cmd/compile: surprising behavior for doubly declared methods #66285
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
Before Go 1.13, it was an error for a method to appear more than once (via embedding) in an interface. For instance, this code produced an error ("duplicate method Read"). With 1.14, such code was permitted.
Similarly, this code also produces the same error under 1.13 as one would expect:
However, this code does not:
The reason is that here the method
Read
both times is imported (throughio.Reader
): because theio
package is "correct", the importedRead
method is "exempt" from the 1.13 version check. This seems odd: even thoughio
is valid, the actual embedding ofRead
happens in the current package (or file) and thus the 1.13 rules should apply irrespective of where the method came from.A method's origin package should not matter for the version test, only the (file) version of the source where the embedding happens.
The text was updated successfully, but these errors were encountered: