X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FbasicTypes%2FRdrName.lhs;h=31ffe6a41ce38e726ca69ebe55279b0f6a6b89d6;hp=6b28786145bafddf41f3157dd13f1e90e92433d3;hb=61bcd16d4f3d4cf84b26bf7bb92f16f0440b7071;hpb=66579ff945831c5fc9a17c58c722ff01f2268d76 diff --git a/compiler/basicTypes/RdrName.lhs b/compiler/basicTypes/RdrName.lhs index 6b28786..31ffe6a 100644 --- a/compiler/basicTypes/RdrName.lhs +++ b/compiler/basicTypes/RdrName.lhs @@ -353,6 +353,12 @@ type GlobalRdrEnv = OccEnv [GlobalRdrElt] -- -- INVARIANT: All the members of the list have distinct -- 'gre_name' fields; that is, no duplicate Names +-- +-- INVARIANT: Imported provenance => Name is an ExternalName +-- However LocalDefs can have an InternalName. This +-- happens only when type-checking a [d| ... |] Template +-- Haskell quotation; see this note in RnNames +-- Note [Top-level Names in Template Haskell decl quotes] -- | An element of the 'GlobalRdrEnv' data GlobalRdrElt @@ -361,6 +367,12 @@ data GlobalRdrElt gre_prov :: Provenance -- ^ Why it's in scope } +-- | The children of a Name are the things that are abbreviated by the ".." +-- notation in export lists. Specifically: +-- TyCon Children are * data constructors +-- * record field ids +-- Class Children are * class operations +-- Each child has the parent thing as its Parent data Parent = NoParent | ParentIs Name deriving (Eq) @@ -461,16 +473,17 @@ pickGREs rdr_name gres pick :: GlobalRdrElt -> Maybe GlobalRdrElt pick gre@(GRE {gre_prov = LocalDef, gre_name = n}) -- Local def - | rdr_is_unqual = Just gre - | Just (mod,_) <- rdr_is_qual, - mod == moduleName (nameModule n) = Just gre - | otherwise = Nothing + | rdr_is_unqual = Just gre + | Just (mod,_) <- rdr_is_qual -- Qualified name + , Just n_mod <- nameModule_maybe n -- Binder is External + , mod == moduleName n_mod = Just gre + | otherwise = Nothing pick gre@(GRE {gre_prov = Imported [is]}) -- Single import (efficiency) | rdr_is_unqual, - not (is_qual (is_decl is)) = Just gre + not (is_qual (is_decl is)) = Just gre | Just (mod,_) <- rdr_is_qual, - mod == is_as (is_decl is) = Just gre - | otherwise = Nothing + mod == is_as (is_decl is) = Just gre + | otherwise = Nothing pick gre@(GRE {gre_prov = Imported is}) -- Multiple import | null filtered_is = Nothing | otherwise = Just (gre {gre_prov = Imported filtered_is})