@@ -192,26 +192,33 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
192
192
}
193
193
}
194
194
195
- homogenize (tp) match {
195
+ def appliedText (tp : Type ) : Text = tp match
196
196
case tp @ AppliedType (tycon, args) =>
197
197
val cls = tycon.typeSymbol
198
- if ( tycon.isRepeatedParam) toTextLocal(args.head) ~ " *"
199
- else if ( defn.isFunctionClass(cls)) toTextFunction(args, cls.name.isContextFunction, cls.name.isErasedFunction)
200
- else if ( tp.tupleArity >= 2 && ! printDebug) toTextTuple(tp.tupleElementTypes)
201
- else if ( isInfixType(tp)) {
198
+ if tycon.isRepeatedParam then toTextLocal(args.head) ~ " *"
199
+ else if defn.isFunctionClass(cls) then toTextFunction(args, cls.name.isContextFunction, cls.name.isErasedFunction)
200
+ else if tp.tupleArity >= 2 && ! printDebug then toTextTuple(tp.tupleElementTypes)
201
+ else if isInfixType(tp) then
202
202
val l :: r :: Nil = args
203
203
val opName = tyconName(tycon)
204
204
toTextInfixType(tyconName(tycon), l, r) { simpleNameString(tycon.typeSymbol) }
205
- }
206
- else super .toText(tp)
205
+ else Str (" " )
206
+ case _ =>
207
+ Str (" " )
207
208
209
+ homogenize(tp) match {
210
+ case tp : AppliedType =>
211
+ val refined = appliedText(tp)
212
+ if refined.isEmpty then super .toText(tp) else refined
208
213
// Since RefinedPrinter, unlike PlainPrinter, can output right-associative type-operators, we must override handling
209
214
// of AndType and OrType to account for associativity
210
215
case AndType (tp1, tp2) =>
211
216
toTextInfixType(tpnme.raw.AMP , tp1, tp2) { toText(tpnme.raw.AMP ) }
212
217
case OrType (tp1, tp2) =>
213
218
toTextInfixType(tpnme.raw.BAR , tp1, tp2) { toText(tpnme.raw.BAR ) }
214
- case EtaExpansion (tycon) if ! printDebug =>
219
+ case tp @ EtaExpansion (tycon)
220
+ if ! printDebug && appliedText(tp.asInstanceOf [HKLambda ].resType).isEmpty =>
221
+ // don't eta contract if the application would be printed specially
215
222
toText(tycon)
216
223
case tp : RefinedType if defn.isFunctionType(tp) && ! printDebug =>
217
224
toTextDependentFunction(tp.refinedInfo.asInstanceOf [MethodType ])
0 commit comments