-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
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:
type T interface {
io.Reader
Reader
}
type Reader interface {
Read(p []byte) (n int, err error)
}However, this code does not:
type T interface {
io.Reader
io.Reader
}The reason is that here the method Read both times is imported (through io.Reader): because the io package is "correct", the imported Read method is "exempt" from the 1.13 version check. This seems odd: even though io is valid, the actual embedding of Read 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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status