fix: handle method declaration with forward declared type
This commit is contained in:
29
_test/method31.go
Normal file
29
_test/method31.go
Normal 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}
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user