@@ -155,15 +155,15 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
155
155
case _ => false
156
156
}
157
157
158
- def toTextInfixType (op : Type , args : List [Type ]): Text = {
158
+ def toTextInfixType (op : Type , args : List [Type ]): Text = changePrec( InfixPrec ) {
159
159
/* SLS 3.2.8: all infix types have the same precedence.
160
160
* In A op B op' C, op and op' need the same associativity.
161
161
* Therefore, if op is left associative, anything on its right
162
162
* needs to be parenthesized if it's an infix type, and vice versa. */
163
163
val l :: r :: Nil = args
164
164
val isRightAssoc = op.typeSymbol.name.endsWith(" :" )
165
- val leftArg = if (isRightAssoc && isInfixType(l)) changePrec( GlobalPrec ) { argText(l) } else argText(l)
166
- val rightArg = if (! isRightAssoc && isInfixType(r)) changePrec( GlobalPrec ) { argText(r) } else argText(r)
165
+ val leftArg = if (isRightAssoc && isInfixType(l)) atPrec( OrPrec ) { argText(l) } else argText(l)
166
+ val rightArg = if (! isRightAssoc && isInfixType(r)) atPrec( OrPrec ) { argText(r) } else argText(r)
167
167
168
168
leftArg ~ " " ~ toTextLocal(op) ~ " " ~ rightArg
169
169
}
@@ -174,7 +174,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
174
174
if (tycon.isRepeatedParam) return toTextLocal(args.head) ~ " *"
175
175
if (defn.isFunctionClass(cls)) return toTextFunction(args, cls.name.isImplicitFunction, cls.name.isErasedFunction)
176
176
if (defn.isTupleClass(cls)) return toTextTuple(args)
177
- if (isInfixType(tp)) return atPrec( InfixPrec ) { toTextInfixType(tycon, args) }
177
+ if (isInfixType(tp)) return toTextInfixType(tycon, args)
178
178
case EtaExpansion (tycon) =>
179
179
return toText(tycon)
180
180
case tp : RefinedType if defn.isFunctionType(tp) =>
0 commit comments