Skip to content

Commit

Permalink
[java/cs] Support dynamic functions in interfaces. Closes HaxeFoundat…
Browse files Browse the repository at this point in the history
  • Loading branch information
waneck committed Jul 12, 2014
1 parent 2d5a4ae commit ac16080
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gencommon.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10149,6 +10149,10 @@ struct
);
cl.cl_fields <- PMap.remove cf.cf_name cl.cl_fields;
false
| Method MethDynamic ->
(* TODO OPTIMIZATION - add a `_dispatch` method to the interface which will call the dynamic function itself *)
cl.cl_fields <- PMap.remove cf.cf_name cl.cl_fields;
false
| _ -> true
) cl.cl_ordered_fields in

Expand Down
34 changes: 34 additions & 0 deletions tests/unit/issues/Issue3159.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package unit.issues;

class Issue3159 extends Test
{
public function test()
{
var dmet = new DynamicMethod();
f(dmet.hasCalled);
var test:IHasDynamicMethod = dmet;
test.foo();
t(dmet.hasCalled);
test.foo = function() dmet.hasCalled = false;
test.foo();
f(dmet.hasCalled);
}
}

interface IHasDynamicMethod
{
dynamic function foo():Void;
}

private class DynamicMethod implements IHasDynamicMethod
{
public var hasCalled = false;
public function new()
{
}

dynamic public function foo()
{
hasCalled = true;
}
}

0 comments on commit ac16080

Please sign in to comment.