Răsfoiți Sursa

added TestOrder (need new file to avoid "using" interferences) + "using" order fix

Simon Krajewski 13 ani în urmă
părinte
comite
41dfda6f1b
6 a modificat fișierele cu 47 adăugiri și 2 ștergeri
  1. 7 0
      tests/unit/MyUsing1.hx
  2. 13 0
      tests/unit/MyUsing2.hx
  3. 1 0
      tests/unit/Test.hx
  4. 24 0
      tests/unit/TestOrder.hx
  5. 1 1
      tests/unit/TestType.hx
  6. 1 1
      typeload.ml

+ 7 - 0
tests/unit/MyUsing1.hx

@@ -0,0 +1,7 @@
+package unit;
+
+class Using1 {
+	static public function usingTest(s:String) {
+		return "1";
+	}
+}

+ 13 - 0
tests/unit/MyUsing2.hx

@@ -0,0 +1,13 @@
+package unit;
+
+class Using2 {
+	static public function usingTest(s:String) {
+		return "2";
+	}
+}
+
+class Using3 {
+	static public function usingTest(s:String) {
+		return "3";
+	}
+}

+ 1 - 0
tests/unit/Test.hx

@@ -224,6 +224,7 @@ package unit;
 			new TestSerialize(),
 			new TestMeta(),
 			new TestType(),
+			new TestOrder(),
 			#if cs
 			new TestCSharp(),
 			#end

+ 24 - 0
tests/unit/TestOrder.hx

@@ -0,0 +1,24 @@
+package unit;
+
+using unit.MyUsing1;
+using unit.MyUsing2;
+
+enum E1 {
+	C1;
+}
+
+enum E2 {
+	C1;
+}
+
+class TestOrder extends Test {
+	public function testUsing() {
+		// Latest using should be used
+		eq("foo".usingTest(), "3");
+		
+		// Latest enum should be used
+		var c:E2 = E2.C1;
+		TestType.typedAs(C1, c);
+		eq(c, C1);
+	}
+}

+ 1 - 1
tests/unit/TestType.hx

@@ -12,7 +12,7 @@ class TestType extends Test {
 		#end
 	}
 	
-	@:macro static function typedAs(actual:haxe.macro.Expr, expected:haxe.macro.Expr) {
+	@:macro static public function typedAs(actual:haxe.macro.Expr, expected:haxe.macro.Expr) {
 		var tExpected = haxe.macro.Context.typeof(expected);
 		var tActual = haxe.macro.Context.typeof(actual);
 		return haxe.macro.Context.parse("{Test.count++; eq('" +Std.string(tActual) + "', '" +Std.string(tExpected) + "');}", haxe.macro.Context.currentPos());

+ 1 - 1
typeload.ml

@@ -1626,7 +1626,7 @@ let init_module_type ctx context_init do_init (decl,p) =
 				| [] ->
 					acc
 			in
-			loop [] (List.rev types)
+			loop [] types
 		in
 		context_init := (fun() -> ctx.m.module_using <- filter_classes types @ ctx.m.module_using) :: !context_init
 	| EClass d ->