@@ -158,14 +158,25 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
158158 argStr ~ " " ~ arrow(isGiven) ~ " " ~ argText(args.last)
159159 }
160160
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)
169180
170181 def isInfixType (tp : Type ): Boolean = tp match
171182 case AppliedType (tycon, args) =>
@@ -229,8 +240,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
229240 if ! printDebug && appliedText(tp.asInstanceOf [HKLambda ].resType).isEmpty =>
230241 // don't eta contract if the application would be printed specially
231242 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)
234247 case tp : TypeRef =>
235248 if (tp.symbol.isAnonymousClass && ! showUniqueIds)
236249 toText(tp.info)
@@ -244,6 +257,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
244257 case ErasedValueType (tycon, underlying) =>
245258 " ErasedValueType(" ~ toText(tycon) ~ " , " ~ toText(underlying) ~ " )"
246259 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 _ =>
247264 toTextParents(tp.parents) ~~ " {...}"
248265 case JavaArrayType (elemtp) =>
249266 toText(elemtp) ~ " []"
0 commit comments