Open stevenblenkinsop opened 11 years ago
The behaviour of sFn seems consistent with the behaviour of iFn logically, I just wasn't sure if it was expected based on the wording of the spec. I was checking through the spec to see how the term "receiver" was used because of a topic I posted to the mailing list, and happened upon this. It already says that x in x.M will be dereferenced to match the receiver of the function. Dereferencing just doesn't normally mean traversing anonymous fields. I suppose the current behaviour could be justified using the "x.f is shorthand for (*x.A).f" rule, but nowhere else is the literal expansion of this "shorthand" semantically significant, that I can think of. If this is the basis for the current behaviour, then it bears mentioning along with auto-reference/dereference, especially since auto-dereference is just a special case of it. I didn't think it was worth mentioning, but the other behaviour (observing the change to *t rather than not) is observed when an interface is involved: http://play.golang.org/p/993ZmY8324 But I was fairly certain this was expected based on both the language spec and how interfaces normally behave as an opaque barrier between static and dynamic dispatch of methods.
The current behaviour is also consistent with the behaviour of defer: http://play.golang.org/p/oOrplS9704