Skip to content

Workaround #2335 issue in bootstraped REPL #2338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions compiler/src/dotty/tools/dotc/repl/ammonite/Protocol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ case class TermState(
) extends TermAction

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

def unapply(ti: TermInfo): Option[(LazyList[Int], Vector[Char], Int, Ansi.Str)] =
TermState.unapply(ti.ts)
TermState.unapplyWorkaround(ti.ts)

def unapply(ti: TermAction): Option[(LazyList[Int], Vector[Char], Int, Ansi.Str)] =
ti match {
case ts: TermState => TermState.unapply(ts)
case ts: TermState => TermState.unapplyWorkaround(ts)
case _ => None
}
}
Expand Down