Intellij is too permissive in its scala for-comprehensions

Intellij allows too much in scala for-comprehensions.  It does not show errors where the scala compiler will not comple. 

Consider this tests class:

import org.scalatest.FunSuite

class ComprehensionTest extends FunSuite {

test("Option of Seq comprehension") {
val os = Option(Seq(1,2,3))
val ints: Iterable[Int] = for {
s <- os
i <- s
} yield {
i * i

Intellij shows no errors, but it really should.  You can't do a for comprehension over an option and a sequence like that.  The compiler complains:Error:(9, 9) type mismatch;
 found   : Seq[Int]
 required: Option[?]
      i <- sMichael


Please sign in to leave a comment.