Fix #3698 - Error resolving Symbol Table
This commit is contained in:
parent
72c4bbb31d
commit
f838b183bf
@ -59,10 +59,12 @@ public class NameFinder {
|
||||
if (node instanceof ASTPrimarySuffix) {
|
||||
ASTPrimarySuffix suffix = (ASTPrimarySuffix) node;
|
||||
if (suffix.isArguments()) {
|
||||
JavaNameOccurrence occurrence = names.get(names.size() - 1);
|
||||
occurrence.setIsMethodOrConstructorInvocation();
|
||||
ASTArguments args = (ASTArguments) ((ASTPrimarySuffix) node).getChild(0);
|
||||
occurrence.setArgumentCount(args.size());
|
||||
if (!names.isEmpty()) {
|
||||
JavaNameOccurrence occurrence = names.get(names.size() - 1);
|
||||
occurrence.setIsMethodOrConstructorInvocation();
|
||||
ASTArguments args = (ASTArguments) ((ASTPrimarySuffix) node).getChild(0);
|
||||
occurrence.setArgumentCount(args.size());
|
||||
}
|
||||
} else if (suffix.getNumChildren() == 1 && suffix.getChild(0) instanceof ASTMemberSelector) {
|
||||
ASTMemberSelector member = (ASTMemberSelector) suffix.getChild(0);
|
||||
if (member.getNumChildren() == 1 && member.getChild(0) instanceof ASTMethodReference) {
|
||||
|
@ -16,6 +16,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTLambdaExpression;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTPrimaryExpression;
|
||||
import net.sourceforge.pmd.lang.symboltable.NameDeclaration;
|
||||
|
||||
public class ScopeAndDeclarationFinderTest extends BaseNonParserTest {
|
||||
@ -72,4 +73,19 @@ public class ScopeAndDeclarationFinderTest extends BaseNonParserTest {
|
||||
ClassScope scope2 = methods.get(1).getScope().getEnclosingScope(ClassScope.class);
|
||||
Assert.assertSame(scope1, scope2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testSuperCtor() {
|
||||
// #3698 -- test that parsing does not throw (this executes the symbol pass)
|
||||
ASTCompilationUnit acu = parseCode("class Foo { Object rs; class Inner { \n"
|
||||
+ " Inner(Object phase) {\n"
|
||||
+ " (rs.deferredAttr).super(AttrMode.SPECULATIVE, msym, phase);\n"
|
||||
+ " } } }");
|
||||
ASTClassOrInterfaceDeclaration inner = acu.getFirstDescendantOfType(ASTClassOrInterfaceDeclaration.class)
|
||||
.getFirstDescendantOfType(ASTClassOrInterfaceDeclaration.class);
|
||||
Assert.assertEquals(5, inner.findDescendantsOfType(ASTPrimaryExpression.class).size());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user