summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorZubin Duggal <zubin.duggal@gmail.com>2022-03-17 19:41:01 +0530
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-07-13 14:00:18 -0400
commite9d9f0784e8670c6b85f1bf80e26b571b08519b5 (patch)
tree4bb50ffa8d21b8abcc5489099218aef48246f054 /compiler
parent8b417ad54a91a7e12671cf059e0b5a3be43bbce2 (diff)
downloadhaskell-e9d9f0784e8670c6b85f1bf80e26b571b08519b5.tar.gz
hie-files: Fix scopes for deriving clauses and instance signatures (#18425)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Iface/Ext/Ast.hs10
-rw-r--r--compiler/GHC/Iface/Ext/Utils.hs3
2 files changed, 7 insertions, 6 deletions
diff --git a/compiler/GHC/Iface/Ext/Ast.hs b/compiler/GHC/Iface/Ext/Ast.hs
index 43cd29bc1c..affe0e7ca4 100644
--- a/compiler/GHC/Iface/Ext/Ast.hs
+++ b/compiler/GHC/Iface/Ext/Ast.hs
@@ -1583,7 +1583,7 @@ instance ToHie (Located [LocatedAn NoEpAnns (HsDerivingClause GhcRn)]) where
instance ToHie (LocatedAn NoEpAnns (HsDerivingClause GhcRn)) where
toHie (L span cl) = concatM $ makeNodeA cl span : case cl of
HsDerivingClause _ strat dct ->
- [ toHie strat
+ [ toHie (RS (mkLScopeA dct) <$> strat)
, toHie dct
]
@@ -1592,12 +1592,12 @@ instance ToHie (LocatedC (DerivClauseTys GhcRn)) where
DctSingle _ ty -> [ toHie $ TS (ResolvedScopes []) ty ]
DctMulti _ tys -> [ toHie $ map (TS (ResolvedScopes [])) tys ]
-instance ToHie (LocatedAn NoEpAnns (DerivStrategy GhcRn)) where
- toHie (L span strat) = concatM $ makeNodeA strat span : case strat of
+instance ToHie (RScoped (LocatedAn NoEpAnns (DerivStrategy GhcRn))) where
+ toHie (RS sc (L span strat)) = concatM $ makeNodeA strat span : case strat of
StockStrategy _ -> []
AnyclassStrategy _ -> []
NewtypeStrategy _ -> []
- ViaStrategy s -> [ toHie (TS (ResolvedScopes []) s) ]
+ ViaStrategy s -> [ toHie (TS (ResolvedScopes [sc]) s) ]
instance ToHie (LocatedP OverlapMode) where
toHie (L span _) = locOnly (locA span)
@@ -1970,7 +1970,7 @@ instance ToHie (LocatedA (DerivDecl GhcRn)) where
toHie (L span decl) = concatM $ makeNodeA decl span : case decl of
DerivDecl _ typ strat overlap ->
[ toHie $ TS (ResolvedScopes []) typ
- , toHie strat
+ , toHie $ (RS (mkScopeA span) <$> strat)
, toHie overlap
]
diff --git a/compiler/GHC/Iface/Ext/Utils.hs b/compiler/GHC/Iface/Ext/Utils.hs
index 20d047d150..aece9ed044 100644
--- a/compiler/GHC/Iface/Ext/Utils.hs
+++ b/compiler/GHC/Iface/Ext/Utils.hs
@@ -296,8 +296,9 @@ getNameBindingInClass
-> Maybe Span
getNameBindingInClass n sp asts = do
ast <- M.lookup (HiePath (srcSpanFile sp)) asts
+ clsNode <- selectLargestContainedBy sp ast
getFirst $ foldMap First $ do
- child <- flattenAst ast
+ child <- flattenAst clsNode
dets <- maybeToList
$ M.lookup (Right n) $ sourcedNodeIdents $ sourcedNodeInfo child
let binding = foldMap (First . getBindSiteFromContext) (identInfo dets)