Bläddra i källkod

Allow typer to be resumed when typing underlying abstract types. Closes #5231 (#5232)

Cauê Waneck 9 år sedan
förälder
incheckning
8a83a3026f
2 ändrade filer med 31 tillägg och 3 borttagningar
  1. 6 3
      src/typing/typer.ml
  2. 25 0
      tests/unit/src/unit/issues/Issue5231.hx

+ 6 - 3
src/typing/typer.ml

@@ -1663,9 +1663,12 @@ and type_field ?(resume=false) ctx e i p mode =
 				AKUsing (ef,c,f,e)
 			| MSet, _ ->
 				error "This operation is unsupported" p)
-		with Not_found when does_forward a false ->
-			type_field ctx {e with etype = apply_params a.a_params pl a.a_this} i p mode;
-		| Not_found -> try
+		with Not_found -> try
+			if does_forward a false then
+				type_field ~resume:true ctx {e with etype = apply_params a.a_params pl a.a_this} i p mode
+			else
+				raise Not_found
+		with Not_found -> try
 			using_field ctx mode e i p
 		with Not_found -> try
 			(match ctx.curfun, e.eexpr with

+ 25 - 0
tests/unit/src/unit/issues/Issue5231.hx

@@ -0,0 +1,25 @@
+package unit.issues;
+using unit.issues.Issue5231;
+
+class Issue5231 extends Test {
+  public function test() {
+    t(getTest().doesItWork(getTest()));
+  }
+
+  public static function getTest():Test1 {
+    return cast {};
+  }
+}
+
+private abstract Test2(Dynamic) {
+}
+
+@:forward
+private abstract Test1(Test2) {
+}
+
+class I5231_Using {
+  public static function doesItWork(t:Test1, t2:Test1):Bool {
+    return true;
+  }
+}