Skip to content

Commit f16b77a

Browse files
committed
Fix infinite recursion with -Yplain-printer
Trying to print the type of `List(1,2)` in the repl launched with `-Yplain-printer` previously resulted in an infinite recursion (stopped by PlainPrinter#controlled) because `refinementChain(tp)` will return a list of only one argument for a RefinedType which is also an AppliedType.
1 parent dc8c5c3 commit f16b77a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
142142
toTextLocal(tp.underlying) ~ "(" ~ toTextRef(tp) ~ ")"
143143
case tp: TypeRef =>
144144
toTextPrefix(tp.prefix) ~ selectionString(tp)
145+
case AppliedType(tycon, args) =>
146+
(toTextLocal(tycon) ~ "[" ~ Text(args map argText, ", ") ~ "]").close
145147
case tp: RefinedType =>
146148
val parent :: (refined: List[RefinedType @unchecked]) =
147149
refinementChain(tp).reverse

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
155155
if (defn.isFunctionClass(cls)) return toTextFunction(args, cls.name.isImplicitFunction)
156156
if (defn.isTupleClass(cls)) return toTextTuple(args)
157157
if (isInfixType(tp)) return toTextInfixType(tycon, args)
158-
return (toTextLocal(tycon) ~ "[" ~ Text(args map argText, ", ") ~ "]").close
159158
case EtaExpansion(tycon) =>
160159
return toText(tycon)
161160
case tp: TypeRef =>

0 commit comments

Comments
 (0)