Issue #3582: marked enum field's final method as redundant

This commit is contained in:
rnveach 2017-01-05 14:44:54 -05:00 committed by Roman Ivanov
parent 0b36159898
commit 39cafcc5bb
2 changed files with 6 additions and 2 deletions

View File

@ -278,7 +278,8 @@ public class RedundantModifierCheck
checkFinal = checkFinal || classModifiers.branchContains(TokenTypes.FINAL);
parent = null;
}
else if (parent.getType() == TokenTypes.LITERAL_NEW) {
else if (parent.getType() == TokenTypes.LITERAL_NEW
|| parent.getType() == TokenTypes.ENUM_CONSTANT_DEF) {
checkFinal = true;
parent = null;
}

View File

@ -227,7 +227,10 @@ public class RedundantModifierCheckTest
@Test
public void testEnumMethods() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(RedundantModifierCheck.class);
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
final String[] expected = {
"7:16: " + getCheckMessage(MSG_KEY, "final"),
"22:16: " + getCheckMessage(MSG_KEY, "final"),
};
verify(checkConfig, getPath("InputFinalInEnumMethods.java"), expected);
}
}