Skip to content

Commit

Permalink
Fixes issue #176 (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
SlavaRa authored Aug 23, 2016
1 parent 214c54f commit 3ef91ae
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/as3hx/Writer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2654,6 +2654,13 @@ class Writer
rebuiltCall = ECall(EField(EIdent("Reflect"), "callMethod"), params);
}
}
else if(f == "call") {
var type = getExprType(e);
if(type == "Function") {
params = [EIdent("null"), e].concat([EArrayDecl(params.slice(1))]);
rebuiltCall = ECall(EField(EIdent("Reflect"), "callMethod"), params);
}
}
else {
var ident = getIdentString(e);
if (ident != null) {
Expand Down
8 changes: 8 additions & 0 deletions test/issues/Issue176.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package {
public class Issue176 {
public function Issue176() {
var call:Function = trace;
call.call(null, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
}
}
}
9 changes: 9 additions & 0 deletions test/issues/Issue176.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

class Issue176
{
public function new()
{
var call : Function = trace;
Reflect.callMethod(null, call, [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]);
}
}
5 changes: 5 additions & 0 deletions test/unit/as3hx/AS3HXTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ class AS3HXTest {
generate("Issue167.as", "Issue167.hx");
}

@Test("function.call(null, 1,2,3,4,5,6,7,8,9,0) -> Reflect.callMethod(null, function, [1,2,3,4,5,6,7,8,9,0])")
public function issue176() {
generate("Issue176.as", "Issue176.hx");
}

function generate(as3FileName:String, expectedHaxeFileName:String) {
var issuesDirectory = FileSystem.absolutePath("test/issues");
var generatedDirectoryPath = '$issuesDirectory/generated';
Expand Down

0 comments on commit 3ef91ae

Please sign in to comment.