Răsfoiți Sursa

do not make nonsense monomorphs when calling abstract methods from within the abstract (closes #2979)

Simon Krajewski 11 ani în urmă
părinte
comite
ba88240dd0
2 a modificat fișierele cu 18 adăugiri și 1 ștergeri
  1. 17 0
      tests/unit/issues/Issue2979.hx
  2. 1 1
      typer.ml

+ 17 - 0
tests/unit/issues/Issue2979.hx

@@ -0,0 +1,17 @@
+package unit.issues;
+
+private class A<T> {}
+
+private abstract B<T>(T) {
+    public function toA():A<T> return null;
+    public function a() return toA();
+}
+
+class Issue2979 extends Test {
+	function test() {
+        var b:B<String> = null;
+        var a:A<String>;
+		unit.TestType.typedAs(a, b.a());
+		unit.TestType.typedAs(a, b.toA());
+	}
+}

+ 1 - 1
typer.ml

@@ -1029,7 +1029,7 @@ let field_access ctx mode f fmode t e p =
 		| (FunMemberAbstract | FunMemberAbstractLocal),TTypeExpr(TClassDecl ({cl_kind = KAbstractImpl a} as c)) when c == ctx.curclass && Meta.has Meta.Impl f.cf_meta ->
 			let e = mk (TField(e,fmode)) t p in
 			let ethis = get_this ctx p in
-			let ethis = {ethis with etype = TAbstract(a,List.map (fun _ -> mk_mono()) a.a_types)} in
+			let ethis = {ethis with etype = TAbstract(a,List.map snd a.a_types)} in
 			AKUsing(e,ctx.curclass,f,ethis)
 		| _ ->
 			(match m, mode with