浏览代码

consider to and from when assigning to and from `Dynamic<T>` (closes #3461)

Simon Krajewski 11 年之前
父节点
当前提交
4e4693249c
共有 2 个文件被更改,包括 16 次插入0 次删除
  1. 12 0
      tests/unit/issues/Issue3461.hx
  2. 4 0
      type.ml

+ 12 - 0
tests/unit/issues/Issue3461.hx

@@ -0,0 +1,12 @@
+package unit.issues;
+
+private abstract E<T1>(Dynamic) from T1 to T1 {}
+
+class Issue3461 extends Test {
+	function test() {
+        var a:E<Dynamic<String>> = { value: "foo" };
+        var b:Dynamic<String> = a;
+		a = b;
+		eq("foo", b.value);
+	}
+}

+ 4 - 0
type.ml

@@ -1414,6 +1414,8 @@ let rec unify a b =
 					type_eq EqRightDynamic t t2
 				with
 					Unify_error l -> error (cannot_unify a b :: l));
+		| TAbstract(bb,tl) when (List.exists (unify_from bb tl a b) bb.a_from) ->
+			()
 		| _ ->
 			error [cannot_unify a b])
 	| _ , TDynamic t ->
@@ -1440,6 +1442,8 @@ let rec unify a b =
 				) an.a_fields
 			with Unify_error l ->
 				error (cannot_unify a b :: l))
+		| TAbstract(aa,tl) when (List.exists (unify_to aa tl b) aa.a_to) ->
+			()
 		| _ ->
 			error [cannot_unify a b])
 	| TAbstract (aa,tl), _  ->