In Scala 2.11.5, compiling this
object Tryout {
trait A {
def method(a: Int): Boolean
}
abstract class B extends A {
def method(a: Int) = ???
}
new B {
override def method(a: Int) = true // type mismatch here
}
}
yields a "type mismatch: found Boolean, required Nothing" at the "true". If I replace the ???
with true or false, it compiles. It also compiles if I specify the result type of "method" in the abstract class.
This is not a big issue. However I'm curious whether anybody can explain why ???
is not inferred correctly as Boolean?
def method(a: Int): Boolean = ???
in abstract class B. – sarveshseri