The following Scala code compiles fine:
val f = (input: String) => Some("result")
object Extract {
def unapply(input: String): Option[String] = f(input)
}
val Extract(result) = "a string"
But if I replace the extractor by:
object Extract {
def unapply = f
}
Then compilation fails with:
error: an unapply result must have a member `def isEmpty: Boolean
val Extract(result) = "a string"
^
Why? Where does def isEmpty: Boolean
come from?