ソースを参照

Wrap function args of type function in parenthesis

Kevin Leung 9 年 前
コミット
8b19140d73
1 ファイル変更6 行追加1 行削除
  1. 6 1
      std/haxe/macro/Printer.hx

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

@@ -110,7 +110,12 @@ class Printer {
 	// TODO: check if this can cause loops
 	public function printComplexType(ct:ComplexType) return switch(ct) {
 		case TPath(tp): printTypePath(tp);
-		case TFunction(args, ret): (args.length>0 ? args.map(printComplexType).join(" -> ") : "Void") + " -> " + printComplexType(ret);
+		case TFunction(args, ret):
+			function printArg(ct) return switch ct {
+				case TFunction(_): "(" + printComplexType(ct) + ")";
+				default: printComplexType(ct);
+			};
+			(args.length>0 ? args.map(printArg).join(" -> ") :"Void") + " -> " + printComplexType(ret);
 		case TAnonymous(fields): "{ " + [for (f in fields) printField(f) + "; "].join("") + "}";
 		case TParent(ct): "(" + printComplexType(ct) + ")";
 		case TOptional(ct): "?" + printComplexType(ct);