diff options
author | odersky <odersky@gmail.com> | 2017-04-13 11:43:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-13 11:43:37 +0200 |
commit | b8ed254e38480eb8892eccd897d525d977d9e6a7 (patch) | |
tree | 902b9c8fa209f730746ef84dc895ff2710badd24 /tests | |
parent | 46e3395693b6f8749aa0b01b41b7d643f3bef5dc (diff) | |
parent | 3e04b6f3aa4e4088220f199bd6aa5c6644c22354 (diff) | |
download | dotty-b8ed254e38480eb8892eccd897d525d977d9e6a7.tar.gz dotty-b8ed254e38480eb8892eccd897d525d977d9e6a7.tar.bz2 dotty-b8ed254e38480eb8892eccd897d525d977d9e6a7.zip |
Merge pull request #2249 from dotty-staging/revert-product
Revert <: Product requierment in pattern matching
Diffstat (limited to 'tests')
-rw-r--r-- | tests/run/1938-2.scala | 37 |
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 _ => () + } + } +} |