summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala13
-rw-r--r--src/library/scala/Product.scala7
-rwxr-xr-xsrc/library/scala/collection/SequenceLike.scala2
-rw-r--r--src/library/scala/collection/generic/MapTemplate.scala2
-rw-r--r--src/library/scala/collection/generic/SetTemplate.scala2
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala1
-rw-r--r--test/files/pos/unapplyComplex.scala4
-rw-r--r--test/files/pos/unapplyGeneric.scala4
8 files changed, 17 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index 07914fbc27..d1a746f222 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -39,11 +39,10 @@ trait SyntheticMethods extends ast.TreeDSL {
// to override this method anyways.
protected def typer : Typer = global.typer.asInstanceOf[Typer]
- /**
- * @param templ ...
- * @param clazz ...
- * @param unit ...
- * @return ...
+ /** Add the synthetic methods to case classes. Note that a lot of the
+ * complexity herein is a consequence of case classes inheriting from
+ * case classes, which has been deprecated as of Sep 11 2009. So when
+ * the opportunity for removal arises, this can be simplified.
*/
def addSyntheticMethods(templ: Template, clazz: Symbol, context: Context): Template = {
@@ -142,7 +141,9 @@ trait SyntheticMethods extends ast.TreeDSL {
}
}
- /** The canEqual method for case classes.
+ /** The canEqual method for case classes. Note that if we spot
+ * a user-supplied equals implementation, we simply return true
+ * so as not to interfere.
*/
def canEqualMethod: Tree = {
val method = syntheticMethod(nme.canEqual_, 0, makeTypeConstructor(List(AnyClass.tpe), BooleanClass.tpe))
diff --git a/src/library/scala/Product.scala b/src/library/scala/Product.scala
index a67fb94167..ce8f733771 100644
--- a/src/library/scala/Product.scala
+++ b/src/library/scala/Product.scala
@@ -50,11 +50,4 @@ trait Product extends Equals {
* toString methods.
*/
def productPrefix = ""
-
- /**
- * An equality helper method to assist in maintaining reflexivity
- * in the face of subtyping. For more, see
- * http://www.artima.com/lejava/articles/equality.html
- */
- override def canEqual(other: Any): Boolean = true
}
diff --git a/src/library/scala/collection/SequenceLike.scala b/src/library/scala/collection/SequenceLike.scala
index bd62590c4c..baa4d47646 100755
--- a/src/library/scala/collection/SequenceLike.scala
+++ b/src/library/scala/collection/SequenceLike.scala
@@ -445,7 +445,7 @@ trait SequenceLike[+A, +Repr] extends IterableLike[A, Repr] { self =>
override def hashCode() = (Sequence.hashSeed /: this)(_ * 41 + _.hashCode)
override def equals(that: Any): Boolean = that match {
- case that: Sequence[_] => /*(that canEqual this)!!! &&*/ (this sameElements that)
+ case that: Sequence[_] => (that canEqual this) && (this sameElements that)
case _ => false
}
diff --git a/src/library/scala/collection/generic/MapTemplate.scala b/src/library/scala/collection/generic/MapTemplate.scala
index 2bd15ee315..cf0fdcbc3d 100644
--- a/src/library/scala/collection/generic/MapTemplate.scala
+++ b/src/library/scala/collection/generic/MapTemplate.scala
@@ -277,7 +277,7 @@ self =>
override def equals(that: Any): Boolean = that match {
case that: Map[b, _] =>
(this eq that) ||
- /*(that canEqual this) && !!!*/
+ (that canEqual this) &&
(this.size == that.size) && {
try {
this forall {
diff --git a/src/library/scala/collection/generic/SetTemplate.scala b/src/library/scala/collection/generic/SetTemplate.scala
index f0e735133b..88061cb4f5 100644
--- a/src/library/scala/collection/generic/SetTemplate.scala
+++ b/src/library/scala/collection/generic/SetTemplate.scala
@@ -176,7 +176,7 @@ self =>
override def equals(that: Any): Boolean = that match {
case that: Set[A] =>
(this eq that) ||
- /*(that canEqual this) &&!!!*/
+ (that canEqual this) &&
(this.size == that.size) &&
(try this subsetOf that.asInstanceOf[Set[A]]
catch { case ex: ClassCastException => false })
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index bb51a5049b..0473955ed9 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -778,6 +778,7 @@ class Worker(val fileManager: FileManager) extends Actor {
val resFile = results(0)
// 2. Compile source file
if (!compileMgr.shouldCompile(outDir, List(file), kind, logFile)) {
+ NestUI.verbose("compilerMgr failed to compile %s to %s".format(file, outDir))
succeeded = false
} else {
diff --git a/test/files/pos/unapplyComplex.scala b/test/files/pos/unapplyComplex.scala
index 886e265978..70158348c3 100644
--- a/test/files/pos/unapplyComplex.scala
+++ b/test/files/pos/unapplyComplex.scala
@@ -1,4 +1,6 @@
-trait Complex extends Product2[Double, Double]
+trait Complex extends Product2[Double, Double] {
+ def canEqual(other: Any) = other.isInstanceOf[Complex]
+}
class ComplexRect(val _1: Double, val _2: Double) extends Complex {
override def toString = "ComplexRect("+_1+","+_2+")"
diff --git a/test/files/pos/unapplyGeneric.scala b/test/files/pos/unapplyGeneric.scala
index bf88816885..987efdd956 100644
--- a/test/files/pos/unapplyGeneric.scala
+++ b/test/files/pos/unapplyGeneric.scala
@@ -2,7 +2,9 @@ object Bar {
def unapply[A,B](bar:Bar[A,B]) = Some(bar)
}
-class Bar[A,B](val _1:A, val _2:B) extends Product2[A,B]
+class Bar[A,B](val _1:A, val _2:B) extends Product2[A,B] {
+ def canEqual(other: Any) = other.isInstanceOf[Bar[_,_]]
+}
object Test {
new Bar(2, 'a') match {