Browse Source

[typer] bring back no-mono check when unifying to-fields

closes #10565
Simon Krajewski 3 years ago
parent
commit
1be7f04892
2 changed files with 15 additions and 0 deletions
  1. 1 0
      src/core/tUnification.ml
  2. 14 0
      tests/unit/src/unit/issues/Issue10565.hx

+ 1 - 0
src/core/tUnification.ml

@@ -1012,6 +1012,7 @@ and unifies_to_field uctx a b ab tl (t,cf) =
 			let unify_func = get_abstract_unify_func uctx EqStrict in
 			let athis = map ab.a_this in
 			(* we cannot allow implicit casts when the this type is not completely known yet *)
+			if has_mono athis then raise (Unify_error []);
 			with_variance uctx (type_eq {uctx with equality_kind = EqStrict}) athis (map ta);
 			unify_func (map t) b;
 		| _ -> die "" __LOC__)

+ 14 - 0
tests/unit/src/unit/issues/Issue10565.hx

@@ -0,0 +1,14 @@
+package unit.issues;
+
+private abstract MapProxy<K, V>(Dynamic) {
+	@:from static function fromMap<K, V>(map:Map<K, V>):MapProxy<K, V> {
+		return null;
+	}
+}
+
+class Issue10565 extends Test {
+	function test() {
+		var m:MapProxy<String, Int> = new Map();
+		utest.Assert.pass();
+	}
+}