From 5459db1226b86027e0817acb0a2f41e0c12b28ed Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 20 Mar 2006 12:03:12 +0000 Subject: 1. 2. Changed method compareTo in class Ordered to compare. 3. Moved retsynch to pending 4. Fixed bug 550 --- test/files/neg/bug550.check | 10 ++++++++++ test/files/neg/bug550.scala | 9 +++++++++ test/files/pos/orderedpoints.scala | 6 +++--- test/files/pos/viewtest3.scala | 6 +++--- test/files/run/retsynch.check | 1 - test/files/run/retsynch.scala | 11 ----------- 6 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 test/files/neg/bug550.check create mode 100755 test/files/neg/bug550.scala delete mode 100644 test/files/run/retsynch.check delete mode 100644 test/files/run/retsynch.scala (limited to 'test') diff --git a/test/files/neg/bug550.check b/test/files/neg/bug550.check new file mode 100644 index 0000000000..becafc8768 --- /dev/null +++ b/test/files/neg/bug550.check @@ -0,0 +1,10 @@ +bug550.scala:6 error: class List takes type parameters + def sum[a](xs: List)(implicit m: Monoid[a]): a = + ^ +bug550.scala:6 error: class List takes type parameters + def sum[a](xs: List)(implicit m: Monoid[a]): a = + ^ +bug550.scala:8 error: no implicit argument matching parameter type Monoid[scala.All] was found. + sum(List(1,2,3)) + ^ +three errors found diff --git a/test/files/neg/bug550.scala b/test/files/neg/bug550.scala new file mode 100755 index 0000000000..5212a2658d --- /dev/null +++ b/test/files/neg/bug550.scala @@ -0,0 +1,9 @@ +abstract class Monoid[a] { + def unit: a +} + +object test { + def sum[a](xs: List)(implicit m: Monoid[a]): a = + if (xs.isEmpty) m.unit else xs.head + sum(List(1,2,3)) +} diff --git a/test/files/pos/orderedpoints.scala b/test/files/pos/orderedpoints.scala index 7e56a663fe..f972028bce 100644 --- a/test/files/pos/orderedpoints.scala +++ b/test/files/pos/orderedpoints.scala @@ -2,9 +2,9 @@ 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) + def compare [b >: Point1 <% Ordered[b]](that: b): int = that match { + case that1: Point1 => this.xCoord.compare(that1.xCoord) + case _ => -that.compare(this) } } class Point2(x: int, y: int) extends Point1(x) with Ordered[Point2] {} diff --git a/test/files/pos/viewtest3.scala b/test/files/pos/viewtest3.scala index 89e32e48a8..68277a7a47 100644 --- a/test/files/pos/viewtest3.scala +++ b/test/files/pos/viewtest3.scala @@ -20,9 +20,9 @@ class Node[a <% Ordered[a]](elem: a, l: Tree[a], r: Tree[a]) extends Tree[a] { } case class Str(elem: String) extends Ordered[Str] { - def compareTo[b >: Str <% Ordered[b]](that: b): int = that match { - case that1: Str => this.elem compareTo that1.elem - case _ => -(that compareTo this) + def compare[b >: Str <% Ordered[b]](that: b): int = that match { + case that1: Str => this.elem compare that1.elem + case _ => -(that compare this) } } diff --git a/test/files/run/retsynch.check b/test/files/run/retsynch.check deleted file mode 100644 index 8c40598f93..0000000000 --- a/test/files/run/retsynch.check +++ /dev/null @@ -1 +0,0 @@ -abs(-5) = 5 diff --git a/test/files/run/retsynch.scala b/test/files/run/retsynch.scala deleted file mode 100644 index d6398cf28e..0000000000 --- a/test/files/run/retsynch.scala +++ /dev/null @@ -1,11 +0,0 @@ -object Test { - def abs(x:int): int = synchronized { - if(x > 0) - return x - return -x - } - - def main(args: Array[String]) = { - Console.println("abs(-5) = " + abs(-5)) - } -} -- cgit v1.2.3