From 3081f817da8c194982596ddddf5d3ec321c859af Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Fri, 20 Aug 2021 16:15:53 -0700 Subject: cmd/compile: always remove receiver type from instantiated method values If a type T has a method foo, then var t T var i interface{} = t.foo The type of foo is a method type, but the type of t.foo should be a standard function type. Make sure we always do that conversion. Fixes #47775 Change-Id: I464ec792196b050aba1914e070a4ede34bfd0bfa Reviewed-on: https://go-review.googlesource.com/c/go/+/343881 Trust: Keith Randall Trust: Dan Scales Reviewed-by: Matthew Dempsky Reviewed-by: Dan Scales --- src/cmd/compile/internal/typecheck/dcl.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/cmd/compile/internal/typecheck/dcl.go') diff --git a/src/cmd/compile/internal/typecheck/dcl.go b/src/cmd/compile/internal/typecheck/dcl.go index 11e20f0f07..472d8d2b8a 100644 --- a/src/cmd/compile/internal/typecheck/dcl.go +++ b/src/cmd/compile/internal/typecheck/dcl.go @@ -479,6 +479,12 @@ func autotmpname(n int) string { // f is method type, with receiver. // return function type, receiver as first argument (or not). func NewMethodType(sig *types.Type, recv *types.Type) *types.Type { + if sig.HasTParam() { + base.Fatalf("NewMethodType with type parameters in signature %+v", sig) + } + if recv != nil && recv.HasTParam() { + base.Fatalf("NewMethodType with type parameters in receiver %+v", recv) + } nrecvs := 0 if recv != nil { nrecvs++ -- cgit v1.2.3-54-g00ecf