Skip to content

Commit 891eb23

Browse files
committed
Reduce use of globalPrecArgText
This change is still hacky, and this shows because I can't drop the inner checks for isInfixType.
1 parent 3817733 commit 891eb23

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
162162
* needs to be parenthesized if it's an infix type, and vice versa. */
163163
val l :: r :: Nil = args
164164
val isRightAssoc = op.typeSymbol.name.endsWith(":")
165-
val leftArg = if (isRightAssoc && isInfixType(l)) "(" ~ globalPrecArgText(l) ~ ")" else globalPrecArgText(l)
166-
val rightArg = if (!isRightAssoc && isInfixType(r)) "(" ~ globalPrecArgText(r) ~ ")" else globalPrecArgText(r)
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)
167167

168168
leftArg ~ " " ~ toTextLocal(op) ~ " " ~ rightArg
169169
}
@@ -174,7 +174,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
174174
if (tycon.isRepeatedParam) return toTextLocal(args.head) ~ "*"
175175
if (defn.isFunctionClass(cls)) return toTextFunction(args, cls.name.isImplicitFunction, cls.name.isErasedFunction)
176176
if (defn.isTupleClass(cls)) return toTextTuple(args)
177-
if (isInfixType(tp)) return toTextInfixType(tycon, args)
177+
if (isInfixType(tp)) return atPrec(InfixPrec) { toTextInfixType(tycon, args) }
178178
case EtaExpansion(tycon) =>
179179
return toText(tycon)
180180
case tp: RefinedType if defn.isFunctionType(tp) =>

0 commit comments

Comments
 (0)