Browse Source

test for "X redefined from X" (#8368)

Aleksandr Kuzmenko 6 years ago
parent
commit
afc4ae3723

+ 11 - 0
tests/server/src/Main.hx

@@ -192,6 +192,17 @@ class ServerTests extends HaxeServerTestCase {
 		}
 		utest.Assert.equals("function() {_Vector.Vector_Impl_.toIntVector(null);}", moreHack(type.args.statics[0].expr.testHack)); // lmao
 	}
+
+	function testXRedefinedFromX() {
+		vfs.putContent("Main.hx", getTemplate("issues/Issue8368/Main.hx"));
+		vfs.putContent("MyMacro.hx", getTemplate("issues/Issue8368/MyMacro.hx"));
+		vfs.putContent("Type1.hx", getTemplate("issues/Issue8368/Type1.hx"));
+		vfs.putContent("Type2.hx", getTemplate("issues/Issue8368/Type2.hx"));
+		var args = ["-main", "Main", "--macro", "define('whatever')"];
+		runHaxe(args);
+		runHaxe(args);
+		assertSuccess();
+	}
 }
 
 class Main {

+ 5 - 0
tests/server/test/templates/issues/Issue8368/Main.hx

@@ -0,0 +1,5 @@
+class Main {
+	public static function main():Void {
+		MyMacro.foo();
+	}
+}

+ 8 - 0
tests/server/test/templates/issues/Issue8368/MyMacro.hx

@@ -0,0 +1,8 @@
+class MyMacro {
+	#if macro
+	static var issue = haxe.macro.ComplexTypeTools.toType(macro :Type1);
+	// ^ this causes the issue
+	#end
+
+	public static macro function foo() return macro { };
+}

+ 5 - 0
tests/server/test/templates/issues/Issue8368/Type1.hx

@@ -0,0 +1,5 @@
+class Type1 {
+	public function new() {
+		trace(Type2);
+	}
+}

+ 5 - 0
tests/server/test/templates/issues/Issue8368/Type2.hx

@@ -0,0 +1,5 @@
+class Type2 {
+	public function new() {
+		trace(Type1);
+	}
+}