File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
src/dotty/tools/dotc/printing
test-resources/type-printer Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
135
135
def toTextFunction (args : List [Type ], isImplicit : Boolean , isErased : Boolean ): Text =
136
136
changePrec(GlobalPrec ) {
137
137
val argStr : Text =
138
- if (args.length == 2 && ! defn.isTupleType(args.head))
138
+ if (args.length == 2 && defn.isFunctionType(args.head)) {
139
+ " (" ~ globalPrecArgText(args.head) ~ " )"
140
+ } else if (args.length == 2 && ! defn.isTupleType(args.head))
139
141
atPrec(InfixPrec ) { globalPrecArgText(args.head) }
140
142
else
141
143
toTextTuple(args.init)
Original file line number Diff line number Diff line change 1
1
scala> val toInt: Any => Int = new { def apply(a: Any) = 1; override def toString() = "<func1>" }
2
2
val toInt: Any => Int = <func1>
3
+ scala> val hoFun: (Int => Int) => Int = new { def apply(a: Int => Int) = 1; override def toString() = "<func2>" }
4
+ val hoFun: (Int => Int) => Int = <func2>
5
+ scala> val curriedFun: Int => (Int => Int) = new { def apply(a: Int) = _ => 1; override def toString() = "<func3>" }
6
+ val curriedFun: Int => Int => Int = <func3>
7
+ scala> val tupFun: ((Int, Int)) => Int = new { def apply(a: (Int, Int)) = 1; override def toString() = "<func4>" }
8
+ val tupFun: ((Int, Int)) => Int = <func4>
9
+ scala> val binFun: (Int, Int) => Int = new { def apply(a: Int, b: Int) = 1; override def toString() = "<func5>" }
10
+ val binFun: (Int, Int) => Int = <func5>
You can’t perform that action at this time.
0 commit comments