summaryrefslogtreecommitdiff
path: root/test/pending/run/bugs425-and-816.scala
blob: 4e841ccc316c9b996962354b26d408dff168d2d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
object Test {
  object bug816 {
    abstract class Atest(val data: String)
    case class Btest(override val data: String, val b: Boolean) extends Atest(data)
    case class Ctest(override val data: String) extends Btest(data, true)

    class testCaseClass {
      def test(x: Atest) = x match {
        case Ctest(data)    => "C"
        case Btest(data, b) => "B"
      }
    }
    def go() = {
      val tcc = new testCaseClass()

      tcc.test(Ctest("foo")) + tcc.test(Btest("bar", true))
    }
  }

  object bug425 {
    case class A(x: Int)
    case class B(override val x: Int, y: Double) extends A(x)

    val b: A = B(5, 3.3)
    def flail = b match {
      case B(x, y)  => "B"
      case A(x)     => "A"
    }
    def flail2 = (B(10, 5.5): Any) match {
      case A(20)      => "1"
      case A(10)      => "2"
      case _          => "fail"
    }
    def go() = flail + flail2
  }

  def main(args: Array[String]): Unit = {
    assert(bug816.go() == "CB")
    assert(bug425.go() == "B2")
  }
}