Thanks Ian, you are of course correct- but I still don't get it. Thank you for taking the time.
> m.EqualName has to mean something. The Go language defines it as meaning the field in m's type, rather than the embedded method. Doesn't have meter an embedded field of type EqualName (the interface)? > Therefore, the type meter does not have a method EqualName. Therefore, the type meter does not implement the EqualName interface. meter doesn't. But impl's methods get promoted to meter- which happens with different name: clearly the different name method has become promoted, implements the different namer interface and is non-nil. I still don't fully understand why this doesn't work for equal name. If impl's equal name method does get promoted it should implement the interface since meter now as a equal name method. If it doesn't (due to name conflict with the embedded equal name interface) where would still be the embedded equal name interface (which might be nil but still existing)? Thanks, Andi On Thursday, February 27, 2025 at 6:40:30 PM UTC+1 Ian Lance Taylor wrote: > On Thu, Feb 27, 2025 at 9:32 AM cpu...@gmail.com <cpu...@gmail.com> wrote: > > > > I can see that that's the difference and cause but I'm not convinced by > the explanation (although that clearly is what happens): > > > > If the embedded method name EqualName shadows the method name EqualName > that should still implement the interface of the same signature? I.e. why > doesn't the shadow implement the interface? > > I'm sorry, I don't understand the question. I'll try to explain what > is happening. > > m.EqualName has to mean something. The Go language defines it as > meaning the field in m's type, rather than the embedded method. > Therefore, the type meter does not have a method EqualName. Therefore, > the type meter does not implement the EqualName interface. > > I note that this kind of confusion between interface name and method > name is the Go standard library is careful to do things like an > interface Writer with a method Write. We don't use the same name for > an interface type and the method(s) that it includes. > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/1a4bf2ee-f1ae-4ff2-9829-38506870cad9n%40googlegroups.com.