aboutsummaryrefslogblamecommitdiff
path: root/tests/neg/patmat.scala
blob: 1e72c104aee4a63ed0a9df43748b9052be006331 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                    
                                             








                                                              
trait A
trait B
class C extends A with B
case class D()
object X {
  def unapply(x: B): Boolean = false
}

object Test {
  def main(args: Array[String]) = {
    val ca: A = new C
    ca match {
      case x: B =>
      case X() =>
      case D() => // ok, but scalac disagrees
    }
    val cc = new C
    cc match {
      case x: B =>
      case X() =>
      case D() =>  // error: neither a subtype not a supertype
    }
  }
}