summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala21
2 files changed, 13 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index 3f46850e30..54aa364ddd 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -362,6 +362,7 @@ trait Definitions requires SymbolTable {
// boxed classes
var BoxedArrayClass: Symbol = _
+ var BoxedNumberClass: Symbol = _
var BoxedAnyArrayClass: Symbol = _
var BoxedObjectArrayClass: Symbol = _
var BoxedUnitClass: Symbol = _
@@ -862,6 +863,7 @@ trait Definitions requires SymbolTable {
PatternWildcard = NoSymbol.newValue(NoPos, "_").setInfo(AllClass.typeConstructor)
+ BoxedNumberClass = getClass("scala.runtime.BoxedNumber")
BoxedArrayClass = getClass("scala.runtime.BoxedArray")
BoxedAnyArrayClass = getClass("scala.runtime.BoxedAnyArray")
BoxedObjectArrayClass = getClass("scala.runtime.BoxedObjectArray")
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index a5f6f785b9..78ccc5f7f4 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -454,23 +454,24 @@ abstract class RefChecks extends InfoTransform {
def nonSensibleWarning(what: String, alwaysEqual: boolean) =
unit.warning(pos, "comparing "+what+" using `"+name.decode+"' will always yield "+
(alwaysEqual == (name == nme.EQ || name == nme.LE || name == nme.GE)))
- def nonSensible(alwaysEqual: boolean) =
- nonSensibleWarning("values of types "+qual.tpe.widen+" and "+args.head.tpe.widen,
+ def nonSensible(pre: String, alwaysEqual: boolean) =
+ nonSensibleWarning(pre+"values of types "+qual.tpe.widen+" and "+args.head.tpe.widen,
alwaysEqual)
+ def hasObjectEquals = receiver.info.member(nme.equals_) == Object_equals
if (formal == UnitClass && actual == UnitClass)
- nonSensible(true)
+ nonSensible("", true)
else if ((receiver == BooleanClass || receiver == UnitClass) &&
!(receiver isSubClass actual))
- nonSensible(false)
+ nonSensible("", false)
else if (isNumericValueClass(receiver) &&
!isNumericValueClass(actual) &&
+ !(actual isSubClass BoxedNumberClass) &&
!(receiver isSubClass actual))
- nonSensible(false)
- else if ((receiver hasFlag FINAL) &&
- (fn.symbol == Object_== || fn.symbol == Object_!=) &&
- !(receiver isSubClass actual))
- nonSensible(false)
- else if (isNew && (fn.symbol == Object_== || fn.symbol == Object_!=))
+ nonSensible("", false)
+ else if ((receiver hasFlag FINAL) && hasObjectEquals && !isValueClass(receiver) &&
+ !(receiver isSubClass actual) && actual != AllRefClass)
+ nonSensible("non-null ", false)
+ else if (isNew && hasObjectEquals)
nonSensibleWarning("a fresh object", false)
case _ =>
}