github.com/HaHadaxigua/yaegi@v1.0.1/_test/issue-1156.go (about)

     1  package main
     2  
     3  type myInterface interface {
     4  	myFunc() string
     5  }
     6  
     7  type V struct{}
     8  
     9  func (v *V) myFunc() string { return "hello" }
    10  
    11  type U struct {
    12  	v myInterface
    13  }
    14  
    15  func (u *U) myFunc() string { return u.v.myFunc() }
    16  
    17  func main() {
    18  	x := V{}
    19  	y := myInterface(&x)
    20  	y = &U{y}
    21  	println(y.myFunc())
    22  }
    23  
    24  // Output:
    25  // hello