diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2005-12-16 18:29:42 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2005-12-16 18:29:42 +0000 |
commit | df50e05006b43b007c2587549030d24b5c154398 (patch) | |
tree | 9edfb1fb5b8c04350a00c163cfcdb1fccd79e3aa /test/files/pos/orderedpoints.scala | |
parent | 17e2b1c2a6f69ba74e79c30d1e44195fe732e3e3 (diff) | |
download | scala-df50e05006b43b007c2587549030d24b5c154398.tar.gz scala-df50e05006b43b007c2587549030d24b5c154398.tar.bz2 scala-df50e05006b43b007c2587549030d24b5c154398.zip |
'test-nsc' has been moved to 'test'.
Diffstat (limited to 'test/files/pos/orderedpoints.scala')
-rw-r--r-- | test/files/pos/orderedpoints.scala | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/files/pos/orderedpoints.scala b/test/files/pos/orderedpoints.scala new file mode 100644 index 0000000000..7e56a663fe --- /dev/null +++ b/test/files/pos/orderedpoints.scala @@ -0,0 +1,30 @@ +package test; + +class Point1(x: int) extends Object with Ordered[Point1] { + val xCoord = x; + def compareTo [b >: Point1 <% Ordered[b]](that: b): int = that match { + case that1: Point1 => this.xCoord.compareTo(that1.xCoord) + case _ => -that.compareTo(this) + } +} +class Point2(x: int, y: int) extends Point1(x) with Ordered[Point2] {} +/* + val yCoord = y; + override def compareTo [b >: Point2 <% Ordered[b]](that: b): int = that match { + case that1: Point2 => + val r = super.compareTo(that1); + if (r == 0) this.yCoord.compareTo(that1.yCoord) else r + case _ => -that.compareTo(this) + } +} +object Test extends Application { + val p1 = new Point1(1); + val q1 = new Point1(2); + System.out.println(p1 < q1); + val p2 = new Point2(1, 2); + val q2 = new Point2(1, 3); + System.out.println(p2 < q2); + System.out.println(p1 < q2); + System.out.println(p2 < q1); +} +*/ |