github.com/powerman/golang-tools@v0.1.11-0.20220410185822-5ad214d8d803/go/pointer/testdata/rtti.go (about) 1 package main 2 3 // Regression test for guru crash 4 // https://code.google.com/p/go/issues/detail?id=6605 5 // 6 // Using reflection, methods may be called on types that are not the 7 // operand of any ssa.MakeInterface instruction. In this example, 8 // (Y).F is called by deriving the type Y from *Y. Prior to the fix, 9 // no RTTI (or method set) for type Y was included in the program, so 10 // the F() call would crash. 11 12 import "reflect" 13 14 var a int 15 16 type X struct{} 17 18 func (X) F() *int { 19 return &a 20 } 21 22 type I interface { 23 F() *int 24 } 25 26 func main() { 27 type Y struct{ X } 28 print(reflect.Indirect(reflect.ValueOf(new(Y))).Interface().(I).F()) // @pointsto command-line-arguments.a 29 }