]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/types2: use correct recv for parameterized embedded methods
authorRobert Griesemer <gri@golang.org>
Wed, 3 Mar 2021 05:52:09 +0000 (21:52 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 3 Mar 2021 20:01:55 +0000 (20:01 +0000)
commit6db80d74200675e20c562684c0bcc6d12a5631eb
treec3147ccf2ea9f856fdcf127d637b34983c9ac2a2
parentd6f6ef6358f15d6e49d949749869f199d99d5047
cmd/compile/internal/types2: use correct recv for parameterized embedded methods

Methods of generic types are instantiated lazily (upon use). Thus,
when we encounter a method of such a type, we need to instantiate
the method signature with the receiver type arguments. We infer
those type arguments from the method receiver. If the method is
embedded, we must use the actual embedded receiver type, otherwise
the receiver type declared with the method doesn't match up and
inference will fail.

(Note that there's no type inference in the source code here, it's
only the implementation which uses the existing inference mechanism
to easily identify the actual type arguments. If the implementation
is correct, the inference will always succeed.)

Updates #44688.

Change-Id: Ie35b62bebaeaf42037f2ca00cf8bd34fec2ddd9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/298129
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/call.go
src/cmd/compile/internal/types2/fixedbugs/issue44688.go2 [new file with mode: 0644]
src/cmd/compile/internal/types2/selection.go