Fixed EqualsHashCodeCheck to ignore generics in determination of check failure.
This commit is contained in:
parent
7b2966e2a5
commit
8a518cb679
|
|
@ -78,8 +78,8 @@ public class EqualsHashCodeCheck
|
|||
public void visitToken(DetailAST aAST)
|
||||
{
|
||||
final DetailAST modifiers = (DetailAST) aAST.getFirstChild();
|
||||
final AST type = modifiers.getNextSibling();
|
||||
final AST methodName = type.getNextSibling();
|
||||
final AST type = aAST.findFirstToken(TokenTypes.TYPE);
|
||||
final AST methodName = aAST.findFirstToken(TokenTypes.IDENT);
|
||||
final DetailAST parameters = aAST.findFirstToken(TokenTypes.PARAMETERS);
|
||||
|
||||
if (type.getFirstChild().getType() == TokenTypes.LITERAL_BOOLEAN
|
||||
|
|
|
|||
|
|
@ -177,4 +177,21 @@ class InputSemantic
|
|||
// empty instance initializer
|
||||
{
|
||||
}
|
||||
|
||||
public class EqualsVsHashCode5
|
||||
{
|
||||
public <A> boolean equals(int a) // wrong arg type, don't flag even with generics
|
||||
{
|
||||
return a == 1;
|
||||
}
|
||||
}
|
||||
|
||||
public class EqualsVsHashCode6
|
||||
{
|
||||
public <A> boolean equals(Comparable<A> a) // flag, weven with generics
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ public class EqualsHashCodeCheckTest
|
|||
final String[] expected = {
|
||||
"126:9: Definition of 'equals()' without corresponding definition of 'hashCode()'.",
|
||||
"163:13: Definition of 'equals()' without corresponding definition of 'hashCode()'.",
|
||||
"191:9: Definition of 'equals()' without corresponding definition of 'hashCode()'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic.java"), expected);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue