diff --git a/_test/struct38.go b/_test/struct38.go new file mode 100644 index 00000000..8d1973b6 --- /dev/null +++ b/_test/struct38.go @@ -0,0 +1,24 @@ +package main + +type T struct { + f func(t *T1) + y *xxx +} + +type T1 struct { + T +} + +type xxx struct{} + +var ( + x1 *T1 = x + x = &T1{} +) + +func main() { + println("ok") +} + +// Output: +// ok diff --git a/interp/gta.go b/interp/gta.go index 79d5c79c..209a58d0 100644 --- a/interp/gta.go +++ b/interp/gta.go @@ -1,8 +1,6 @@ package interp -import ( - "reflect" -) +import "reflect" // gta performs a global types analysis on the AST, registering types, // variables and functions symbols at package level, prior to CFG. diff --git a/interp/type.go b/interp/type.go index c12e735f..dde6970f 100644 --- a/interp/type.go +++ b/interp/type.go @@ -905,6 +905,9 @@ var interf = reflect.TypeOf(new(interface{})).Elem() func (t *itype) refType(defined map[string]*itype, wrapRecursive bool) reflect.Type { if t.rtype != nil { + if wrapRecursive && t.cat == structT && defined[t.name] != nil { + return interf + } return t.rtype }