فهرست منبع

run type param constraints checks in TpDefinition mode

closes #12241
Simon Krajewski 3 ماه پیش
والد
کامیت
d473f87866
2فایلهای تغییر یافته به همراه28 افزوده شده و 1 حذف شده
  1. 7 1
      src/typing/typeloadCheck.ml
  2. 21 0
      tests/unit/src/unit/issues/Issue12241.hx

+ 7 - 1
src/typing/typeloadCheck.ml

@@ -107,7 +107,13 @@ let valid_redefinition map1 map2 f1 t1 f2 t2 = (* child, parent *)
 		| ct1,ct2 ->
 			List.iter (fun t2 ->
 				let t2 = map2 t2 in
-				if not (List.exists (fun t1 -> does_unify (map1 t1) t2) ct1) then
+				if not (List.exists (fun t1 ->
+					try
+						Type.unify_custom uctx (map1 t1) t2;
+						true
+					with Unify_error _ ->
+						false
+				) ct1) then
 					raise (Unify_error ([Unify_custom (Printf.sprintf "Constraint unsatisfied for type parameter %s: %s" ttp2.ttp_name (s_type (print_context()) t2))]))
 			) ct2
 	in

+ 21 - 0
tests/unit/src/unit/issues/Issue12241.hx

@@ -0,0 +1,21 @@
+package unit.issues;
+
+private interface I {
+	function f<T, C:Array<T>>(c:C):C;
+}
+
+private class C implements I {
+	public function new() {}
+
+	public function f<T, C:Array<T>>(c:C) {
+		return c;
+	}
+}
+
+class Issue12241 extends Test {
+	function test() {
+		var c:I = new C();
+		var a = [];
+		eq(a, c.f(a));
+	}
+}