From ef6c5be16025a1868fc27267b7abfb1c28329fe2 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Fri, 11 Jun 2021 02:44:16 -0700 Subject: [PATCH] [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 Reviewed-by: Dan Scales Trust: Dan Scales Trust: Matthew Dempsky TryBot-Result: Go Bot --- src/cmd/compile/internal/reflectdata/reflect.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index 0fcb7e3d6d..bdc3527011 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -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 }