Преглед на файлове

Do not type the abstract implementation directly. Rather, type the ab… (#5193)

* Do not type the abstract implementation directly. Rather, type the abstract itself

Closes #5192

* Fix macro problem with the issues directory and Issue5192_Test module
Cauê Waneck преди 9 години
родител
ревизия
09ceabfbcf
променени са 3 файла, в които са добавени 25 реда и са изтрити 1 реда
  1. 6 1
      src/typing/typer.ml
  2. 9 0
      tests/unit/src/unit/issues/Issue5192.hx
  3. 10 0
      tests/unit/src/unit/issues/Issue5192_Test.hx

+ 6 - 1
src/typing/typer.ml

@@ -1896,7 +1896,12 @@ let unify_int ctx e k =
 			cf2.cf_meta <- (Meta.NoCompletion,[],p) :: (Meta.NoUsing,[],p) :: (Meta.GenericInstance,[],p) :: metadata;
 			cf2
 		in
-		let e = if stat then type_type ctx c.cl_path p else e in
+		let path = match c.cl_kind with
+			| KAbstractImpl(a) ->
+				a.a_path
+			| _ -> c.cl_path
+		in
+		let e = if stat then type_type ctx path p else e in
 		let fa = if stat then FStatic (c,cf2) else FInstance (c,tl,cf2) in
 		let e = mk (TField(e,fa)) cf2.cf_type p in
 		make_call ctx e el ret p

+ 9 - 0
tests/unit/src/unit/issues/Issue5192.hx

@@ -0,0 +1,9 @@
+package unit.issues;
+import unit.issues.Issue5192_Test;
+
+class Issue5192 extends Test {
+	public function test() {
+		var x:String = Issue5192_Test_Abstract.doSomething();
+		eq(x,null);
+	}
+}

+ 10 - 0
tests/unit/src/unit/issues/Issue5192_Test.hx

@@ -0,0 +1,10 @@
+package unit.issues;
+
+class Issue5192_Test extends Test {
+}
+
+abstract Issue5192_Test_Abstract(Int) {
+  @:generic public static function doSomething<T>():T {
+    return cast null;
+  }
+}