Bläddra i källkod

[macro] fix printing of TExtend (#9580)

Dmitrii Maganov 5 år sedan
förälder
incheckning
07dda068b1
2 ändrade filer med 14 tillägg och 1 borttagningar
  1. 4 1
      std/haxe/macro/Printer.hx
  2. 10 0
      tests/unit/src/unit/issues/Issue9405.hx

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

@@ -138,7 +138,10 @@ class Printer {
 			case TParent(ct): "(" + printComplexType(ct) + ")";
 			case TOptional(ct): "?" + printComplexType(ct);
 			case TNamed(n, ct): n + ":" + printComplexType(ct);
-			case TExtend(tpl, fields): '{> ${tpl.map(printTypePath).join(" >, ")}, ${fields.map(printField).join(", ")} }';
+			case TExtend(tpl, fields):
+				var types = [for (t in tpl) "> " + printTypePath(t) + ", "].join("");
+				var fields = [for (f in fields) printField(f) + "; "].join("");
+				'{${types}${fields}}';
 			case TIntersection(tl): tl.map(printComplexType).join(" & ");
 		}
 

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

@@ -0,0 +1,10 @@
+package unit.issues;
+
+class Issue9405 extends Test {
+  function test() {
+    var ct = macro : {> Foo, > Bar, baz: Int, qux: Int};
+    var printer = new haxe.macro.Printer();
+    var s = printer.printComplexType(ct);
+    eq("{> Foo, > Bar, var baz : Int; var qux : Int; }", s);
+  }
+}