@@ -574,6 +574,8 @@ type Entity =
574574 /// Used during codegen to hold the ILX representation indicating how to access the type
575575 // MUTABILITY: only for unpickle linkage and caching
576576 mutable entity_il_repr_cache : CompiledTypeRepr cache
577+
578+ mutable entity_parent_namespace : Entity option
577579 }
578580 /// The name of the namespace, module or type, possibly with mangling, e.g. List`1, List or FailureException
579581 member x.LogicalName = x.entity_ logical_ name
@@ -845,6 +847,7 @@ type Entity =
845847 | Some x -> NameMap.tryFind n x.CasesTable.CasesByName
846848 | None -> None
847849
850+ member x.ParentNamespace = x.entity_ parent_ namespace
848851
849852 /// Create a new entity with empty, unlinked data. Only used during unpickling of F# metadata.
850853 static member NewUnlinked () : Entity =
@@ -868,7 +871,8 @@ type Entity =
868871 entity_ pubpath = Unchecked.defaultof<_>
869872 entity_ accessiblity= Unchecked.defaultof<_>
870873 entity_ cpath = Unchecked.defaultof<_>
871- entity_ il_ repr_ cache = Unchecked.defaultof<_> }
874+ entity_ il_ repr_ cache = Unchecked.defaultof<_>
875+ entity_ parent_ namespace = Unchecked.defaultof<_> }
872876
873877 /// Create a new entity with the given backing data. Only used during unpickling of F# metadata.
874878 static member New _reason ( data : Entity ) : Entity = data
@@ -1828,10 +1832,11 @@ and Construct =
18281832 entity_ xmldocsig= " "
18291833 entity_ pubpath = Some pubpath
18301834 entity_ cpath = Some cpath
1831- entity_ il_ repr_ cache = newCache() }
1835+ entity_ il_ repr_ cache = newCache()
1836+ entity_ parent_ namespace = None } // todo how to get an Entiry namespace for provided types?
18321837#endif
18331838
1834- static member NewModuleOrNamespace cpath access ( id : Ident ) xml attribs mtype =
1839+ static member NewModuleOrNamespace cpath access ( id : Ident ) xml attribs mtype parentNs =
18351840 let stamp = newStamp()
18361841 // Put the module suffix on if needed
18371842 Tycon.New " mspec"
@@ -1855,7 +1860,8 @@ and Construct =
18551860 entity_ attribs= attribs
18561861 entity_ xmldoc= xml
18571862 entity_ xmldocsig= " "
1858- entity_ il_ repr_ cache = newCache() }
1863+ entity_ il_ repr_ cache = newCache()
1864+ entity_ parent_ namespace = parentNs }
18591865
18601866and Accessibility =
18611867 /// Indicates the construct can only be accessed from any code in the given type constructor, module or assembly. [ ] indicates global scope.
@@ -2742,6 +2748,7 @@ and NonLocalEntityRef =
27422748 ( Some cpath)
27432749 ( TAccess []) ( ident( path.[ k], m)) XmlDoc.Empty []
27442750 ( MaybeLazy.Strict ( Construct.NewEmptyModuleOrNamespaceType Namespace))
2751+ ( Some entity)
27452752 entity.ModuleOrNamespaceType.AddModuleOrNamespaceByMutation( newEntity)
27462753 injectNamespacesFromIToJ newEntity ( k+ 1 )
27472754 let newEntity = injectNamespacesFromIToJ entity i
@@ -4895,7 +4902,7 @@ let NewModuleOrNamespaceType mkind tycons vals =
48954902let NewEmptyModuleOrNamespaceType mkind = NewModuleOrNamespaceType mkind [] []
48964903
48974904/// Create a new TAST Entity node for an F# exception definition
4898- let NewExn cpath ( id : Ident ) access repr attribs doc =
4905+ let NewExn cpath ( id : Ident ) access repr attribs doc parentNs =
48994906 Tycon.New " exnc"
49004907 { entity_ stamp= newStamp()
49014908 entity_ attribs= attribs
@@ -4917,7 +4924,8 @@ let NewExn cpath (id:Ident) access repr attribs doc =
49174924 entity_ tycon_ abbrev = None
49184925 entity_ tycon_ repr = TNoRepr
49194926 entity_ flags= EntityFlags( usesPrefixDisplay= false , isModuleOrNamespace= false , preEstablishedHasDefaultCtor= false , hasSelfReferentialCtor= false , isStructRecordOrUnionType= false )
4920- entity_ il_ repr_ cache= newCache() }
4927+ entity_ il_ repr_ cache= newCache()
4928+ entity_ parent_ namespace = parentNs }
49214929
49224930/// Create a new TAST RecdField node for an F# class, struct or record field
49234931let NewRecdField stat konst id ty isMutable isVolatile pattribs fattribs docOption access secret =
@@ -4936,7 +4944,7 @@ let NewRecdField stat konst id ty isMutable isVolatile pattribs fattribs docOpt
49364944 rfield_ other_ range = None }
49374945
49384946
4939- let NewTycon ( cpath , nm , m , access , reprAccess , kind , typars , docOption , usesPrefixDisplay , preEstablishedHasDefaultCtor , hasSelfReferentialCtor , mtyp ) =
4947+ let NewTycon ( cpath , nm , m , access , reprAccess , kind , typars , docOption , usesPrefixDisplay , preEstablishedHasDefaultCtor , hasSelfReferentialCtor , mtyp , parentNs ) =
49404948 let stamp = newStamp()
49414949 Tycon.New " tycon"
49424950 { entity_ stamp= stamp
@@ -4959,14 +4967,15 @@ let NewTycon (cpath, nm, m, access, reprAccess, kind, typars, docOption, usesPre
49594967 entity_ xmldocsig= " "
49604968 entity_ pubpath= cpath |> Option.map ( fun ( cp : CompilationPath ) -> cp.NestedPublicPath ( mkSynId m nm))
49614969 entity_ cpath = cpath
4962- entity_ il_ repr_ cache = newCache() }
4970+ entity_ il_ repr_ cache = newCache()
4971+ entity_ parent_ namespace = parentNs }
49634972
49644973
4965- let NewILTycon nlpath ( nm , m ) tps ( scoref : ILScopeRef , enc , tdef : ILTypeDef ) mtyp =
4974+ let NewILTycon nlpath ( nm , m ) tps ( scoref : ILScopeRef , enc , tdef : ILTypeDef ) mtyp ( parentNs : Entity option ) =
49664975
49674976 // NOTE: hasSelfReferentialCtor=false is an assumption about mscorlib
49684977 let hasSelfReferentialCtor = tdef.IsClass && ( not scoref.IsAssemblyRef && scoref.AssemblyRef.Name = " mscorlib" )
4969- let tycon = NewTycon( nlpath, nm, m, taccessPublic, taccessPublic, TyparKind.Type, tps, XmlDoc.Empty, true , false , hasSelfReferentialCtor, mtyp)
4978+ let tycon = NewTycon( nlpath, nm, m, taccessPublic, taccessPublic, TyparKind.Type, tps, XmlDoc.Empty, true , false , hasSelfReferentialCtor, mtyp, parentNs )
49704979
49714980 tycon.entity_ tycon_ repr <- TILObjectRepr ( TILObjectReprData ( scoref, enc, tdef))
49724981 tycon.TypeContents.tcaug_ closed <- true
0 commit comments