From de614651561c6d5bfe1e68bddaf0dedab9a0ecb0 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Tue, 1 Jun 2021 10:49:14 -0700 Subject: [dev.typeparams] cmd/compile: allow inlining in instantiated functions Change markType to scan generic types and methods, so that inlineable functions inside generic functions/methods will be properly marked for export, which means inlining inside instantiated functions will work correctly. Also, fix handling of closures for instantiated functions. Some code needs to be adjusted, since instantiated functions/methods are compiled as if in the package of the source generic function/type, rather than in the local package. When we create the closure struct, we want to make sure that the .F field has the same package as the other fields for the closure variables. Also, we need to disable a check in tcCompLit() when being done for an instantiated function, since fields of the closure struct will be from the source package, not the local package. Re-enabled part of the orderedmapsimp test that was disabled because of these issues. Change-Id: Ic4dba8917da0a36b17c0bdb69d6d6edfdf14104a Reviewed-on: https://go-review.googlesource.com/c/go/+/324331 Trust: Dan Scales Run-TryBot: Dan Scales Reviewed-by: Keith Randall --- src/cmd/compile/internal/reflectdata/reflect.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/cmd/compile/internal/reflectdata/reflect.go') diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index 604cec6096..0fcb7e3d6d 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -949,7 +949,7 @@ func writeType(t *types.Type) *obj.LSym { // 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 && - !tbase.IsInstantiated() { + !tbase.IsFullyInstantiated() { if i := typecheck.BaseTypeIndex(t); i >= 0 { lsym.Pkg = tbase.Sym().Pkg.Prefix lsym.SymIdx = int32(i) @@ -1795,7 +1795,7 @@ func methodWrapper(rcvr *types.Type, method *types.Field, forItab bool) *obj.LSy // instantiated methods. if rcvr.IsPtr() && rcvr.Elem() == method.Type.Recv().Type && rcvr.Elem().Sym() != nil && rcvr.Elem().Sym().Pkg != types.LocalPkg && - !rcvr.Elem().IsInstantiated() { + !rcvr.Elem().IsFullyInstantiated() { return lsym } -- cgit v1.2.3-54-g00ecf