aboutsummaryrefslogtreecommitdiff
path: root/tests/run/1938-2.scala
blob: 32e4c4518b96878ae309f5fe2c7d38969f665ebc (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
object ProdNonEmpty {
  def _1: Int = 0
  def _2: String = "???" // Slight variation with scalac: this test passes
                         // with ??? here. I think dotty behavior is fine
                         // according to the spec given that methods involved
                         // in pattern matching should be pure.
  def isEmpty = false
  def unapply(s: String): this.type = this
  def get = this
}

object ProdEmpty {
  def _1: Int = ???
  def _2: String = ???
  def isEmpty = true
  def unapply(s: String): this.type = this
  def get = this
}

object Test {
  def main(args: Array[String]): Unit = {
    "" match {
      case ProdNonEmpty(0, _) => ()
      case _ => ???
    }

    "" match {
      case ProdNonEmpty(1, _) => ???
      case _ => ()
    }

    "" match {
      case ProdEmpty(_, _) => ???
      case _ => ()
    }
  }
}