@@ -158,14 +158,25 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
158
158
argStr ~ " " ~ arrow(isGiven) ~ " " ~ argText(args.last)
159
159
}
160
160
161
- def toTextDependentFunction (appType : MethodType ): Text =
162
- " ("
163
- ~ keywordText(" erased " ).provided(appType.isErasedMethod)
164
- ~ paramsText(appType)
165
- ~ " ) "
166
- ~ arrow(appType.isImplicitMethod)
167
- ~ " "
168
- ~ toText(appType.resultType)
161
+ def toTextMethodAsFunction (info : Type ): Text = info match
162
+ case info : MethodType =>
163
+ " ("
164
+ ~ keywordText(" erased " ).provided(info.isErasedMethod)
165
+ ~ ( if info.isParamDependent || info.isResultDependent
166
+ then paramsText(info)
167
+ else argsText(info.paramInfos)
168
+ )
169
+ ~ " ) "
170
+ ~ arrow(info.isImplicitMethod)
171
+ ~ " "
172
+ ~ toTextMethodAsFunction(info.resultType)
173
+ case info : PolyType =>
174
+ " ["
175
+ ~ paramsText(info)
176
+ ~ " ] => "
177
+ ~ toTextMethodAsFunction(info.resultType)
178
+ case _ =>
179
+ toText(info)
169
180
170
181
def isInfixType (tp : Type ): Boolean = tp match
171
182
case AppliedType (tycon, args) =>
@@ -229,8 +240,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
229
240
if ! printDebug && appliedText(tp.asInstanceOf [HKLambda ].resType).isEmpty =>
230
241
// don't eta contract if the application would be printed specially
231
242
toText(tycon)
232
- case tp : RefinedType if defn.isFunctionType(tp) && ! printDebug =>
233
- toTextDependentFunction(tp.refinedInfo.asInstanceOf [MethodType ])
243
+ case tp : RefinedType
244
+ if (defn.isFunctionType(tp) || (tp.parent.typeSymbol eq defn.PolyFunctionClass ))
245
+ && ! printDebug =>
246
+ toTextMethodAsFunction(tp.refinedInfo)
234
247
case tp : TypeRef =>
235
248
if (tp.symbol.isAnonymousClass && ! showUniqueIds)
236
249
toText(tp.info)
@@ -244,6 +257,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
244
257
case ErasedValueType (tycon, underlying) =>
245
258
" ErasedValueType(" ~ toText(tycon) ~ " , " ~ toText(underlying) ~ " )"
246
259
case tp : ClassInfo =>
260
+ if tp.cls.derivesFrom(defn.PolyFunctionClass ) then
261
+ tp.member(nme.apply).info match
262
+ case info : PolyType => return toTextMethodAsFunction(info)
263
+ case _ =>
247
264
toTextParents(tp.parents) ~~ " {...}"
248
265
case JavaArrayType (elemtp) =>
249
266
toText(elemtp) ~ " []"
0 commit comments