HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.16k stars 658 forks source link

java compilation error with Typedefs #2889

Closed frabbit closed 10 years ago

frabbit commented 10 years ago

This code:

typedef Mappable<T> = {
  public function map <B>(f:T->B):Array<B>;
}

class Test {

  public static function main() {

    function mapMappable <A,B>(m:Mappable<A>, f:A->B):Mappable<B> {
      return m.map(f);
    }
    var r = mapMappable([1], function (y) return y+1);
  }

}

causes this java compilation error:

src/haxe/root/Test.java:38: error: cannot find symbol java.lang.Object r = ((java.lang.Object) (new haxe.root.Test_main_13Fun<java.lang.Object, java.lang.Object, B1>().hx_invoke2_o(0.0, new haxe.root.Array(new java.lang.Object[]{1}), 0.0, ( (( haxe.root.Test_main_16Fun.hx_current != null )) ? (haxe.root.Test_main_16Fun.hx_current) : (haxe.root.Test_main_16Fun.hx_current = ((haxe.root.Test_main_16Fun) (new haxe.root.Test_main_16Fun()) )) ))) ); ^ symbol: class B1 location: class Test 1 error Compilation error Native compilation failed Error: Build failed

frabbit commented 10 years ago

@waneck do you think this is difficult to fix? This is the only issue that prevents successful compilation of higher kinded types for java and c#, see https://travis-ci.org/Simn/haxe/builds/23751139.

waneck commented 10 years ago

It shouldn't be hard. I'll try to have a look this weekend

frabbit commented 10 years ago

Sounds great, thx.

waneck commented 10 years ago

The added test still fails on AS3