瀏覽代碼

disallow invalid @:coreType abstract variance (see #2844)

Simon Krajewski 11 年之前
父節點
當前提交
6c22897f89
共有 4 個文件被更改,包括 14 次插入1 次删除
  1. 0 0
      tests/unit/issues/Issue2718.hx.disabled
  2. 11 0
      tests/unit/issues/Issue2844.hx
  3. 2 0
      tests/unit/unit.hxproj
  4. 1 1
      type.ml

+ 0 - 0
tests/unit/issues/Issue2718.hx → tests/unit/issues/Issue2718.hx.disabled


+ 11 - 0
tests/unit/issues/Issue2844.hx

@@ -0,0 +1,11 @@
+package unit.issues;
+import unit.Test;
+
+class Issue2844 extends Test {
+	function test() {
+		t(unit.TestType.typeError({
+			var a:Array<Int> = [];
+			var b:Array<Float> = a;
+		}));
+	}
+}

+ 2 - 0
tests/unit/unit.hxproj

@@ -21,6 +21,7 @@
   <build>
   <build>
     <option directives="" />
     <option directives="" />
     <option flashStrict="False" />
     <option flashStrict="False" />
+    <option noInlineOnDebug="False" />
     <option mainClass="unit.Test" />
     <option mainClass="unit.Test" />
     <option enabledebug="False" />
     <option enabledebug="False" />
     <option additional="" />
     <option additional="" />
@@ -58,6 +59,7 @@
     <hidden path="runexe.n" />
     <hidden path="runexe.n" />
     <hidden path="runjava.n" />
     <hidden path="runjava.n" />
     <hidden path="server.bat" />
     <hidden path="server.bat" />
+    <hidden path="obj" />
   </hiddenPaths>
   </hiddenPaths>
   <!-- Executed before build -->
   <!-- Executed before build -->
   <preBuildCommand>"$(CompilerPath)/haxe" compile.hxml</preBuildCommand>
   <preBuildCommand>"$(CompilerPath)/haxe" compile.hxml</preBuildCommand>

+ 1 - 1
type.ml

@@ -1254,7 +1254,7 @@ and unify_with_variance t1 t2 =
 	| TAbstract(a1,pl1),TAbstract(a2,pl2) ->
 	| TAbstract(a1,pl1),TAbstract(a2,pl2) ->
 		let ta1 = apply_params a1.a_types pl1 a1.a_this in
 		let ta1 = apply_params a1.a_types pl1 a1.a_this in
 		let ta2 = apply_params a2.a_types pl2 a2.a_this in
 		let ta2 = apply_params a2.a_types pl2 a2.a_this in
-		if not (Meta.has Meta.CoreType a1.a_meta) && not (Meta.has Meta.CoreType a2.a_meta) then
+		if (Meta.has Meta.CoreType a1.a_meta) && (Meta.has Meta.CoreType a2.a_meta) then
 			type_eq EqStrict ta1 ta2;
 			type_eq EqStrict ta1 ta2;
 		if not (List.exists (allows_variance_to ta2) a1.a_to) && not (List.exists (allows_variance_to ta1) a2.a_from) then
 		if not (List.exists (allows_variance_to ta2) a1.a_to) && not (List.exists (allows_variance_to ta1) a2.a_from) then
 			error [cannot_unify t1 t2]
 			error [cannot_unify t1 t2]