Skip to content

Commit

Permalink
interp: fix method lookup for aliased types
Browse files Browse the repository at this point in the history
Fixes #1058.
  • Loading branch information
mvertes authored Apr 13, 2021
1 parent 7863456 commit 9aeb78f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion interp/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ func (interp *Interpreter) cfg(root *node, importPath string) ([]*node, error) {
// TODO(mpl): move any of that code to typecheck?
c.typ.node = c
if !c.typ.assignableTo(typ) {
err = fmt.Errorf("cannot use %v (type %v) as type %v in return argument", c.ident, c.typ.cat, typ.cat)
err = c.cfgErrorf("cannot use %v (type %v) as type %v in return argument", c.ident, c.typ.cat, typ.cat)
return
}
if c.typ.cat == nilT {
Expand Down
4 changes: 4 additions & 0 deletions interp/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,10 @@ func (t *itype) methods() methodSet {
seen[typ] = true

switch typ.cat {
case aliasT:
for k, v := range getMethods(typ.val) {
res[k] = v
}
case interfaceT:
// Get methods from recursive analysis of interface fields.
for _, f := range typ.field {
Expand Down

0 comments on commit 9aeb78f

Please sign in to comment.