Browse Source

Follow abstract underlying type when unifying with structure declaration (see #2933)

Dan Korostelev 11 years ago
parent
commit
48b56ee03a
2 changed files with 12 additions and 1 deletions
  1. 11 0
      tests/unit/issues/Issue2933.hx
  2. 1 1
      typer.ml

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

@@ -8,10 +8,21 @@ private abstract B({a:A}) from {a:A} {
 	}
 	}
 }
 }
 
 
+private typedef T = {a:A};
+
+private abstract C(T) from T {
+	public function getA() {
+		return this.a;
+	}
+}
+
 class Issue2933 extends Test {
 class Issue2933 extends Test {
 	function test() {
 	function test() {
 		var a:A = 1;
 		var a:A = 1;
 		var b:B = {a: 1};
 		var b:B = {a: 1};
 		eq(1, b.getA());
 		eq(1, b.getA());
+
+		var c:C = {a: 1};
+		eq(1, c.getA());
 	}
 	}
 }
 }

+ 1 - 1
typer.ml

@@ -2543,7 +2543,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
 			(match follow t with
 			(match follow t with
 			| TAnon a when not (PMap.is_empty a.a_fields) -> Some a
 			| TAnon a when not (PMap.is_empty a.a_fields) -> Some a
 			| TAbstract (a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
 			| TAbstract (a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
-				begin match Codegen.Abstract.get_underlying_type a tl with
+				begin match follow (Codegen.Abstract.get_underlying_type a tl) with
 					| TAnon a -> Some a
 					| TAnon a -> Some a
 					| _ -> None
 					| _ -> None
 				end
 				end