You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a method set, each method must have a unique non-blank method name.
It also specifies that promoted methods are included in the method set of a struct:
Given a struct type S and a type named T, promoted methods are included in the method set of the struct as follows:
If S contains an anonymous field T, the method sets of S and *S both include promoted methods with receiver T. The method set of *S also includes promoted methods with receiver *T.
If S contains an anonymous field *T, the method sets of S and *S both include promoted methods with receiver T or *T.
These two excerpts seem to imply that there exist a conflict between a promoted method and a non-promoted method with the same name, or between two promoted methods, like in these examples:
package main
typeAstruct{}
func (A) F() {}
typeBstruct{ A }
func (B) F() {}
funcmain() {}
However, all of go, gccgo, and gotypes allow the above programs, so perhaps the intent is for the method name to be unique only among the non-promoted methods?
The text was updated successfully, but these errors were encountered:
The rules are spelled out at https://golang.org/ref/spec#Selectors . But the spec doesn't seem to clearly state that those rules apply not just to selectors, but also to method sets. At least, if it does state that, I can't find it.
The specification states that
It also specifies that promoted methods are included in the method set of a struct:
These two excerpts seem to imply that there exist a conflict between a promoted method and a non-promoted method with the same name, or between two promoted methods, like in these examples:
However, all of
go
,gccgo
, andgotypes
allow the above programs, so perhaps the intent is for the method name to be unique only among the non-promoted methods?The text was updated successfully, but these errors were encountered: