aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/selection.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-03-02 21:52:09 -0800
committerRobert Griesemer <gri@golang.org>2021-03-03 20:01:55 +0000
commit6db80d74200675e20c562684c0bcc6d12a5631eb (patch)
treec3147ccf2ea9f856fdcf127d637b34983c9ac2a2 /src/cmd/compile/internal/types2/selection.go
parentd6f6ef6358f15d6e49d949749869f199d99d5047 (diff)
downloadgo-6db80d74200675e20c562684c0bcc6d12a5631eb.tar.gz
go-6db80d74200675e20c562684c0bcc6d12a5631eb.zip
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>
Diffstat (limited to 'src/cmd/compile/internal/types2/selection.go')
-rw-r--r--src/cmd/compile/internal/types2/selection.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/types2/selection.go b/src/cmd/compile/internal/types2/selection.go
index 67d1aa7e1d..02c0fc6902 100644
--- a/src/cmd/compile/internal/types2/selection.go
+++ b/src/cmd/compile/internal/types2/selection.go
@@ -51,8 +51,8 @@ func (s *Selection) Kind() SelectionKind { return s.kind }
// Recv returns the type of x in x.f.
func (s *Selection) Recv() Type { return s.recv }
-// Work-around for bug where a (*instance) shows up in a final type.
-// TODO(gri): fix this bug.
+// Work-around for a compiler issue where an (*instance) escapes.
+// TODO(gri): Is this still needed?
func (s *Selection) TArgs() []Type {
r := s.recv
if p := asPointer(r); p != nil {