Closed
Description
Here's an interesting problem minmized from https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/repl/ammonite/Protocol.scala that causes dotty-compiler-bootstrapped/repl
to go into an infinite loop:
class Foo
case class Bar(x: Int) extends Foo
object Bar {
def unapply(foo: Foo): Option[Int] = foo match {
case foo: Bar =>
unapply(foo)
}
}
With scalac
, the unapply call goes to the generated def unapply(x$1: Bar): Option[Int]
, but with dotty no such method exist, instead we only generate a def unapply(x$1: Bar): Bar
, so the previously perfectly correct code becomes an infinite loop!
I think we can fix this by always generating an unapply method that returns an Option
, even if we don't use it.