Skip to content

Commit a37d233

Browse files
Merge pull request #2338 from dotty-staging/workaround-#2335
Workaround #2335 issue in bootstraped REPL
2 parents 4897be1 + 3c26292 commit a37d233

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

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

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

2130
def unapply(ti: TermAction): Option[(LazyList[Int], Vector[Char], Int, Ansi.Str)] =
2231
ti match {
23-
case ts: TermState => TermState.unapply(ts)
32+
case ts: TermState => TermState.unapplyWorkaround(ts)
2433
case _ => None
2534
}
2635
}

0 commit comments

Comments
 (0)