go/types: what is the (types.Object) identity of embedded methods? #34421
Labels
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
Up to Go 1.13, embedded interfaces could not have overlapping methods. The corresponding
go/types
implementation, when computing method sets of interfaces, reused the original methods in embedding methods. For instance, given:the
go/types
methodFunc
Object
form
inB
was the same as inA
. We know that some (external) tests depended on this property. A consequence of this is that the source position ofB.m
is the same as the one ofA.m
; it is not the position of the embeddedA
inB
.With Go 1.14, embedded interfaces may overlap. The same method
m
(with identical signature), may be embedded in an interface through multiple embedded interfaces:Now, it is not clear which "original" method
m
should be used in the method set forC
. It could be the "first" one (as in the one embedded via the earliest embedded interface providingm
in the source, soA
in this example), or it could be undefined. Or it could be a new methodFunc
Object
. Note that the latter choice wouldn't be of much help when deciding which position should be assigned tom
as it could be any of the embedded interfaces that providem
.This boils down to what kind of API guarantee should be provided by
go/types
.The text was updated successfully, but these errors were encountered: