diff options
author | Paul Phillips <paulp@improving.org> | 2010-11-01 16:26:44 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-11-01 16:26:44 +0000 |
commit | 1df37f476926ada63e223abcbe119147b6d693b3 (patch) | |
tree | 965fd2c5211d195b3a0e60cdaf8fb2e3fd4ed252 /src | |
parent | 00b42b18ed462db89956de881bbc13740cd8ba82 (diff) | |
download | scala-1df37f476926ada63e223abcbe119147b6d693b3.tar.gz scala-1df37f476926ada63e223abcbe119147b6d693b3.tar.bz2 scala-1df37f476926ada63e223abcbe119147b6d693b3.zip |
Relaxed non-sensible warning for comparisons wh...
Relaxed non-sensible warning for comparisons when ScalaNumber is
involved, since there is special number logic which makes it wrong to
chastise us. No review.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Definitions.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 8 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index a26ee2c94f..4e16f06566 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -471,6 +471,7 @@ trait Definitions extends reflect.generic.StandardDefinitions { lazy val MigrationAnnotationClass: Symbol = getClass("scala.annotation.migration") lazy val NativeAttr: Symbol = getClass("scala.native") lazy val RemoteAttr: Symbol = getClass("scala.remote") + lazy val ScalaNumberClass: Symbol = getClass("scala.math.ScalaNumber") lazy val SerialVersionUIDAttr: Symbol = getClass("scala.SerialVersionUID") lazy val SerializableAttr: Symbol = getClass("scala.serializable") lazy val TraitSetterAnnotationClass: Symbol = getClass("scala.runtime.TraitSetter") diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index bc16d7c377..fd8d8274d3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -883,7 +883,7 @@ abstract class RefChecks extends InfoTransform { } // Whether the operands+operator represent a warnable combo (assuming anyrefs) def isWarnable = isReferenceOp || (isUsingDefaultEquals && isUsingDefaultScalaOp) - def isValueOrBoxed(s: Symbol) = isNumericValueClass(s) || (s isSubClass BoxedNumberClass) + def isScalaNumber(s: Symbol) = isNumericValueClass(s) || (s isSubClass BoxedNumberClass) || (s isSubClass ScalaNumberClass) def isEitherNull = (receiver == NullClass) || (actual == NullClass) def isEitherNullable = (NullClass.tpe <:< receiver.info) || (NullClass.tpe <:< actual.info) @@ -901,8 +901,10 @@ abstract class RefChecks extends InfoTransform { nonSensible("", false) else if (receiver == UnitClass && actual == UnitClass) // () == () nonSensible("", true) - else if (isNumericValueClass(receiver) && !isValueOrBoxed(actual) && !forMSIL) // 5 == "abc" - nonSensible("", false) + else if (isNumericValueClass(receiver)) { + if (!isScalaNumber(actual) && !forMSIL) // 5 == "abc" + nonSensible("", false) + } else if (isWarnable) { if (receiver.isFinal && !isEitherNull && !(receiver isSubClass actual)) // object X, Y; X == Y nonSensible((if (isEitherNullable) "non-null " else ""), false) |