Skip to content

Commit

Permalink
fix: handle method declaration with forward declared type
Browse files Browse the repository at this point in the history
  • Loading branch information
mvertes committed Feb 7, 2020
1 parent 23dfef0 commit 6c339ce
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
29 changes: 29 additions & 0 deletions _test/method31.go
Original file line number Diff line number Diff line change
@@ -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}
3 changes: 3 additions & 0 deletions interp/gta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6c339ce

Please sign in to comment.