Skip to content

Commit 91ee299

Browse files
PR-2107 follow-up: avoid sharing AST nodes (eclipse-jdt#4127)
PR 2107 copies a reference to an AST node (local declaration) which implies that the same node will be visited twice for all phases. Let's play safe and move instead of copy in order to maintain that AST is indeed a tree :)
1 parent 3a87bcb commit 91ee299

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ protected void attachOrphanCompletionNode(){
697697
// if (a instanceof List l) { l.is| Object // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2106
698698
if (ifStatement.condition instanceof InstanceOfExpression iof && iof.pattern instanceof TypePattern pattern) {
699699
this.currentElement.add(pattern.local, 0);
700+
iof.pattern = null;
700701
}
701702
this.currentElement = this.currentElement.add(ifStatement, 0);
702703
}

0 commit comments

Comments
 (0)