GoPLS Viewer

Home|gopls/go/pointer/testdata/rtti.go
1package 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
12import "reflect"
13
14var a int
15
16type X struct{}
17
18func (XF() *int {
19    return &a
20}
21
22type I interface {
23    F() *int
24}
25
26func main() {
27    type Y struct{ X }
28    print(reflect.Indirect(reflect.ValueOf(new(Y))).Interface().(I).F()) // @pointsto command-line-arguments.a
29}
30
MembersX
X
X.F
main.BlockStmt.Y
Members
X