]> Cypherpunks repositories - gostls13.git/commit
go/types: use correct receiver types for embedded interface methods
authorRobert Griesemer <gri@golang.org>
Thu, 11 Oct 2018 00:19:29 +0000 (17:19 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 11 Oct 2018 18:17:34 +0000 (18:17 +0000)
commit76f578459a3db0153237816a7513497092463aae
tree05f5f0fb5450bea3f7df9ae38095a38a4072d523
parent872a5479574f11d7ebe78118226f2a423e89c993
go/types: use correct receiver types for embedded interface methods

Interface methods don't declare a receiver (it's implicit), but after
type-checking the respective *types.Func objects are marked as methods
by having a receiver. For interface methods, the receiver base type used
to be the interface that declared the method in the first place, even if
the method also appeared in other interfaces via embedding. A change in
the computation of method sets for interfaces for Go1.10 changed that
inadvertently, with the consequence that sometimes a method's receiver
type ended up being an interface into which the method was embedded.
The exact behavior also depended on file type-checking order, and because
files are sometimes sorted by name, the behavior depended on file names.

This didn't matter for type-checking (the typechecker doesn't need the
receiver), but it matters for clients, and for printing of methods.

This change fixes interface method receivers at the end of type-checking
when we have all relevant information.

Fixes #28005.

Change-Id: I96c120fb0e517d7f8a14b8530f0273674569d5ea
Reviewed-on: https://go-review.googlesource.com/c/141358
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/types/issues_test.go
src/go/types/typexpr.go