#1333 Error while processing Java file with Lambda expressions
This commit is contained in:
@ -373,7 +373,8 @@ public class ClassScope extends AbstractJavaScope {
|
||||
Map<VariableNameDeclaration, List<NameOccurrence>> vars = s
|
||||
.getDeclarations(VariableNameDeclaration.class);
|
||||
for (VariableNameDeclaration d : vars.keySet()) {
|
||||
if (d.getImage().equals(name.getImage())) {
|
||||
// in case of simple lambda expression, the type might be unknown
|
||||
if (d.getImage().equals(name.getImage()) && d.getTypeImage() != null) {
|
||||
String typeName = d.getTypeImage();
|
||||
typeName = qualifyTypeName(typeName);
|
||||
Node declaringNode = qualifiedTypeNames.get(typeName);
|
||||
|
@ -65,6 +65,28 @@ public class ParserCornersTest extends ParserTst {
|
||||
parseJava18(test18);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for https://sourceforge.net/p/pmd/bugs/1333/
|
||||
*/
|
||||
@Test
|
||||
public void testLambdaBug1333() {
|
||||
parseJava18("final class Bug1333 {\n" +
|
||||
" private static final Logger LOG = LoggerFactory.getLogger(Foo.class);\n" +
|
||||
"\n" +
|
||||
" public void deleteDirectoriesByNamePattern() {\n" +
|
||||
" delete(path -> deleteDirectory(path));\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" private void delete(Consumer<? super String> consumer) {\n" +
|
||||
" LOG.debug(consumer.toString());\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" private void deleteDirectory(String path) {\n" +
|
||||
" LOG.debug(path);\n" +
|
||||
" }\n" +
|
||||
"}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleExceptionCatching() {
|
||||
String code = "public class Foo { public void bar() { "
|
||||
|
Reference in New Issue
Block a user