I get the following match warning.
"match may not be exhaustive. It would fail on the following input: Some((x: Abstract forSome x not in (A, B, C)))"
code:
abstract class Abstract
case class A() extends Abstract
case class B() extends Abstract
case class C() extends Abstract
class matcher {
def matcher(a: Option[Abstract]) = a match {
case None => true
case Some(A()) => false
case Some(B()) => false
case Some(C()) => false
}
}
In case you wonder, the case classes here have no arguments but in my real code they do. I hope the answer is not "the compiler can't know whether or not there are additional subclassess of Abstract
somewhere in the program...
Is making the abstract class sealed the only solution? scala is not a very dynamic language, so how come the compiler doesn't know that the group mentioned in the compilation warning is an empty group?