Browse Source

[cs] hide native type param constraints generation behind @:nativeTypeConstraints for now (closes #4002, see #3526)

Dan Korostelev 10 years ago
parent
commit
c2de76355a
2 changed files with 21 additions and 1 deletions
  1. 4 1
      gencs.ml
  2. 17 0
      tests/unit/src/unit/issues/Issue4002.hx

+ 4 - 1
gencs.ml

@@ -1835,7 +1835,10 @@ let configure gen =
 				let get_param_name t = match follow t with TInst(cl, _) -> snd cl.cl_path | _ -> assert false in
 				let get_param_name t = match follow t with TInst(cl, _) -> snd cl.cl_path | _ -> assert false in
 				let params = sprintf "<%s>" (String.concat ", " (List.map (fun (_, tcl) -> get_param_name tcl) cl_params)) in
 				let params = sprintf "<%s>" (String.concat ", " (List.map (fun (_, tcl) -> get_param_name tcl) cl_params)) in
 				let params_extends =
 				let params_extends =
-					if hxgen then
+					if hxgen
+					(* this is temprorary, see https://github.com/HaxeFoundation/haxe/issues/3526 *)
+					|| not (Meta.has (Meta.Custom ":nativeTypeConstraints") cl.cl_meta)
+					then
 						[""]
 						[""]
 					else
 					else
 						List.fold_left (fun acc (name, t) ->
 						List.fold_left (fun acc (name, t) ->

+ 17 - 0
tests/unit/src/unit/issues/Issue4002.hx

@@ -0,0 +1,17 @@
+package unit.issues;
+
+private class A {
+    public var a = 5;
+    public function new() {}
+}
+
+class Issue4002 extends Test {
+    function test() {
+        eq(fail(new A()), 5);
+    }
+
+    function fail<T:A>(v:T):Int {
+        var x = function() return v.a;
+        return x();
+    }
+}