1
0
mirror of https://github.com/golang/go synced 2024-11-22 20:40:03 -07:00

[dev.typeparams] cmd/compile: fix wrapper generation for imported generics

This CL fixes reflectdata.methodWrapper to compile wrapper functions
for method expressions involving imported, instantiated interface
types. CL 322193 fixed a similar issue for generating wrappers for
imported, instantiated concrete types, but missed this case.

This is necessary to fix CL 326169's test case 10. However, that test
case is not included currently, because -G=3 mode crashes on method
expressions involving *any* instantiated interface type. Adding a test
will have to wait until either this issue is fixed in -G=3 mode, or
unified IR is merged.

Updates #46704.

Change-Id: Ib02d3c20e7c69d16288f1286cd1c98e7cbbba114
Reviewed-on: https://go-review.googlesource.com/c/go/+/327055
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Matthew Dempsky 2021-06-11 02:44:16 -07:00
parent 4a735ce068
commit ef6c5be160

View File

@ -1800,8 +1800,11 @@ func methodWrapper(rcvr *types.Type, method *types.Field, forItab bool) *obj.LSy
}
// Only generate I.M wrappers for I in I's own package
// but keep doing it for error.Error (was issue #29304).
if rcvr.IsInterface() && rcvr.Sym() != nil && rcvr.Sym().Pkg != types.LocalPkg && rcvr != types.ErrorType {
// but keep doing it for error.Error (was issue #29304)
// and methods of instantiated interfaces.
if rcvr.IsInterface() && rcvr != types.ErrorType &&
rcvr.Sym() != nil && rcvr.Sym().Pkg != types.LocalPkg &&
!rcvr.IsFullyInstantiated() {
return lsym
}