aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/valueclasses/optmatch.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2015-04-06 18:32:38 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-05-01 13:27:42 +0200
commite5b02a88e66af0d5e9c37a881ac0237bf1d38387 (patch)
tree1e1277ca44b21d804025c17d7d7bd1f53d8c62aa /tests/pos/valueclasses/optmatch.scala
parent06e1905aed315d5199936797c9e9493326b74595 (diff)
downloaddotty-e5b02a88e66af0d5e9c37a881ac0237bf1d38387.tar.gz
dotty-e5b02a88e66af0d5e9c37a881ac0237bf1d38387.tar.bz2
dotty-e5b02a88e66af0d5e9c37a881ac0237bf1d38387.zip
Enable pending pos tests related to value classes
Each test needs to have its own package because pos_all will try to compile the whole valueclasses directory at once. The remaining tests with "extends AnyVal" in tests/pending/pos are related to separate compilation, except for: - t6482.scala and t7022.scala which were fixed by https://github.com/scala/scala/pull/1468 in scalac and seem to trigger a similar bug in FullParameterization - strip-tvars-for-lubbasetypes.scala which was fixed by https://github.com/scala/scala/pull/1758 in scalac
Diffstat (limited to 'tests/pos/valueclasses/optmatch.scala')
-rw-r--r--tests/pos/valueclasses/optmatch.scala35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/pos/valueclasses/optmatch.scala b/tests/pos/valueclasses/optmatch.scala
new file mode 100644
index 000000000..a7995a455
--- /dev/null
+++ b/tests/pos/valueclasses/optmatch.scala
@@ -0,0 +1,35 @@
+package optmatch
+
+// final case class NonZeroLong(value: Long) extends AnyVal {
+// def get: Long = value
+// def isEmpty: Boolean = get == 0l
+// }
+
+class NonZeroLong(val value: Long) extends AnyVal {
+ def get: Long = value
+ def isDefined: Boolean = get != 0l
+}
+object NonZeroLong {
+ def unapply(value: Long): NonZeroLong = new NonZeroLong(value)
+}
+
+
+object Foo {
+ def unapply(x: Int): NonZeroLong = new NonZeroLong(1L << x)
+ // public long unapply(int);
+ // 0: lconst_1
+ // 1: iload_1
+ // 2: lshl
+ // 3: lreturn
+}
+
+object Test {
+ def f(x: Int): Int = x match {
+ case Foo(1024l) => 1
+ case _ => 2
+ }
+ def main(args: Array[String]): Unit = {
+ println(f(10))
+ println(f(11))
+ }
+}