aboutsummaryrefslogtreecommitdiff
path: root/tests/run/1938-2.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/1938-2.scala')
-rw-r--r--tests/run/1938-2.scala37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/run/1938-2.scala b/tests/run/1938-2.scala
new file mode 100644
index 000000000..32e4c4518
--- /dev/null
+++ b/tests/run/1938-2.scala
@@ -0,0 +1,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 _ => ()
+ }
+ }
+}