summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2006-03-20 12:03:12 +0000
committerMartin Odersky <odersky@gmail.com>2006-03-20 12:03:12 +0000
commit5459db1226b86027e0817acb0a2f41e0c12b28ed (patch)
tree2662cea2c40283eadcdccb5d53d58f769a825601
parent4ddf81c21818dadb435a4a43b91ae69688d8bc1d (diff)
downloadscala-5459db1226b86027e0817acb0a2f41e0c12b28ed.tar.gz
scala-5459db1226b86027e0817acb0a2f41e0c12b28ed.tar.bz2
scala-5459db1226b86027e0817acb0a2f41e0c12b28ed.zip
1.
2. Changed method compareTo in class Ordered to compare. 3. Moved retsynch to pending 4. Fixed bug 550
-rw-r--r--pending/files/run/retsynch.check (renamed from test/files/run/retsynch.check)0
-rw-r--r--pending/files/run/retsynch.scala (renamed from test/files/run/retsynch.scala)0
-rw-r--r--src/compiler/scala/tools/nsc/models/Models.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala10
-rw-r--r--src/library/scala/Array.scala19
-rwxr-xr-xsrc/library/scala/BigInt.scala6
-rw-r--r--src/library/scala/Enumeration.scala4
-rw-r--r--src/library/scala/Iterable.scala6
-rw-r--r--src/library/scala/List.scala6
-rw-r--r--src/library/scala/Ordered.scala11
-rw-r--r--src/library/scala/Predef.scala109
-rw-r--r--src/library/scala/Seq.scala6
-rw-r--r--src/library/scala/runtime/matching/Address.scala6
-rw-r--r--src/library/scala/runtime/matching/NonTerm.scala12
-rw-r--r--src/library/scala/runtime/matching/Rule.scala4
-rw-r--r--src/library/scala/util/automata/SubsetConstruction.scala4
-rw-r--r--test/files/neg/bug550.check10
-rwxr-xr-xtest/files/neg/bug550.scala9
-rw-r--r--test/files/pos/orderedpoints.scala6
-rw-r--r--test/files/pos/viewtest3.scala6
21 files changed, 151 insertions, 99 deletions
diff --git a/test/files/run/retsynch.check b/pending/files/run/retsynch.check
index 8c40598f93..8c40598f93 100644
--- a/test/files/run/retsynch.check
+++ b/pending/files/run/retsynch.check
diff --git a/test/files/run/retsynch.scala b/pending/files/run/retsynch.scala
index d6398cf28e..d6398cf28e 100644
--- a/test/files/run/retsynch.scala
+++ b/pending/files/run/retsynch.scala
diff --git a/src/compiler/scala/tools/nsc/models/Models.scala b/src/compiler/scala/tools/nsc/models/Models.scala
index 65eb769d67..11d422c5d4 100644
--- a/src/compiler/scala/tools/nsc/models/Models.scala
+++ b/src/compiler/scala/tools/nsc/models/Models.scala
@@ -138,11 +138,11 @@ abstract class Models {
override def toString() : String = tree.toString();
- def compareTo [b >: HasTree <% Ordered[b]](that: b): Int = that match {
+ def compare [b >: HasTree <% Ordered[b]](that: b): Int = that match {
case ht : HasTree =>
- val result = tree.symbol.nameString.compareTo(ht.tree.symbol.nameString);
+ val result = tree.symbol.nameString.compare(ht.tree.symbol.nameString);
if (result != 0) result;
- else toString().compareTo(ht.toString());
+ else toString().compare(ht.toString());
}
def kind = kindOf(tree.symbol);
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index da9918c317..f6581950bd 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -199,7 +199,7 @@ trait Namers requires Analyzer {
def applicableTypeParams(owner: Symbol): List[Symbol] =
if (owner.isTerm || owner.isPackageClass) List()
- else applicableTypeParams(owner.owner) ::: owner.unsafeTypeParams;
+ else applicableTypeParams(owner.owner) ::: owner.typeParams;
def deSkolemize: TypeMap = new DeSkolemizeMap(applicableTypeParams(context.owner));
@@ -349,7 +349,7 @@ trait Namers requires Analyzer {
override def complete(sym: Symbol): unit = {
val clazz = tree.symbol;
var tpe = clazz.primaryConstructor.tpe;
- val tparams = clazz.unsafeTypeParams;
+ val tparams = clazz.typeParams;
if (!tparams.isEmpty) tpe = PolyType(tparams, tpe).cloneInfo(sym);
sym.setInfo(tpe);
}
@@ -477,7 +477,7 @@ trait Namers requires Analyzer {
checkContractive(sym, result)
case ValDef(_, _, tpt, rhs) =>
- if (tpt.isEmpty)
+ if (tpt.isEmpty) {
if (rhs.isEmpty) {
context.error(tpt.pos, "missing parameter type");
ErrorType
@@ -485,7 +485,7 @@ trait Namers requires Analyzer {
tpt.tpe = deconstIfNotFinal(sym, newTyper(context.make(tree, sym)).computeType(rhs));
tpt.tpe
}
- else {
+ } else {
val typer1 =
if (sym.hasFlag(PARAM) && sym.owner.isConstructor && !phase.erasedTypes)
newTyper(context.makeConstructorContext)
@@ -545,6 +545,8 @@ trait Namers requires Analyzer {
Flags.flagsToString(flag1) + " and " + Flags.flagsToString(flag2));
if (sym.hasFlag(IMPLICIT) && !sym.isTerm)
context.error(sym.pos, "`implicit' modifier can be used only for values, variables and methods");
+ if (sym.hasFlag(IMPLICIT) && sym.owner.isPackage)
+ context.error(sym.pos, "`implicit' modifier cannot be used for top-level objects");
if (sym.hasFlag(ABSTRACT) && !sym.isClass)
context.error(sym.pos, "`abstract' modifier can be used only for classes; " +
"\nit should be omitted for abstract members");
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index b9e435c7b6..0ad7cd9100 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -22,7 +22,7 @@ trait Typers requires Analyzer {
var implcnt = 0
var impltime = 0l
- final val xviews = false
+ final val xviews = true
private val transformed = new HashMap[Tree, Tree]
@@ -396,7 +396,7 @@ trait Typers requires Analyzer {
if (clazz.hasFlag(CASE)) { // (5.1)
val tree1 = TypeTree(clazz.primaryConstructor.tpe.asSeenFrom(tree.tpe.prefix, clazz.owner)) setOriginal tree
try {
- inferConstructorInstance(tree1, clazz.unsafeTypeParams, pt)
+ inferConstructorInstance(tree1, clazz.typeParams, pt)
} catch {
case npe : NullPointerException =>
logError("CONTEXT: " + context . unit . source .dbg(tree.pos), npe);
@@ -427,7 +427,7 @@ trait Typers requires Analyzer {
}
} else if ((mode & FUNmode) != 0) {
tree
- } else if (tree.hasSymbol && !tree.symbol.unsafeTypeParams.isEmpty) { // (7)
+ } else if (tree.hasSymbol && !tree.symbol.typeParams.isEmpty) { // (7)
errorTree(tree, ""+clazz+" takes type parameters")
} else tree match { // (6)
case TypeTree() => tree
@@ -1402,7 +1402,7 @@ trait Typers requires Analyzer {
case New(tpt: Tree) =>
var tpt1 = typedTypeConstructor(tpt)
if (tpt1.hasSymbol && !tpt1.symbol.typeParams.isEmpty) {
- context.undetparams = cloneSymbols(tpt1.symbol.unsafeTypeParams)
+ context.undetparams = cloneSymbols(tpt1.symbol.typeParams)
tpt1 = TypeTree()
.setOriginal(tpt1) /* .setPos(tpt1.pos) */
.setType(appliedType(tpt1.tpe, context.undetparams map (.tpe)))
@@ -1755,6 +1755,8 @@ trait Typers requires Analyzer {
else errorTree(tree, "no implicit argument matching parameter type "+pt+" was found.")
}
Apply(tree, formals map implicitArg) setPos tree.pos
+ case ErrorType =>
+ tree
}
}
}
diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala
index 21176ce965..b684647bf3 100644
--- a/src/library/scala/Array.scala
+++ b/src/library/scala/Array.scala
@@ -15,6 +15,11 @@ package scala;
import runtime._
object Array {
+
+ /** Copy one array to another
+ * Equaivalent to System.arraycopy(src, srcPos, dest, destPos, length),
+ * except that this works also for plymorphic and boxed arrays
+ */
def copy(src: AnyRef, srcPos: Int, dest: AnyRef, destPos: Int, length: Int): Unit = src match {
case xs: BoxedArray =>
xs.copyTo(srcPos, dest, destPos, length)
@@ -27,6 +32,8 @@ object Array {
}
}
+ /** Concatenate all argument arrays into a single array
+ */
def concat[T](xs: Array[T]*) = {
var len = 0
for (val x <- xs) {
@@ -40,6 +47,18 @@ object Array {
}
result
}
+
+ /** Create a an array containing of successive integers.
+ *
+ * @param from the value of the first element of the array
+ * @param end the value of the last element fo the array plus 1
+ * @return the sorted array of all integers in range [from;end).
+ */
+ def range(start: Int, end: Int): Array[Int] = {
+ val result = new Array[Int](end - start);
+ for (val i <- Iterator.range(start, end)) result(i) = i
+ result
+ }
}
[cloneable,serializable]
diff --git a/src/library/scala/BigInt.scala b/src/library/scala/BigInt.scala
index fd877f6124..66d9719e88 100755
--- a/src/library/scala/BigInt.scala
+++ b/src/library/scala/BigInt.scala
@@ -79,9 +79,9 @@ object BigInt {
*/
implicit def bigInt2ordered(x: BigInt): Ordered[BigInt] = new Ordered[BigInt] with Proxy {
def self: Any = x;
- def compareTo [b >: BigInt <% Ordered[b]](y: b): Int = y match {
+ def compare [b >: BigInt <% Ordered[b]](y: b): Int = y match {
case y: BigInt => x.bigInteger.compareTo(y.bigInteger)
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
}
@@ -108,7 +108,7 @@ class BigInt(val bigInteger: BigInteger) extends runtime.BoxedNumber {
/** Compares this BigInt with the specified BigInt
*/
- def compareTo (that: BigInt): int = this.bigInteger.compareTo(that.bigInteger)
+ def compare (that: BigInt): int = this.bigInteger.compareTo(that.bigInteger)
/** Less-than-or-equals comparison of BigInts
*/
diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala
index 5bd0ccf0f5..5d44c60413 100644
--- a/src/library/scala/Enumeration.scala
+++ b/src/library/scala/Enumeration.scala
@@ -116,9 +116,9 @@ abstract class Enumeration(initial: Int, names: String*) {
abstract class Value extends Ordered[Value] {
def id: Int;
- override def compareTo[S >: Value <% Ordered[S]](that: S): Int = that match {
+ override def compare[S >: Value <% Ordered[S]](that: S): Int = that match {
case that1: Value => id - that1.id
- case _ => -(that compareTo this)
+ case _ => -(that compare this)
}
}
diff --git a/src/library/scala/Iterable.scala b/src/library/scala/Iterable.scala
index 581b39201a..933d597b83 100644
--- a/src/library/scala/Iterable.scala
+++ b/src/library/scala/Iterable.scala
@@ -16,19 +16,19 @@ import Predef.error;
object Iterable {
implicit def view[A <% Ordered[A]](x: Iterable[A]): Ordered[Iterable[A]] =
new Ordered[Iterable[A]] {
- def compareTo[B >: Iterable[A] <% Ordered[B]](that: B): Int = that match {
+ def compare[B >: Iterable[A] <% Ordered[B]](that: B): Int = that match {
case y: Iterable[A] =>
val xs = x.elements;
val ys = y.elements;
var res = 0;
while (xs.hasNext && ys.hasNext && (res == 0)) {
- res = xs.next compareTo ys.next;
+ res = xs.next compare ys.next;
}
if (xs.hasNext) 1
else if (ys.hasNext) -1
else res;
case _ =>
- -(that compareTo x)
+ -(that compare x)
}
}
diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala
index 824e109a60..395f497558 100644
--- a/src/library/scala/List.scala
+++ b/src/library/scala/List.scala
@@ -339,16 +339,16 @@ object List {
/** Lists with ordered elements are ordered
*/
implicit def list2ordered[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 {
+ def compare [b >: List[a] <% Ordered[b]](y: b): Int = y match {
case y1: List[a] => compareLists(x, y1);
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
private def compareLists(xs: List[a], ys: List[a]): Int = {
if (xs.isEmpty && ys.isEmpty) 0
else if (xs.isEmpty) -1
else if (ys.isEmpty) 1
else {
- val s = xs.head compareTo ys.head;
+ val s = xs.head compare ys.head;
if (s != 0) s
else compareLists(xs.tail, ys.tail)
}
diff --git a/src/library/scala/Ordered.scala b/src/library/scala/Ordered.scala
index eca26f290b..97639c5170 100644
--- a/src/library/scala/Ordered.scala
+++ b/src/library/scala/Ordered.scala
@@ -25,13 +25,14 @@ trait Ordered[+a] {
* <code>x == 0</code> iff <code>this == that</code>
* <code>x &gt; 0</code> iff <code>this &gt; that</code>
*/
- def compareTo [b >: a <% Ordered[b]](that: b): Int;
+ def compareTo [b >: a <% Ordered[b]](that: b): Int = compare(that)
+ def compare [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 compare that) < 0;
- def > [b >: a <% Ordered[b]](that: b): Boolean = (this compareTo that) > 0;
+ def > [b >: a <% Ordered[b]](that: b): Boolean = (this compare that) > 0;
- def <= [b >: a <% Ordered[b]](that: b): Boolean = (this compareTo that) <= 0;
+ def <= [b >: a <% Ordered[b]](that: b): Boolean = (this compare that) <= 0;
- def >= [b >: a <% Ordered[b]](that: b): Boolean = (this compareTo that) >= 0;
+ def >= [b >: a <% Ordered[b]](that: b): Boolean = (this compare that) >= 0;
}
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index ace68c2eec..775daf40f3 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -187,187 +187,187 @@ object Predef {
implicit def int2ordered(x: int): Ordered[int] = new Ordered[int] with Proxy {
def self: Any = x;
- def compareTo [b >: int <% Ordered[b]](y: b): int = y match {
+ def compare [b >: int <% Ordered[b]](y: b): int = y match {
case y1: int =>
if (x < y1) -1
else if (x > y1) 1
else 0
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def char2ordered(x: char): Ordered[char] = new Ordered[char] with Proxy {
def self: Any = x;
- def compareTo [b >: char <% Ordered[b]](y: b): int = y match {
+ def compare [b >: char <% Ordered[b]](y: b): int = y match {
case y1: char =>
if (x < y1) -1
else if (x > y1) 1
else 0
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def long2ordered(x: long): Ordered[long] = new Ordered[long] with Proxy {
def self: Any = x;
- def compareTo [b >: long <% Ordered[b]](y: b): int = y match {
+ def compare [b >: long <% Ordered[b]](y: b): int = y match {
case y1: long =>
if (x < y1) -1
else if (x > y1) 1
else 0
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def float2ordered(x: float): Ordered[float] = new Ordered[float] with Proxy {
def self: Any = x;
- def compareTo [b >: float <% Ordered[b]](y: b): int = y match {
+ def compare [b >: float <% Ordered[b]](y: b): int = y match {
case y1: float =>
if (x < y1) -1
else if (x > y1) 1
else 0
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def double2ordered(x: double): Ordered[double] = new Ordered[double] with Proxy {
def self: Any = x;
- def compareTo [b >: double <% Ordered[b]](y: b): int = y match {
+ def compare [b >: double <% Ordered[b]](y: b): int = y match {
case y1: double =>
if (x < y1) -1
else if (x > y1) 1
else 0
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def boolean2ordered(x: boolean): Ordered[boolean] = new Ordered[boolean] with Proxy {
def self: Any = x;
- def compareTo [b >: boolean <% Ordered[b]](y: b): int = y match {
+ def compare [b >: boolean <% Ordered[b]](y: b): int = y match {
case y1: boolean =>
if (x == y1) 0
else if (x) 1
else -1
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def seq2ordered[a <% Ordered[a]](xs: Array[a]): Ordered[Seq[a]] =
new Ordered[Seq[a]] with Proxy {
val self = xs
- def compareTo[b >: Seq[a] <% Ordered[b]](that: b): Int = that match {
+ def compare[b >: Seq[a] <% Ordered[b]](that: b): Int = that match {
case that: Seq[a] =>
var res = 0
val these = xs.elements
val those = that.elements
while (res == 0 && these.hasNext)
- res = if (those.hasNext) these.next compareTo those.next else 1
+ res = if (those.hasNext) these.next compare those.next else 1
res
case _ =>
- -(that compareTo xs)
+ -(that compare xs)
}
}
implicit def tuple22ordered[a1 <% Ordered[a1], a2 <% Ordered[a2]](x: Tuple2[a1, a2]): Ordered[Tuple2[a1, a2]] =
new Ordered[Tuple2[a1, a2]] with Proxy {
val self = x
- def compareTo[T >: Tuple2[a1, a2] <% Ordered[T]](y: T): Int = y match {
+ def compare[T >: Tuple2[a1, a2] <% Ordered[T]](y: T): Int = y match {
case y: Tuple2[a1, a2] =>
- val res = x._1 compareTo y._1
- if (res == 0) x._2 compareTo y._2
+ val res = x._1 compare y._1
+ if (res == 0) x._2 compare y._2
else res
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def tuple32ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3]](x: Tuple3[a1, a2, a3]): Ordered[Tuple3[a1, a2, a3]] =
new Ordered[Tuple3[a1, a2, a3]] with Proxy {
val self = x
- def compareTo[T >: Tuple3[a1, a2, a3] <% Ordered[T]](y: T): Int = y match {
+ def compare[T >: Tuple3[a1, a2, a3] <% Ordered[T]](y: T): Int = y match {
case y: Tuple3[a1, a2, a3] =>
- val res = x._1 compareTo y._1;
- if (res == 0) Tuple2(x._2, x._3) compareTo Tuple2(y._2, y._3)
+ val res = x._1 compare y._1;
+ if (res == 0) Tuple2(x._2, x._3) compare Tuple2(y._2, y._3)
else res
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def tuple42ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3], a4 <% Ordered[a4]](x: Tuple4[a1, a2, a3, a4]): Ordered[Tuple4[a1, a2, a3, a4]] =
new Ordered[Tuple4[a1, a2, a3, a4]] with Proxy {
val self = x
- def compareTo[T >: Tuple4[a1, a2, a3, a4] <% Ordered[T]](y: T): Int = y match {
+ def compare[T >: Tuple4[a1, a2, a3, a4] <% Ordered[T]](y: T): Int = y match {
case y: Tuple4[a1, a2, a3, a4] =>
- val res = x._1 compareTo y._1;
- if (res == 0) Tuple3(x._2, x._3, x._4) compareTo Tuple3(y._2, y._3, y._4)
+ val res = x._1 compare y._1;
+ if (res == 0) Tuple3(x._2, x._3, x._4) compare Tuple3(y._2, y._3, y._4)
else res
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def tuple52ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3], a4 <% Ordered[a4], a5 <% Ordered[a5]](x: Tuple5[a1, a2, a3, a4, a5]): Ordered[Tuple5[a1, a2, a3, a4, a5]] =
new Ordered[Tuple5[a1, a2, a3, a4, a5]] with Proxy {
val self = x
- def compareTo[T >: Tuple5[a1, a2, a3, a4, a5] <% Ordered[T]](y: T): Int = y match {
+ def compare[T >: Tuple5[a1, a2, a3, a4, a5] <% Ordered[T]](y: T): Int = y match {
case y: Tuple5[a1, a2, a3, a4, a5] =>
- val res = x._1 compareTo y._1;
- if (res == 0) Tuple4(x._2, x._3, x._4, x._5) compareTo Tuple4(y._2, y._3, y._4, y._5)
+ val res = x._1 compare y._1;
+ if (res == 0) Tuple4(x._2, x._3, x._4, x._5) compare Tuple4(y._2, y._3, y._4, y._5)
else res
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def tuple62ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3], a4 <% Ordered[a4], a5 <% Ordered[a5], a6 <% Ordered[a6]](x: Tuple6[a1, a2, a3, a4, a5, a6]): Ordered[Tuple6[a1, a2, a3, a4, a5, a6]] =
new Ordered[Tuple6[a1, a2, a3, a4, a5, a6]] with Proxy {
val self = x
- def compareTo[T >: Tuple6[a1, a2, a3, a4, a5, a6] <% Ordered[T]](y: T): Int = y match {
+ def compare[T >: Tuple6[a1, a2, a3, a4, a5, a6] <% Ordered[T]](y: T): Int = y match {
case y: Tuple6[a1, a2, a3, a4, a5, a6] =>
- val res = x._1 compareTo y._1;
- if (res == 0) Tuple5(x._2, x._3, x._4, x._5, x._6) compareTo Tuple5(y._2, y._3, y._4, y._5, y._6)
+ val res = x._1 compare y._1;
+ if (res == 0) Tuple5(x._2, x._3, x._4, x._5, x._6) compare Tuple5(y._2, y._3, y._4, y._5, y._6)
else res
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def tuple72ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3], a4 <% Ordered[a4], a5 <% Ordered[a5], a6 <% Ordered[a6], a7 <% Ordered[a7]](x: Tuple7[a1, a2, a3, a4, a5, a6, a7]): Ordered[Tuple7[a1, a2, a3, a4, a5, a6, a7]] =
new Ordered[Tuple7[a1, a2, a3, a4, a5, a6, a7]] with Proxy {
val self = x
- def compareTo[T >: Tuple7[a1, a2, a3, a4, a5, a6, a7] <% Ordered[T]](y: T): Int = y match {
+ def compare[T >: Tuple7[a1, a2, a3, a4, a5, a6, a7] <% Ordered[T]](y: T): Int = y match {
case y: Tuple7[a1, a2, a3, a4, a5, a6, a7] =>
- val res = x._1 compareTo y._1;
- if (res == 0) Tuple6(x._2, x._3, x._4, x._5, x._6, x._7) compareTo Tuple6(y._2, y._3, y._4, y._5, y._6, y._7)
+ val res = x._1 compare y._1;
+ if (res == 0) Tuple6(x._2, x._3, x._4, x._5, x._6, x._7) compare Tuple6(y._2, y._3, y._4, y._5, y._6, y._7)
else res
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def tuple82ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3], a4 <% Ordered[a4], a5 <% Ordered[a5], a6 <% Ordered[a6], a7 <% Ordered[a7], a8 <% Ordered[a8]](x: Tuple8[a1, a2, a3, a4, a5, a6, a7, a8]): Ordered[Tuple8[a1, a2, a3, a4, a5, a6, a7, a8]] =
new Ordered[Tuple8[a1, a2, a3, a4, a5, a6, a7, a8]] with Proxy {
val self = x
- def compareTo[T >: Tuple8[a1, a2, a3, a4, a5, a6, a7, a8] <% Ordered[T]](y: T): Int = y match {
+ def compare[T >: Tuple8[a1, a2, a3, a4, a5, a6, a7, a8] <% Ordered[T]](y: T): Int = y match {
case y: Tuple8[a1, a2, a3, a4, a5, a6, a7, a8] =>
- val res = x._1 compareTo y._1;
- if (res == 0) Tuple7(x._2, x._3, x._4, x._5, x._6, x._7, x._8) compareTo Tuple7(y._2, y._3, y._4, y._5, y._6, y._7, y._8)
+ val res = x._1 compare y._1;
+ if (res == 0) Tuple7(x._2, x._3, x._4, x._5, x._6, x._7, x._8) compare Tuple7(y._2, y._3, y._4, y._5, y._6, y._7, y._8)
else res
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def tuple92ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3], a4 <% Ordered[a4], a5 <% Ordered[a5], a6 <% Ordered[a6], a7 <% Ordered[a7], a8 <% Ordered[a8], a9 <% Ordered[a9]](x: Tuple9[a1, a2, a3, a4, a5, a6, a7, a8, a9]): Ordered[Tuple9[a1, a2, a3, a4, a5, a6, a7, a8, a9]] =
new Ordered[Tuple9[a1, a2, a3, a4, a5, a6, a7, a8, a9]] with Proxy {
val self = x
- def compareTo[T >: Tuple9[a1, a2, a3, a4, a5, a6, a7, a8, a9] <% Ordered[T]](y: T): Int = y match {
+ def compare[T >: Tuple9[a1, a2, a3, a4, a5, a6, a7, a8, a9] <% Ordered[T]](y: T): Int = y match {
case y: Tuple9[a1, a2, a3, a4, a5, a6, a7, a8, a9] =>
- val res = x._1 compareTo y._1;
- if (res == 0) Tuple8(x._2, x._3, x._4, x._5, x._6, x._7, x._8, x._9) compareTo Tuple8(y._2, y._3, y._4, y._5, y._6, y._7, y._8, y._9)
+ val res = x._1 compare y._1;
+ if (res == 0) Tuple8(x._2, x._3, x._4, x._5, x._6, x._7, x._8, x._9) compare Tuple8(y._2, y._3, y._4, y._5, y._6, y._7, y._8, y._9)
else res
- case _ => -(y compareTo x)
+ case _ => -(y compare x)
}
}
implicit def string2ordered(x: String): Ordered[String] = new Ordered[String] with Proxy {
def self: Any = x;
- def compareTo [b >: String <% Ordered[b]](y: b): int = y match {
- case y1: String => x compareTo y1;
- case _ => -(y compareTo x)
+ def compare [b >: String <% Ordered[b]](y: b): int = y match {
+ case y1: String => x compare y1;
+ case _ => -(y compare x)
}
}
@@ -404,4 +404,13 @@ object Predef {
implicit def long2double(x: long): double = x.toDouble;
implicit def float2double(x: float): double = x.toDouble;
+
+ implicit def byte2Byte(x: byte) = new java.lang.Byte(x)
+ implicit def short2Short(x: short) = new java.lang.Short(x)
+ implicit def char2Character(x: char) = new java.lang.Character(x)
+ implicit def int2Integer(x: int) = new java.lang.Integer(x)
+ implicit def long2Long(x: long) = new java.lang.Long(x)
+ implicit def float2Float(x: float) = new java.lang.Float(x)
+ implicit def double2Double(x: double) = new java.lang.Double(x)
+ implicit def boolean2Boolean(x: boolean) = new java.lang.Boolean(x)
}
diff --git a/src/library/scala/Seq.scala b/src/library/scala/Seq.scala
index 66c44829e7..b591d5fe1f 100644
--- a/src/library/scala/Seq.scala
+++ b/src/library/scala/Seq.scala
@@ -27,17 +27,17 @@ object Seq {
implicit def view[A <% Ordered[A]](xs: Seq[A]): Ordered[Seq[A]] =
new Ordered[Seq[A]] with Proxy {
def self: Any = xs;
- def compareTo[B >: Seq[A] <% Ordered[B]](that: B): Int = that match {
+ def compare[B >: Seq[A] <% Ordered[B]](that: B): Int = that match {
case ys: Seq[A] =>
var res = 0;
val xsit = xs.elements;
val ysit = ys.elements;
while (xsit.hasNext && ysit.hasNext && (res == 0)) {
- res = xsit.next compareTo ysit.next;
+ res = xsit.next compare ysit.next;
}
if (res != 0) res else if (xsit.hasNext) 1 else -1
case _ =>
- -(that compareTo xs)
+ -(that compare xs)
}
}
}
diff --git a/src/library/scala/runtime/matching/Address.scala b/src/library/scala/runtime/matching/Address.scala
index 470650e312..56bab618a7 100644
--- a/src/library/scala/runtime/matching/Address.scala
+++ b/src/library/scala/runtime/matching/Address.scala
@@ -24,10 +24,10 @@ class Address( l:Int* ) extends Ordered[Address] {
private val list:List[Int] = l.toList;
- def compareTo [b >: Address <% Ordered[b]](y: b): int = y match {
- case o:Address => list.reverse.compareTo(o.list.reverse)
+ def compare [b >: Address <% Ordered[b]](y: b): int = y match {
+ case o:Address => list.reverse.compare(o.list.reverse)
//(xs => List.view(xs)(Predef.int2ordered));
- case _ => -(y compareTo this)
+ case _ => -(y compare this)
}
def down: Address = new Address( ( 1 :: list ):_* );
diff --git a/src/library/scala/runtime/matching/NonTerm.scala b/src/library/scala/runtime/matching/NonTerm.scala
index b8915ef916..5c005d3795 100644
--- a/src/library/scala/runtime/matching/NonTerm.scala
+++ b/src/library/scala/runtime/matching/NonTerm.scala
@@ -35,9 +35,9 @@ case class TreeNT(i:int) extends NonTerm with Ordered[TreeNT] {
this.vset = new immutable.TreeSet[Int]() incl vset ;
}
- def compareTo [b >: TreeNT <% Ordered[b]](y: b): int = y match {
- case TreeNT( y1 ) => i compareTo y1;
- case _ => -(y compareTo this)
+ def compare [b >: TreeNT <% Ordered[b]](y: b): int = y match {
+ case TreeNT( y1 ) => i compare y1;
+ case _ => -(y compare this)
}
};
@@ -52,9 +52,9 @@ case class HedgeNT(i:int) extends NonTerm with Ordered[HedgeNT] {
this.nullable = nullable;
}
- def compareTo [b >: HedgeNT <% Ordered[b]](y: b): int = y match {
- case HedgeNT( y1 ) => i compareTo y1;
- case _ => -(y compareTo this)
+ def compare [b >: HedgeNT <% Ordered[b]](y: b): int = y match {
+ case HedgeNT( y1 ) => i compare y1;
+ case _ => -(y compare this)
}
};
diff --git a/src/library/scala/runtime/matching/Rule.scala b/src/library/scala/runtime/matching/Rule.scala
index 148e69735e..7e9e106727 100644
--- a/src/library/scala/runtime/matching/Rule.scala
+++ b/src/library/scala/runtime/matching/Rule.scala
@@ -15,7 +15,7 @@ package scala.runtime.matching ;
/* hedge grammar rules */
abstract class Rule extends Ordered[Rule] {
- def compareTo [b >: Rule <% Ordered[b]](that: b): int = that match {
+ def compare [b >: Rule <% Ordered[b]](that: b): int = that match {
case r:Rule =>
if( rule_smaller( this, r ) )
-1
@@ -23,7 +23,7 @@ abstract class Rule extends Ordered[Rule] {
0
else
1
- case _ => -(that compareTo this)
+ case _ => -(that compare this)
}
final def rule_smaller( r1:Rule, r2:Rule ):boolean = r1 match {
diff --git a/src/library/scala/util/automata/SubsetConstruction.scala b/src/library/scala/util/automata/SubsetConstruction.scala
index 67b19802cf..7a0cb4a39c 100644
--- a/src/library/scala/util/automata/SubsetConstruction.scala
+++ b/src/library/scala/util/automata/SubsetConstruction.scala
@@ -20,7 +20,7 @@ class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) {
import immutable.{ BitSet, TreeMap, TreeSet } ;
implicit def toOrdered(bs: BitSet): Ordered[BitSet] = new Ordered[BitSet] {
- def compareTo [b >: BitSet <% Ordered[b]](other: b): Int = other match {
+ def compare [b >: BitSet <% Ordered[b]](other: b): Int = other match {
case that: BitSet => {
val it1 = bs.elements;
val it2 = that.elements;
@@ -46,7 +46,7 @@ class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) {
res
}
- //case _ => -(other.compareTo(this))
+ //case _ => -(other.compare(this))
}
}
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)
}
}