aboutsummaryrefslogtreecommitdiff
path: root/tests/untried/pos/simplelists.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/untried/pos/simplelists.scala')
-rw-r--r--tests/untried/pos/simplelists.scala16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/untried/pos/simplelists.scala b/tests/untried/pos/simplelists.scala
new file mode 100644
index 000000000..ed3d5d2c3
--- /dev/null
+++ b/tests/untried/pos/simplelists.scala
@@ -0,0 +1,16 @@
+abstract class List[+a] {
+ def head: a
+ def tail: List[a]
+ def cons[b >: a](x: b): List[b] = new Cons[b, a](x, this)
+}
+
+object Nil extends List[Nothing] {
+ def error(msg: String): Nothing = throw new java.lang.Error(msg)
+ def head: Nothing = error("Nil.head")
+ def tail: List[Nothing] = error("Nil.tail")
+}
+
+class Cons[c, d <: c](x: c, xs: List[d]) extends List[c] {
+ def head: c = x
+ def tail: List[c] = xs
+}