Skip to content

Commit cd13ce1

Browse files
committed
Rename argText to globalPrecArgText
This function is doing two things at once, and we don't always want them together, hence the more complex name.
1 parent e85a91e commit cd13ce1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
101101
protected def toTextRefinement(rt: RefinedType) =
102102
(refinementNameString(rt) ~ toTextRHS(rt.refinedInfo)).close
103103

104-
protected def argText(arg: Type): Text = homogenizeArg(arg) match {
104+
protected def globalPrecArgText(arg: Type): Text = homogenizeArg(arg) match {
105105
case arg: TypeBounds => "_" ~ toTextGlobal(arg)
106106
case arg => toTextGlobal(arg)
107107
}
@@ -144,7 +144,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
144144
case tp: SingletonType =>
145145
toTextLocal(tp.underlying) ~ "(" ~ toTextRef(tp) ~ ")"
146146
case AppliedType(tycon, args) =>
147-
(toTextLocal(tycon) ~ "[" ~ Text(args map argText, ", ") ~ "]").close
147+
(toTextLocal(tycon) ~ "[" ~ Text(args map globalPrecArgText, ", ") ~ "]").close
148148
case tp: RefinedType =>
149149
val parent :: (refined: List[RefinedType @unchecked]) =
150150
refinementChain(tp).reverse

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,16 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
130130

131131
override def toText(tp: Type): Text = controlled {
132132
def toTextTuple(args: List[Type]): Text =
133-
"(" ~ Text(args.map(argText), ", ") ~ ")"
133+
"(" ~ Text(args.map(globalPrecArgText), ", ") ~ ")"
134134

135135
def toTextFunction(args: List[Type], isImplicit: Boolean, isErased: Boolean): Text =
136136
changePrec(GlobalPrec) {
137137
val argStr: Text =
138138
if (args.length == 2 && !defn.isTupleType(args.head))
139-
atPrec(InfixPrec) { argText(args.head) }
139+
atPrec(InfixPrec) { globalPrecArgText(args.head) }
140140
else
141141
toTextTuple(args.init)
142-
(keywordText("erased ") provided isErased) ~ (keywordText("implicit ") provided isImplicit) ~ argStr ~ " => " ~ argText(args.last)
142+
(keywordText("erased ") provided isErased) ~ (keywordText("implicit ") provided isImplicit) ~ argStr ~ " => " ~ globalPrecArgText(args.last)
143143
}
144144

145145
def toTextDependentFunction(appType: MethodType): Text = {
@@ -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)) "(" ~ argText(l) ~ ")" else argText(l)
166-
val rightArg = if (!isRightAssoc && isInfixType(r)) "(" ~ argText(r) ~ ")" else argText(r)
165+
val leftArg = if (isRightAssoc && isInfixType(l)) "(" ~ globalPrecArgText(l) ~ ")" else globalPrecArgText(l)
166+
val rightArg = if (!isRightAssoc && isInfixType(r)) "(" ~ globalPrecArgText(r) ~ ")" else globalPrecArgText(r)
167167

168168
leftArg ~ " " ~ toTextLocal(op) ~ " " ~ rightArg
169169
}

0 commit comments

Comments
 (0)