Skip to content

Commit 9cb21f2

Browse files
Workaround #2335 issue in bootstraped REPL
1 parent 4897be1 commit 9cb21f2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

compiler/src/dotty/tools/dotc/repl/ammonite/Protocol.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ case class TermState(
1515
) extends TermAction
1616

1717
object TermState {
18+
// Using unapply instead exposes a dotty/scalac variation. Because TermState
19+
// is case class, scalac generate an unapply with this exact signature, that
20+
// is used by the TermInfo | TermAction unapplies. With dotty, the generated
21+
// unapply has type `TermState => TermState` instead, the TermState.unapply
22+
// for TermAction thus becomes a infinite tail recursion. See #2335.
23+
def unapplyWorkaround(ti: TermState): Option[(LazyList[Int], Vector[Char], Int, Ansi.Str)] =
24+
Some((ti.inputs, ti.buffer, ti.cursor, ti.msg))
25+
1826
def unapply(ti: TermInfo): Option[(LazyList[Int], Vector[Char], Int, Ansi.Str)] =
19-
TermState.unapply(ti.ts)
27+
TermState.unapplyWorkaround(ti.ts)
2028

2129
def unapply(ti: TermAction): Option[(LazyList[Int], Vector[Char], Int, Ansi.Str)] =
2230
ti match {
23-
case ts: TermState => TermState.unapply(ts)
31+
case ts: TermState => TermState.unapplyWorkaround(ts)
2432
case _ => None
2533
}
2634
}

0 commit comments

Comments
 (0)