Skip to content

Commit 9aeb78f

Browse files
authored
interp: fix method lookup for aliased types
Fixes #1058.
1 parent 7863456 commit 9aeb78f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

interp/cfg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ func (interp *Interpreter) cfg(root *node, importPath string) ([]*node, error) {
14331433
// TODO(mpl): move any of that code to typecheck?
14341434
c.typ.node = c
14351435
if !c.typ.assignableTo(typ) {
1436-
err = fmt.Errorf("cannot use %v (type %v) as type %v in return argument", c.ident, c.typ.cat, typ.cat)
1436+
err = c.cfgErrorf("cannot use %v (type %v) as type %v in return argument", c.ident, c.typ.cat, typ.cat)
14371437
return
14381438
}
14391439
if c.typ.cat == nilT {

interp/type.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,10 @@ func (t *itype) methods() methodSet {
10651065
seen[typ] = true
10661066

10671067
switch typ.cat {
1068+
case aliasT:
1069+
for k, v := range getMethods(typ.val) {
1070+
res[k] = v
1071+
}
10681072
case interfaceT:
10691073
// Get methods from recursive analysis of interface fields.
10701074
for _, f := range typ.field {

0 commit comments

Comments
 (0)