summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-06-22 20:26:34 +0000
committerPaul Phillips <paulp@improving.org>2009-06-22 20:26:34 +0000
commitc22ebf74e0ec17d18bf097c1d47426bd647010a5 (patch)
treeaf3b6479902ecc6c98931d9b7e6ca786d1cfb80f /src
parent2ebff1417c9cfd39251a6a95a72c17af24b813c1 (diff)
downloadscala-c22ebf74e0ec17d18bf097c1d47426bd647010a5.tar.gz
scala-c22ebf74e0ec17d18bf097c1d47426bd647010a5.tar.bz2
scala-c22ebf74e0ec17d18bf097c1d47426bd647010a5.zip
Attempted to resolve the improbable mess surrou...
Attempted to resolve the improbable mess surrounding implicit conversions from Unit. Modified test case which relied on the supposedly verboten behavior; verbotenized () => AnyRef; added new test case which fails if verboten behavior should ever return.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/Ordering.scala10
-rw-r--r--src/library/scala/Predef.scala9
-rw-r--r--src/library/scala/runtime/RichUnit.scala11
3 files changed, 11 insertions, 19 deletions
diff --git a/src/library/scala/Ordering.scala b/src/library/scala/Ordering.scala
index c772e0d3fe..38f9ffa9b4 100644
--- a/src/library/scala/Ordering.scala
+++ b/src/library/scala/Ordering.scala
@@ -100,20 +100,14 @@ object Ordering
{
def apply[T](implicit ord : Ordering[T]) = ord
- def ordered[A <: Ordered[A]] : Ordering[A] = new Ordering[A]{
+ def ordered[A <: Ordered[A]] : Ordering[A] = new Ordering[A] {
def compare(x : A, y : A) = x.compare(y);
}
trait UnitOrdering extends Ordering[Unit] {
def compare(x : Unit, y : Unit) = 0;
}
- // XXX For the time being this is non-implicit so there remains
- // only one default implicit conversion Unit => AnyRef (the other
- // being any2stringadd in Predef.) See
- // test/files/neg/structural.scala
- // for an example of code which is influenced by the next line.
- // implicit object Unit extends UnitOrdering
- object Unit extends UnitOrdering
+ implicit object Unit extends UnitOrdering
trait BooleanOrdering extends Ordering[Boolean] {
def compare(x : Boolean, y : Boolean) = (x, y) match {
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index 49af94b716..565aa363e8 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -190,8 +190,7 @@ object Predef {
implicit def floatWrapper(x: Float) = new runtime.RichFloat(x)
implicit def doubleWrapper(x: Double) = new runtime.RichDouble(x)
- implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x)
- implicit def unitWrapper(x: Boolean) = new runtime.RichUnit
+ implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x)
implicit def stringWrapper(x: String) = new runtime.RichString(x)
@@ -203,12 +202,6 @@ object Predef {
implicit def orderingToOrdered[T](x: T)(implicit ord: Ordering[T]): Ordered[T] =
new Ordered[T] { def compare(that: T): Int = ord.compare(x, that) }
- /** Temporarily leaving this conversion to Ordered - see Ordering.scala for reasoning */
- implicit def unit2ordered(x: Unit): Ordered[Unit] = new Ordered[Unit] with Proxy {
- def self: Any = x
- def compare(y: Unit): Int = 0
- }
-
implicit def byte2short(x: Byte): Short = x.toShort
implicit def byte2int(x: Byte): Int = x.toInt
implicit def byte2long(x: Byte): Long = x.toLong
diff --git a/src/library/scala/runtime/RichUnit.scala b/src/library/scala/runtime/RichUnit.scala
index 7738d0634a..4072e81dc7 100644
--- a/src/library/scala/runtime/RichUnit.scala
+++ b/src/library/scala/runtime/RichUnit.scala
@@ -6,13 +6,18 @@
** |/ **
\* */
-// $Id: RichInt.scala 14532 2008-04-07 12:23:22Z washburn $
+// $Id: RichUnit.scala 14532 2008-04-07 12:23:22Z washburn $
package scala.runtime
/** This class exists only as a dummy subclass so that there are two ambiguous
* implicit conversions from Unit to some subclass to Object.
- * It's important that this class should NOT inherit from Ordered
+ * It's important that this class should NOT inherit from Ordered.
+ *
+ * Note - in reality the ambiguity is successfully introduced by any2stringadd
+ * and orderingToOrdered, and adding an implicit from () => RichUnit actually
+ * resolves the ambiguity by being more specific, and succeeds! So this class
+ * is probably useless, and unitWrapper has been removed from Predef.
*/
-final class RichUnit {}
+final class RichUnit {} \ No newline at end of file