Well, start of by not using Java/C#/C++ terminology as Go is different
and in Go you simply cannot have a "specialization s of i" as there are
no "specialization" as there is no inheritance. Also let's rewrite the code
to be a bit more Go'ish:
package main
import "fmt"
type T struct{}
func (t *T) NotInS() { t.M() }
func (t *T) M() { fmt.Println("T.M") }
type S struct{ *T }
func (s *S) M() { fmt.Println("S.M") }
func main() {
x := &S{&T{}}
x.NotInS()
}
You see S has no method NotInS defined and all calls to
NotInS are automatically directed to implicit field T of
S. Remember that embedding a *T in an S has nothing to
do with inheritance or specialisation. It is just some tiny
syntactic sugar for an implicit field and automatic method
forwarding to that field. Spelling it out your code is
equivalent to:
type S struct{ T *T }
func (s *S) NotInS() { s.T.M() }
The embedded T doesn't know it is a field of S and you
call T's M method and it is simply impossible to have
S's M method called like this.
You must redesign. Embedding is not inheritance and
you cannot modle inheritance based design with embedding
no matter how hard you try.
V.