From de8a10cdd1badae2a73c8506a59eebaa1c323312 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 27 Aug 2009 12:01:31 +0000 Subject: Fix for #2240. --- src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 326ce6f748..42d0dd80fb 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -631,6 +631,9 @@ abstract class RefChecks extends InfoTransform { nonSensibleWarning(pre+"values of types "+normalizeAll(qual.tpe.widen)+" and "+normalizeAll(args.head.tpe.widen), alwaysEqual) // @MAT normalize for consistency in error message, otherwise part is normalized due to use of `typeSymbol', but the rest isn't def hasObjectEquals = receiver.info.member(nme.equals_) == Object_equals + // see if it has any == methods beyond Any's and AnyRef's: ticket #2240 + def hasOverloadedEqEq = receiver.info.member(nme.EQ).alternatives.length > 2 + if (formal == UnitClass && actual == UnitClass) nonSensible("", true) else if ((receiver == BooleanClass || receiver == UnitClass) && @@ -646,7 +649,7 @@ abstract class RefChecks extends InfoTransform { (name == nme.EQ || name == nme.LE)) nonSensible("non-null ", false) else if ((isNew(qual) || isNew(args.head)) && hasObjectEquals && - (name == nme.EQ || name == nme.NE)) + (name == nme.EQ || name == nme.NE) && !hasOverloadedEqEq) nonSensibleWarning("a fresh object", false) case _ => } -- cgit v1.2.3