fix: handle method declaration with forward declared type

This commit is contained in:
Marc Vertes
2020-02-07 15:44:04 +01:00
committed by GitHub
parent 23dfef0ac8
commit 6c339ce562
2 changed files with 32 additions and 0 deletions

29
_test/method31.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import "fmt"
var db dbWrapper
type dbWrapper struct {
DB *cmap
}
func (d *dbWrapper) get() *cmap {
return d.DB
}
type cmap struct {
name string
}
func (c *cmap) f() {
fmt.Println("in f, c", c)
}
func main() {
db.DB = &cmap{name: "test"}
db.get().f()
}
// Output:
// in f, c &{test}

View File

@@ -125,6 +125,9 @@ func (interp *Interpreter) gta(root *node, rpath, pkgID string) ([]*node, error)
// Add a function symbol in the package name space
sc.sym[n.child[1].ident] = &symbol{kind: funcSym, typ: n.typ, node: n, index: -1}
}
if n.typ.incomplete {
revisit = append(revisit, n)
}
return false
case importSpec: