Consider the following program:
trait Foo { self =>
val bar: Bar
// Note that the type refinement (in the result) uses `self.bar.type`
def unapply(other: Foo): Option[Foo { val bar: self.bar.type }] = ???
}
trait Bar
class Usage(foo1: Foo, foo2: Foo) {
foo1 match {
case foo2(_) => ()
}
}
It produces the following error:
[error] an unapply result must have a member `def isEmpty: Boolean
[error] case foo2(_) => ()
[error] ^
[error] one error found
If I use other.bar.type instead of self.bar.type, the code compiles, though.