Closed
Description
The following snippet is correctly rejected by the compiler, but the error message is confusing:
object Bar {
trait A
case class A0(foo: Int) extends A
}
object Foo {
import Bar.A
def buzz(a: A) = {
a match {
case A0(_) =>
}
}
}
-- Error: Foo.scala:11:11 ------------------------------------------------------
11 | case A0(_) =>
| ^^
|A0 cannot be used as an extractor in a pattern because it lacks an unapply or unapplySeq method
one error found
A0 defines an unapply
method, so the error message is wrong. The actual problem is that A0 is simply not in scope.
The error message that I would expect is:
-- Error: Foo.scala:11:11 ------------------------------------------------------
11 | case A0(_) =>
| ^^
| not found: A0