1
0
mirror of https://github.com/golang/go synced 2024-11-17 19:54:45 -07:00

cmd/compile: fix problem with methods of instantiated types which are nointerface

In the case of a nointerface method on an instantiated type, we still
have to call methodWrapper, because methodWrapper generates the actual
generic method on the type as well. Currently, we don't call
methodWrapper, so the method on the instantiated type never gets filled
in.

Adjusted the code to still call methodWrapper, but not use the result,
in the case of a nointerface method on an instantiated type.

Change-Id: I34bca58de2861aa772be04eb8dd7695c5b7f3a77
Reviewed-on: https://go-review.googlesource.com/c/go/+/353369
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
This commit is contained in:
Dan Scales 2021-09-29 17:47:19 -07:00
parent 695a59b513
commit 55e7f7e12d

View File

@ -329,7 +329,11 @@ func methods(t *types.Type) []*typeSig {
if f.Type.Recv() == nil { if f.Type.Recv() == nil {
base.Fatalf("receiver with no type on %v method %v %v", mt, f.Sym, f) base.Fatalf("receiver with no type on %v method %v %v", mt, f.Sym, f)
} }
if f.Nointerface() { if f.Nointerface() && !t.IsFullyInstantiated() {
// Skip creating method wrappers if f is nointerface. But, if
// t is an instantiated type, we still have to call
// methodWrapper, because methodWrapper generates the actual
// generic method on the type as well.
continue continue
} }
@ -348,6 +352,11 @@ func methods(t *types.Type) []*typeSig {
type_: typecheck.NewMethodType(f.Type, t), type_: typecheck.NewMethodType(f.Type, t),
mtype: typecheck.NewMethodType(f.Type, nil), mtype: typecheck.NewMethodType(f.Type, nil),
} }
if f.Nointerface() {
// In the case of a nointerface method on an instantiated
// type, don't actually apppend the typeSig.
continue
}
ms = append(ms, sig) ms = append(ms, sig)
} }