Fixed IllegalInstantiationCheck, so it won't recognize a constructor reference (Java8) as instantiation.

Also added a test for it.
This commit is contained in:
Ryszard Wiśniewski 2014-08-10 02:13:14 +02:00 committed by Ilja Dubinin
parent a75e6d670f
commit 839cd1b10e
2 changed files with 14 additions and 0 deletions

View File

@ -190,6 +190,9 @@ public class IllegalInstantiationCheck
*/
private void processLiteralNew(DetailAST aAST)
{
if (aAST.getParent().getType() == TokenTypes.METHOD_REF) {
return;
}
mInstantiations.add(aAST);
}

View File

@ -48,4 +48,15 @@ public class IllegalInstantiationCheckTest
};
verify(checkConfig, getPath("InputSemantic.java"), expected);
}
@Test
public void testJava8() throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(IllegalInstantiationCheck.class);
final String[] expected = {};
verify(checkConfig,
getPath("grammars/java8/InputMethodReferencesTest2.java"),
expected);
}
}