Skip to content

Commit

Permalink
[java/cs] Make sure to collect the right type parameters on anonymous…
Browse files Browse the repository at this point in the history
… functions

Closes #5793
  • Loading branch information
waneck committed Jun 18, 2017
1 parent 833e3a2 commit 3d4e2be
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/generators/gencommon/closuresToClass.ml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ let get_captured expr =
let configure gen ft =

let handle_anon_func fexpr tfunc mapinfo delegate_type : texpr * (tclass * texpr list) =
let fexpr = match fexpr.eexpr with
| TFunction(_) ->
{ fexpr with eexpr = TFunction(tfunc) }
| _ ->
gen.gcon.error "Function expected" fexpr.epos;
fexpr
in
let in_unsafe = mapinfo.in_unsafe || match gen.gcurrent_class, gen.gcurrent_classfield with
| Some c, _ when Meta.has Meta.Unsafe c.cl_meta -> true
| _, Some cf when Meta.has Meta.Unsafe cf.cf_meta -> true
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/src/unit/issues/Issue5793.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package unit.issues;

class Issue5793 extends Test {
public function test() {
function run1() {
function foo <T> (expected:Array<T>, a:T) {
eq(expected[0], a);
}
foo([2], 2);
}
run1();

function run2() {
function bar<A>(expected:Array<A>, a:A) {
function baz<B>(expected:Array<B>, b:B) {
eq(expected[0], b);
}
baz(expected,a);
}
bar([42],42);
}
run2();
}
}

0 comments on commit 3d4e2be

Please sign in to comment.