Browse Source

[java/cs] Fixed bad type parameter caught from already followed tf_args/tf_type; Closes #2889

Cauê Waneck 11 years ago
parent
commit
b06b25ae9a
2 changed files with 27 additions and 2 deletions
  1. 8 2
      gencommon.ml
  2. 19 0
      tests/unit/issues/Issue2889.hx

+ 8 - 2
gencommon.ml

@@ -3043,8 +3043,14 @@ struct
 					check_params v.v_type;
 					Type.iter traverse expr
 				| TFunction(tf) ->
-					List.iter (fun (v,_) -> check_params v.v_type; Hashtbl.add ignored v.v_id v) tf.tf_args;
-					check_params tf.tf_type;
+					List.iter (fun (v,_) -> Hashtbl.add ignored v.v_id v) tf.tf_args;
+					(match follow expr.etype with
+						| TFun(args,ret) ->
+							List.iter (fun (_,_,t) ->
+								check_params t
+							) args;
+							check_params ret
+						| _ -> ());
 					Type.iter traverse expr
 				| TVar (v, opt) ->
 					(match v.v_extra with

+ 19 - 0
tests/unit/issues/Issue2889.hx

@@ -0,0 +1,19 @@
+package unit.issues;
+
+class Issue2889 extends Test {
+	public function test()
+	{
+		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);
+		var r:Array<Int> = cast r;
+		eq(r.length,1);
+		eq(2,r[0]);
+	}
+}
+
+private typedef Mappable<Y> = {
+	public function map <X>(f:Y->X):Array<X>;
+}
+