summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala3
-rw-r--r--test/files/pos/t1027.scala18
2 files changed, 20 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 55728ec70f..5485c4ccc4 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -563,7 +563,8 @@ abstract class RefChecks extends InfoTransform {
!(receiver isSubClass actual) && receiver != AllRefClass && actual != AllRefClass &&
(name == nme.EQ || name == nme.LE))
nonSensible("non-null ", false)
- else if ((isNew(qual) || isNew(args.head)) && hasObjectEquals)
+ else if ((isNew(qual) || isNew(args.head)) && hasObjectEquals &&
+ (name == nme.EQ || name == nme.NE))
nonSensibleWarning("a fresh object", false)
case _ =>
}
diff --git a/test/files/pos/t1027.scala b/test/files/pos/t1027.scala
new file mode 100644
index 0000000000..7854041f10
--- /dev/null
+++ b/test/files/pos/t1027.scala
@@ -0,0 +1,18 @@
+object T1027 extends Application {
+ trait Comparable[T <: Comparable[T]] { this: T =>
+ def < (that: T): Boolean
+ def <=(that: T): Boolean = this < that || this == that
+ def > (that: T): Boolean = that < this
+ def >=(that: T): Boolean = that <= this
+ }
+ class A(val x: String) extends Comparable[A]{
+ def < (that: A) = this.x < that.x
+ }
+ val a = new A("a")
+ val b = new A("b")
+ println(a < b)
+ println(a > b)
+ println(a <= b)
+ println(a >= b)
+ println("Comparable traits : " + (new A("x") > new A("y")).toString)
+ }