summaryrefslogtreecommitdiff
path: root/test/files/pos/viewtest1.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/pos/viewtest1.scala')
-rw-r--r--test/files/pos/viewtest1.scala41
1 files changed, 0 insertions, 41 deletions
diff --git a/test/files/pos/viewtest1.scala b/test/files/pos/viewtest1.scala
deleted file mode 100644
index 0a59fdad58..0000000000
--- a/test/files/pos/viewtest1.scala
+++ /dev/null
@@ -1,41 +0,0 @@
-package test;
-
-trait Ordered[a] {
- def < (x: a): boolean;
-}
-
-object O {
- implicit def view (x: String): Ordered[String] = new Ordered[String] {
- def < (y: String) = x.compareTo(y) < 0;
- }
-}
-
-object Empty extends Tree[All];
-case class Node[c <% Ordered[c]](elem: c, l: Tree[c], r: Tree[c]) extends Tree[c];
-
-trait Tree[+a <% Ordered[a]] {
- def insert[b >: a <% Ordered[b]](x: b): Tree[b] = this match {
- case Empty => new Node(x, Empty, Empty)
- case Node(elem, l, r) =>
- if (x == elem) this
- else if (x < elem) Node(elem, l insert x, r)
- else Node(elem, l, r insert x);
- }
- def elements: List[a] = this match {
- case Empty => List()
- case Node(elem, l, r) =>
- l.elements ::: List(elem) ::: r.elements
- }
-}
-
-object Test {
- import O.view;
-
- def main(args: Array[String]) = {
- var t: Tree[String] = Empty;
- for (val s <- args) {
- t = t insert s
- }
- System.out.println(t.elements)
- }
-}