Fix #3698 - Error resolving Symbol Table
This commit is contained in:
@ -59,10 +59,12 @@ public class NameFinder {
|
|||||||
if (node instanceof ASTPrimarySuffix) {
|
if (node instanceof ASTPrimarySuffix) {
|
||||||
ASTPrimarySuffix suffix = (ASTPrimarySuffix) node;
|
ASTPrimarySuffix suffix = (ASTPrimarySuffix) node;
|
||||||
if (suffix.isArguments()) {
|
if (suffix.isArguments()) {
|
||||||
|
if (!names.isEmpty()) {
|
||||||
JavaNameOccurrence occurrence = names.get(names.size() - 1);
|
JavaNameOccurrence occurrence = names.get(names.size() - 1);
|
||||||
occurrence.setIsMethodOrConstructorInvocation();
|
occurrence.setIsMethodOrConstructorInvocation();
|
||||||
ASTArguments args = (ASTArguments) ((ASTPrimarySuffix) node).getChild(0);
|
ASTArguments args = (ASTArguments) ((ASTPrimarySuffix) node).getChild(0);
|
||||||
occurrence.setArgumentCount(args.size());
|
occurrence.setArgumentCount(args.size());
|
||||||
|
}
|
||||||
} else if (suffix.getNumChildren() == 1 && suffix.getChild(0) instanceof ASTMemberSelector) {
|
} else if (suffix.getNumChildren() == 1 && suffix.getChild(0) instanceof ASTMemberSelector) {
|
||||||
ASTMemberSelector member = (ASTMemberSelector) suffix.getChild(0);
|
ASTMemberSelector member = (ASTMemberSelector) suffix.getChild(0);
|
||||||
if (member.getNumChildren() == 1 && member.getChild(0) instanceof ASTMethodReference) {
|
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.ASTCompilationUnit;
|
||||||
import net.sourceforge.pmd.lang.java.ast.ASTLambdaExpression;
|
import net.sourceforge.pmd.lang.java.ast.ASTLambdaExpression;
|
||||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator;
|
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator;
|
||||||
|
import net.sourceforge.pmd.lang.java.ast.ASTPrimaryExpression;
|
||||||
import net.sourceforge.pmd.lang.symboltable.NameDeclaration;
|
import net.sourceforge.pmd.lang.symboltable.NameDeclaration;
|
||||||
|
|
||||||
public class ScopeAndDeclarationFinderTest extends BaseNonParserTest {
|
public class ScopeAndDeclarationFinderTest extends BaseNonParserTest {
|
||||||
@ -72,4 +73,19 @@ public class ScopeAndDeclarationFinderTest extends BaseNonParserTest {
|
|||||||
ClassScope scope2 = methods.get(1).getScope().getEnclosingScope(ClassScope.class);
|
ClassScope scope2 = methods.get(1).getScope().getEnclosingScope(ClassScope.class);
|
||||||
Assert.assertSame(scope1, scope2);
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user