New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect warning when using an overloaded 'eq' method #6328
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6328?orig=1 |
Jared Luxenberg (jluxenberg) said: ...
def checkSensible(pos: Position, fn: Tree, args: List[Tree]) = fn match {
case Select(qual, name @ (nme.EQ | nme.NE | nme.eq | nme.ne)) if args.length == 1 =>
def isReferenceOp = name == nme.eq || name == nme.ne
...
// Whether def equals(other: Any) is overridden
def isUsingDefaultEquals = {
val m = receiver.info.member(nme.equals_)
(m == Object_equals) || (m == Any_equals)
}
// Whether this == or != is one of those defined in Any/AnyRef or an overload from elsewhere.
def isUsingDefaultScalaOp = {
val s = fn.symbol
(s == Object_==) || (s == Object_!=) || (s == Any_==) || (s == Any_!=)
}
// Whether the operands+operator represent a warnable combo (assuming anyrefs)
def isWarnable = isReferenceOp || (isUsingDefaultEquals && isUsingDefaultScalaOp) note that isReferenceOp is "true" whenever the method name is "eq" or "ne". This code does not take into account whether the method has been overloaded. A check similar to the one used by "isUsingDefaultEquals" and "isUsingDefaultScalaOp" should be included for "eq" and "ne". |
The following test case produces a warning, but I do not believe it should:
The text was updated successfully, but these errors were encountered: