@@ -192,26 +192,33 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
192192 }
193193 }
194194
195- homogenize (tp) match {
195+ def appliedText (tp : Type ) : Text = tp match
196196 case tp @ AppliedType (tycon, args) =>
197197 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
202202 val l :: r :: Nil = args
203203 val opName = tyconName(tycon)
204204 toTextInfixType(tyconName(tycon), l, r) { simpleNameString(tycon.typeSymbol) }
205- }
206- else super .toText(tp)
205+ else Str (" " )
206+ case _ =>
207+ Str (" " )
207208
209+ homogenize(tp) match {
210+ case tp : AppliedType =>
211+ val refined = appliedText(tp)
212+ if refined.isEmpty then super .toText(tp) else refined
208213 // Since RefinedPrinter, unlike PlainPrinter, can output right-associative type-operators, we must override handling
209214 // of AndType and OrType to account for associativity
210215 case AndType (tp1, tp2) =>
211216 toTextInfixType(tpnme.raw.AMP , tp1, tp2) { toText(tpnme.raw.AMP ) }
212217 case OrType (tp1, tp2) =>
213218 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
215222 toText(tycon)
216223 case tp : RefinedType if defn.isFunctionType(tp) && ! printDebug =>
217224 toTextDependentFunction(tp.refinedInfo.asInstanceOf [MethodType ])
0 commit comments