diff options
Diffstat (limited to 'test/files/pos/viewtest1.scala')
-rw-r--r-- | test/files/pos/viewtest1.scala | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/test/files/pos/viewtest1.scala b/test/files/pos/viewtest1.scala index 0a59fdad58..46acefa32e 100644 --- a/test/files/pos/viewtest1.scala +++ b/test/files/pos/viewtest1.scala @@ -1,25 +1,26 @@ -package test; +package test trait Ordered[a] { - def < (x: a): boolean; + def < (x: a): boolean } object O { implicit def view (x: String): Ordered[String] = new Ordered[String] { - def < (y: String) = x.compareTo(y) < 0; + 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]; +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 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); + else Node(elem, l, r insert x) } def elements: List[a] = this match { case Empty => List() @@ -29,10 +30,10 @@ trait Tree[+a <% Ordered[a]] { } object Test { - import O.view; + import O.view def main(args: Array[String]) = { - var t: Tree[String] = Empty; + var t: Tree[String] = Empty for (val s <- args) { t = t insert s } |