summaryrefslogtreecommitdiff
path: root/test/files/pos
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2004-04-08 15:13:56 +0000
committerMartin Odersky <odersky@gmail.com>2004-04-08 15:13:56 +0000
commit99ec3e8abcca88be3362e396d25f3bf2c22d6528 (patch)
tree5fd467630508d0d4c75fd97d04f29671225bf681 /test/files/pos
parent64d2fb73cd89afbb1df3976dda189ad0cc8a8d0a (diff)
downloadscala-99ec3e8abcca88be3362e396d25f3bf2c22d6528.tar.gz
scala-99ec3e8abcca88be3362e396d25f3bf2c22d6528.tar.bz2
scala-99ec3e8abcca88be3362e396d25f3bf2c22d6528.zip
*** empty log message ***
Diffstat (limited to 'test/files/pos')
-rwxr-xr-xtest/files/pos/viewtest2.scala24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/files/pos/viewtest2.scala b/test/files/pos/viewtest2.scala
index aa8d33ed6c..880ee2a57a 100755
--- a/test/files/pos/viewtest2.scala
+++ b/test/files/pos/viewtest2.scala
@@ -1,6 +1,29 @@
package test;
+/** A trait for totally ordered data.
+ */
+trait Ordered[+a] {
+
+ /** Result of comparing `this' with operand `that'.
+ * returns `x' where
+ * x < 0 iff this < that
+ * x == 0 iff this == that
+ * x > 0 iff this > that
+ */
+ def compareTo [b >: a <% Ordered[b]](that: b): int;
+
+ def < [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) < 0;
+
+ def > [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) > 0;
+
+ def <= [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) <= 0;
+
+ def >= [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) >= 0;
+}
+
+
object O {
+
def view (x: String): Ordered[String] = new Ordered[String] {
def compareTo [b >: String <% Ordered[b]](y: b): int = y match {
case y1: String => x compareTo y1;
@@ -13,6 +36,7 @@ object O {
case _ => -(y compareTo x)
}
}
+
def view[a <% Ordered[a]](x: List[a]): Ordered[List[a]] =
new Ordered[List[a]] {
def compareTo [b >: List[a] <% Ordered[b]](y: b): int = y match {