fix: handle forward declaration for aliased type

This commit is contained in:
Marc Vertes
2020-04-22 10:50:05 +02:00
committed by GitHub
parent 7b2d91bcb5
commit 71f730b3d7
2 changed files with 16 additions and 1 deletions

15
_test/type22.go Normal file
View File

@@ -0,0 +1,15 @@
package main
type T1 T
func foo() T1 {
return T1(T{"foo"})
}
type T struct {
Name string
}
func main() {
println(foo().Name)
}

View File

@@ -192,7 +192,7 @@ func (interp *Interpreter) gta(root *node, rpath, pkgID string) ([]*node, error)
return false
}
if n.child[1].kind == identExpr {
n.typ = &itype{cat: aliasT, val: typ, name: typeName, path: rpath, field: typ.field, incomplete: typ.incomplete, scope: sc}
n.typ = &itype{cat: aliasT, val: typ, name: typeName, path: rpath, field: typ.field, incomplete: typ.incomplete, scope: sc, node: n.child[0]}
copy(n.typ.method, typ.method)
} else {
n.typ = typ