Explorar o código

updated haxe.macro.Printer to support static locals, see #10555 (#10566)

AlexHaxe %!s(int64=3) %!d(string=hai) anos
pai
achega
5b862b7fbf
Modificáronse 2 ficheiros con 3 adicións e 1 borrados
  1. 2 1
      std/haxe/macro/Printer.hx
  2. 1 0
      tests/unit/src/unit/TestMacro.hx

+ 2 - 1
std/haxe/macro/Printer.hx

@@ -250,7 +250,8 @@ class Printer {
 			case EUnop(op, false, e1): printUnop(op) + printExpr(e1);
 			case EFunction(FNamed(no,inlined), func): (inlined ? 'inline ' : '') + 'function $no' + printFunction(func);
 			case EFunction(kind, func): (kind != FArrow ? "function" : "") + printFunction(func, kind);
-			case EVars(vl): "var " + vl.map(printVar).join(", ");
+			case EVars([]): "var ";
+			case EVars(vl): ((vl[0].isStatic) ? "static " : "") + ((vl[0].isFinal) ? "final " : "var ") + vl.map(printVar).join(", ");
 			case EBlock([]): '{ }';
 			case EBlock(el):
 				var old = tabs;

+ 1 - 0
tests/unit/src/unit/TestMacro.hx

@@ -70,6 +70,7 @@ class TestMacro extends Test {
 		parseAndPrint('(a, b) -> c');
 		parseAndPrint('function(a) return b');
 		parseAndPrint('function named(a) return b');
+		parseAndPrint('function named() {\n\tstatic final @Test a = 1, b = 2;\n\tstatic var c, d;\n\tfinal e = 2;\n\tvar f;\n}');
 
 		var p = new haxe.macro.Printer();
 		// special handling of single arguments (don't add parentheses)