浏览代码

[java] Do not implement / extend erased interfaces and classes. Closes #2828

Cauê Waneck 11 年之前
父节点
当前提交
e4eab21112
共有 2 个文件被更改,包括 15 次插入3 次删除
  1. 7 1
      genjava.ml
  2. 8 2
      tests/unit/issues/Issue2828.hx

+ 7 - 1
genjava.ml

@@ -1624,7 +1624,13 @@ let configure gen =
     print w "%s %s %s %s" access (String.concat " " modifiers) clt (change_clname (snd cl.cl_path));
     (* type parameters *)
     let params, _ = get_string_params cl.cl_types in
-    let cl_p_to_string (c,p) = path_param_s cl.cl_pos (TClassDecl c) c.cl_path p in
+    let cl_p_to_string (c,p) =
+      let p = List.map (fun t -> match follow t with
+        | TMono _ | TDynamic _ -> t_empty
+        | _ -> t) p
+      in
+      path_param_s cl.cl_pos (TClassDecl c) c.cl_path p
+    in
     print w "%s" params;
     (if is_some cl.cl_super then print w " extends %s" (cl_p_to_string (get cl.cl_super)));
     (match cl.cl_implements with

+ 8 - 2
tests/unit/issues/Issue2828.hx

@@ -4,15 +4,16 @@ class Issue2828 extends unit.Test
 {
 	public function test()
 	{
-		var u = new U1();
+		var u:T1<Dynamic> = new U1();
 		u.foo(1,1);
-		t(u.didCall);
+		t(u.call());
 	}
 }
 
 private interface T1<X>
 {
   public function foo <A>(a:X, c:A):Void;
+	public function call():Bool;
 }
 
 private class U1 implements T1<Dynamic>
@@ -20,6 +21,11 @@ private class U1 implements T1<Dynamic>
   public function new () {}
 	public var didCall:Bool = false;
 
+	public function call()
+	{
+		return didCall;
+	}
+
   public function foo <A>(a:Dynamic, c:A):Void
 	{
 		didCall = true;