aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/spec-sealed.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-01-27 12:46:48 +0100
committerMartin Odersky <odersky@gmail.com>2015-02-07 17:31:53 +0100
commit1f8b5691dabaae336c3c3f568b303eb24e783494 (patch)
tree7546b2148b5863e2e0070122ffc6d67eacf9edf4 /tests/pos/spec-sealed.scala
parent4320e20ff5f3126940f0ecad1dd53573cf03562b (diff)
downloaddotty-1f8b5691dabaae336c3c3f568b303eb24e783494.tar.gz
dotty-1f8b5691dabaae336c3c3f568b303eb24e783494.tar.bz2
dotty-1f8b5691dabaae336c3c3f568b303eb24e783494.zip
Test reorg
Diffstat (limited to 'tests/pos/spec-sealed.scala')
-rw-r--r--tests/pos/spec-sealed.scala32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/pos/spec-sealed.scala b/tests/pos/spec-sealed.scala
new file mode 100644
index 000000000..d7ecfaaab
--- /dev/null
+++ b/tests/pos/spec-sealed.scala
@@ -0,0 +1,32 @@
+sealed abstract class MyList[@specialized +A] {
+ def head: A
+ def tail: MyList[A]
+
+ def ::[@specialized B >: A](x: B): MyList[B] =
+ new Cons[B](x, this)
+}
+
+case object MyNil extends MyList[Nothing] {
+ def head = sys.error("nil")
+ def tail = sys.error("nil")
+}
+
+case class Cons[@specialized a](private val hd: a, tl: MyList[a]) extends MyList[a] {
+ def head = hd
+ def tail = tl
+}
+
+abstract class IntList extends MyList[Int]
+
+object Main extends App {
+ val xs = 1 :: 2 :: 3 :: MyNil
+ println(xs)
+}
+
+/*
+final class ConsI(hd1: Int, tl1: MyList[Int]) extends Cons[Int](hd1, tl1) {
+ override val hd = hd1
+ override val tl = tl1
+}
+*/
+//class IntCons(_hd: Int, _tl: MyList[Int]) extends Cons[Int](_hd, _tl)