Skip to content

Commit 427a88e

Browse files
committed
fix call on method expression (gopherjs#256)
1 parent 13d7ae2 commit 427a88e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

compiler/expressions.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,9 @@ func (c *funcContext) translateExpr(expr ast.Expr) *expression {
678678
}
679679
return c.formatExpr("%s", c.translateCall(e, sig, c.formatExpr("%e.%s", f.X, strings.Join(fields, "."))))
680680

681+
case types.MethodExpr:
682+
return c.formatExpr("%s", c.translateCall(e, sig, c.translateExpr(f)))
683+
681684
default:
682685
panic("")
683686
}

tests/misc_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,3 +387,15 @@ func TestGoStmtWithStructArg(t *testing.T) {
387387
t.Fail()
388388
}
389389
}
390+
391+
type methodExprCallType struct{ i int }
392+
393+
func (t methodExprCallType) test() int {
394+
return t.i + 2
395+
}
396+
397+
func TestMethodExprCall(t *testing.T) {
398+
if methodExprCallType.test(methodExprCallType{40}) != 42 {
399+
t.Fail()
400+
}
401+
}

0 commit comments

Comments
 (0)