The scala compiler should generate warnings for if statements, which I commented below, but this is not the case. Why?
sealed trait T object A extends T val s:Seq[T] = Seq(A) val result = s.map { //This if should produce a compiler warning case a if(a == "A") => "First" case a => //This if should produce a compiler warning if (a == "A") { "Second" } else { "Third" } }
The result will be "Third", as you would expect, but the compiler should have generated a warning on case a if(a == "A") and on if (a == "A") , but, alas, there is no warning.
If I write the following code, it will behave as I would expect:
if(A == "A"){ println("can't happen") }
Why is this happening?
Edit: I am using scala 2.10.1.
source share