浏览代码

[java] Re-enable the 2086 test

Ref #6398
Caue Waneck 7 年之前
父节点
当前提交
4f484039a4

+ 2 - 2
src/codegen/gencommon/dynamicFieldAccess.ml

@@ -68,8 +68,8 @@ let configure gen (is_dynamic:texpr->Type.tfield_access->bool) (change_expr:texp
 		(* class types *)
 		| TField(fexpr, f) when is_nondynamic_tparam fexpr f ->
 			(match follow fexpr.etype with
-				| TInst({ cl_kind = KTypeParameter(tl) }, _) ->
-					let t = List.find (fun t -> not (is_dynamic { fexpr with etype = t } f)) tl in
+				| TInst( ({ cl_kind = KTypeParameter(tl) } as tp_cl), tp_tl) ->
+					let t = apply_params tp_cl.cl_params tp_tl (List.find (fun t -> not (is_dynamic { fexpr with etype = t } f)) tl) in
 					{ e with eexpr = TField(mk_cast t (run fexpr), f) }
 				| _ -> assert false)
 

+ 9 - 0
src/codegen/gencommon/overloadingConstructor.ml

@@ -115,6 +115,15 @@ let create_static_ctor com ~empty_ctor_expr cl ctor follow_type =
 		let static_ctor_name = make_static_ctor_name cl in
 		(* create the static constructor *)
 		let ctor_types = List.map (fun (s,t) -> (s, TInst(map_param (get_cl_t t), []))) cl.cl_params in
+		let ctor_type_params = List.map snd ctor_types in
+		List.iter (function (_,TInst(c,[])) -> (
+			match c.cl_kind with
+			| KTypeParameter (hd :: tail) ->
+				let before = hd :: tail in
+				let after = List.map (apply_params cl.cl_params ctor_type_params) (before) in
+				c.cl_kind <- KTypeParameter(after)
+			| _ -> ())
+		| _ -> ()) ctor_types;
 		let me = alloc_var "__hx_this" (TInst(cl, List.map snd ctor_types)) in
 		me.v_capture <- true;
 

+ 3 - 5
tests/unit/src/unit/issues/Issue2086.hx

@@ -1,7 +1,7 @@
 package unit.issues;
 
-#if !java
 @:generic
+@:keep
 private class Node<T:Node<T>> extends Foo<T> {
 	public var node:T;
 	public function new(node:T) {
@@ -17,6 +17,7 @@ private class Node<T:Node<T>> extends Foo<T> {
 }
 
 @:generic
+@:keep
 private class Foo<T> {
 	public var s:String = "";
 	public function new() { }
@@ -25,6 +26,7 @@ private class Foo<T> {
 	}
 }
 
+@:keep
 private class StringNode extends Node<StringNode> {
 	public function new(s:String) {
 		super(this);
@@ -35,13 +37,9 @@ private class StringNode extends Node<StringNode> {
 	}
 }
 
-#end
-
 class Issue2086 extends Test {
 	function test() {
-		#if !java
 		var sNode = new StringNode("foo");
 		eq("StringNode_funcNode_funcFoo_super_func", sNode.s);
-		#end
 	}
 }