[C#] haxe generates unnecessary Closure when using System.Action #5912

Open
Muxeu opened this Issue Dec 26, 2016 · 0 comments

Projects

None yet

2 participants

@Muxeu
Muxeu commented Dec 26, 2016
typedef Action = cs.system.Action;

@:nativeGen
class Foo {
    private var _test2:Bar;

    public function new() {
        _test2 = new Bar();
        var test3:Bar = new Bar();

        var f:Action = this.testAction;
        f.Invoke();

		//problem here
        var f2:Action = _test2.testAction;
        f2.Invoke();

        var f3:Action = test3.testAction;
        f3.Invoke();
    }

    private function testAction():Void {}
}

@:nativeGen
class Bar {
    public function new () {}

    public function testAction():Void {}
}

Generated code:
http://pastebin.com/qsVyhM21

"var f2:Action" is called thru haxe Closure and extra wrapper class. Replacing "f2 part" with next code fixed the problem.

var tempFix:Bar = _test2;
var f2:Action = tempFix.testAction;
@Muxeu Muxeu changed the title from [C#] haxe generates unnesesary Closure when using System.Action to [C#] haxe generates unnecessaryClosure when using System.Action Dec 26, 2016
@Muxeu Muxeu changed the title from [C#] haxe generates unnecessaryClosure when using System.Action to [C#] haxe generates unnecessary Closure when using System.Action Dec 26, 2016
@Simn Simn modified the milestone: 4.0 Jan 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment