@@ -159,14 +159,29 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
159
159
argStr ~ " " ~ arrow(isGiven) ~ " " ~ argText(args.last)
160
160
}
161
161
162
- def toTextDependentFunction (appType : MethodType ): Text =
163
- " ("
164
- ~ keywordText(" erased " ).provided(appType.isErasedMethod)
165
- ~ paramsText(appType)
166
- ~ " ) "
167
- ~ arrow(appType.isImplicitMethod)
168
- ~ " "
169
- ~ toText(appType.resultType)
162
+ def toTextMethodAsFunction (info : Type ): Text = info match
163
+ case info : MethodType =>
164
+ changePrec(GlobalPrec ) {
165
+ " ("
166
+ ~ keywordText(" erased " ).provided(info.isErasedMethod)
167
+ ~ ( if info.isParamDependent || info.isResultDependent
168
+ then paramsText(info)
169
+ else argsText(info.paramInfos)
170
+ )
171
+ ~ " ) "
172
+ ~ arrow(info.isImplicitMethod)
173
+ ~ " "
174
+ ~ toTextMethodAsFunction(info.resultType)
175
+ }
176
+ case info : PolyType =>
177
+ changePrec(GlobalPrec ) {
178
+ " ["
179
+ ~ paramsText(info)
180
+ ~ " ] => "
181
+ ~ toTextMethodAsFunction(info.resultType)
182
+ }
183
+ case _ =>
184
+ toText(info)
170
185
171
186
def isInfixType (tp : Type ): Boolean = tp match
172
187
case AppliedType (tycon, args) =>
@@ -230,8 +245,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
230
245
if ! printDebug && appliedText(tp.asInstanceOf [HKLambda ].resType).isEmpty =>
231
246
// don't eta contract if the application would be printed specially
232
247
toText(tycon)
233
- case tp : RefinedType if defn.isFunctionType(tp) && ! printDebug =>
234
- toTextDependentFunction(tp.refinedInfo.asInstanceOf [MethodType ])
248
+ case tp : RefinedType
249
+ if (defn.isFunctionType(tp) || (tp.parent.typeSymbol eq defn.PolyFunctionClass ))
250
+ && ! printDebug =>
251
+ toTextMethodAsFunction(tp.refinedInfo)
235
252
case tp : TypeRef =>
236
253
if (tp.symbol.isAnonymousClass && ! showUniqueIds)
237
254
toText(tp.info)
@@ -245,6 +262,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
245
262
case ErasedValueType (tycon, underlying) =>
246
263
" ErasedValueType(" ~ toText(tycon) ~ " , " ~ toText(underlying) ~ " )"
247
264
case tp : ClassInfo =>
265
+ if tp.cls.derivesFrom(defn.PolyFunctionClass ) then
266
+ tp.member(nme.apply).info match
267
+ case info : PolyType => return toTextMethodAsFunction(info)
268
+ case _ =>
248
269
toTextParents(tp.parents) ~~ " {...}"
249
270
case JavaArrayType (elemtp) =>
250
271
toText(elemtp) ~ " []"
@@ -501,6 +522,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
501
522
" <derived typetree watching " ~ tpt.watched.showSummary() ~ " >"
502
523
case TypeTree () =>
503
524
typeText(toText(tree.typeOpt))
525
+ ~ Str (" (inf)" ).provided(tree.isInstanceOf [InferredTypeTree ] && printDebug)
504
526
case SingletonTypeTree (ref) =>
505
527
toTextLocal(ref) ~ " ." ~ keywordStr(" type" )
506
528
case RefinedTypeTree (tpt, refines) =>
@@ -510,6 +532,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
510
532
changePrec(OrTypePrec ) { toText(args(0 )) ~ " | " ~ atPrec(OrTypePrec + 1 ) { toText(args(1 )) } }
511
533
else if (tpt.symbol == defn.andType && args.length == 2 )
512
534
changePrec(AndTypePrec ) { toText(args(0 )) ~ " & " ~ atPrec(AndTypePrec + 1 ) { toText(args(1 )) } }
535
+ else if defn.isFunctionClass(tpt.symbol)
536
+ && tpt.isInstanceOf [TypeTree ] && tree.hasType && ! printDebug
537
+ then changePrec(GlobalPrec ) { toText(tree.typeOpt) }
513
538
else args match
514
539
case arg :: _ if arg.isTerm =>
515
540
toTextLocal(tpt) ~ " (" ~ Text (args.map(argText), " , " ) ~ " )"
0 commit comments