Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions config/pitest-suppressions/pitest-coding-2-suppressions.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,15 @@ private TypeDeclDesc getSuperClassOfAnonInnerClass(DetailAST literalNewAst) {
*
* @param obtainedClass super class of the anon inner class
* @param variablesStack stack of all the relevant variables in the scope
* @param literalNewAst ast node of type {@link TokenTypes#LITERAL_NEW}
* @param objBlockAst ast node of type {@link TokenTypes#OBJBLOCK}
*/
private void modifyVariablesStack(TypeDeclDesc obtainedClass,
Deque<VariableDesc> variablesStack,
DetailAST literalNewAst) {
DetailAST objBlockAst) {
if (obtainedClass != null) {
final Deque<VariableDesc> instAndClassVarDeque = typeDeclAstToTypeDeclDesc
.get(obtainedClass.getTypeDeclAst())
.getUpdatedCopyOfVarStack(literalNewAst);
.getUpdatedCopyOfVarStack(objBlockAst);
instAndClassVarDeque.forEach(variablesStack::push);
}
}
Expand Down Expand Up @@ -640,9 +640,12 @@ else if (type == TokenTypes.VARIABLE_DEF) {
else if (type == TokenTypes.IDENT) {
visitIdentToken(ast, variablesStack);
}
else if (isInsideLocalAnonInnerClass(ast)) {
final TypeDeclDesc obtainedClass = getSuperClassOfAnonInnerClass(ast);
modifyVariablesStack(obtainedClass, variablesStack, ast);
else {
final DetailAST lastChild = ast.getLastChild();
if (lastChild != null && lastChild.getType() == TokenTypes.OBJBLOCK) {
final TypeDeclDesc obtainedClass = getSuperClassOfAnonInnerClass(ast);
modifyVariablesStack(obtainedClass, variablesStack, lastChild);
}
Comment on lines +644 to +648
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a quick look, this can cause problems as isInsideLocalAnonInnerClass(#) returns false for type declarations and lastChild != null && lastChild.getType() == TokenTypes.OBJBLOCK is true for type declarations.

Tests cases might not be there, but it may cause problems in stack order, etc.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about a real test case which can catch this. Could you help to come up with at least one such a case? Otherwise I don't think it's an issue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

Expand Down Expand Up @@ -958,15 +961,14 @@ public DetailAST getTypeDeclAst() {
/**
* Get the copy of variables in instanceAndClassVar stack with updated scope.
*
* @param literalNewAst ast node of type {@link TokenTypes#LITERAL_NEW}
* @param objBlockAst ast node of type {@link TokenTypes#OBJBLOCK}
* @return copy of variables in instanceAndClassVar stack with updated scope.
*/
public Deque<VariableDesc> getUpdatedCopyOfVarStack(DetailAST literalNewAst) {
final DetailAST updatedScope = literalNewAst.getLastChild();
public Deque<VariableDesc> getUpdatedCopyOfVarStack(DetailAST objBlockAst) {
final Deque<VariableDesc> instAndClassVarDeque = new ArrayDeque<>();
instanceAndClassVarStack.forEach(instVar -> {
final VariableDesc variableDesc = new VariableDesc(instVar.getName(),
updatedScope);
objBlockAst);
variableDesc.registerAsInstOrClassVar();
instAndClassVarDeque.push(variableDesc);
});
Expand Down