diff options
Diffstat (limited to 'src/cmd/compile/internal/reflectdata/reflect.go')
-rw-r--r-- | src/cmd/compile/internal/reflectdata/reflect.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index b3688fca67..3576a23db9 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -951,8 +951,12 @@ func writeType(t *types.Type) *obj.LSym { } if base.Ctxt.Pkgpath != "runtime" || (tbase != types.Types[tbase.Kind()] && tbase != types.ByteType && tbase != types.RuneType && tbase != types.ErrorType) { // int, float, etc - // named types from other files are defined only by those files - if tbase.Sym() != nil && tbase.Sym().Pkg != types.LocalPkg { + // Named types from other files are defined only by those files. + // However, as an exception, we can write out instantiated types + // in the local package, even if they may be marked as part of + // another package (the package of their base generic type). + if tbase.Sym() != nil && tbase.Sym().Pkg != types.LocalPkg && + len(tbase.RParams()) == 0 { if i := typecheck.BaseTypeIndex(t); i >= 0 { lsym.Pkg = tbase.Sym().Pkg.Prefix lsym.SymIdx = int32(i) |