aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/patternUnsoundness.scala
blob: 4620f6c7de3e83212c6d5bea9a340bc0fd3d320d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
object patternUnsoundness extends App {

  class C[+T]

  case class D[S](_s: S) extends C[S] {
    var s: S = _s
  }

  val x = new D[String]("abc")
  val y: C[Object] = x

  y match {
    case d @ D(x) => d.s = new Integer(1)
  }

  val z: String = x.s // ClassCast exception
}