2
0
Эх сурвалжийг харах

follow type on resolving @:using field access #8928

Aleksandr Kuzmenko 5 жил өмнө
parent
commit
91dc4be111

+ 1 - 1
src/typing/fields.ml

@@ -337,7 +337,7 @@ let rec using_field ctx mode e i p =
 		loop ctx.m.module_using
 	with Not_found -> try
 		(* type using from `@:using(Path)` *)
-		let mt = module_type_of_type e.etype in
+		let mt = module_type_of_type (follow e.etype) in
 		loop (t_infos mt).mt_using
 	with Not_found | Exit -> try
 		(* global using *)

+ 23 - 0
tests/unit/src/unit/issues/Issue8928.hx

@@ -0,0 +1,23 @@
+package unit.issues;
+
+class Issue8928 extends Test {
+	function test() {
+		var d:Null<Direction> = Forward;
+		eq(10, d.getSpeed());
+	}
+}
+
+@:using(unit.issues.Issue8928)
+enum Direction {
+	Forward;
+	Backward;
+}
+
+class DirectionTools {
+	static public function getSpeed(dir:Null<Direction>) {
+		return switch dir {
+			case Forward | null: 10;
+			case Backward: -10;
+		}
+	}
+}