Skip to content

Commit 635b533

Browse files
cirrasfourls
authored andcommitted
Tweak isExplicitArrayConstructorInvocation function for correctness
Technically speaking, we should never be calling `NameReferenceNode::getLastName` downstream of the `readNameReference` method. It means while we're looping over each part of the name reference, we're looking at the last part of the name each time. This is a subtle correctness thing, there should be no behavior change.
1 parent 1c8e48c commit 635b533

File tree

1 file changed

+2
-2
lines changed
  • delphi-frontend/src/main/java/au/com/integradev/delphi/symbol/resolve

1 file changed

+2
-2
lines changed

delphi-frontend/src/main/java/au/com/integradev/delphi/symbol/resolve/NameResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ private void specializeDeclarations(NameOccurrence occurrence) {
656656
private boolean isExplicitArrayConstructorInvocation(NameReferenceNode reference) {
657657
return Iterables.getLast(resolvedDeclarations, null) instanceof TypeNameDeclaration
658658
&& isDynamicArrayReference(currentType)
659-
&& reference.getLastName().getImage().equalsIgnoreCase("Create");
659+
&& reference.getIdentifier().getImage().equalsIgnoreCase("Create");
660660
}
661661

662662
private static boolean isDynamicArrayReference(Type type) {
@@ -890,7 +890,7 @@ private void handleArgumentList(ArgumentListNode node) {
890890
private boolean handleExplicitArrayConstructorInvocation(ArgumentListNode node) {
891891
Node previous = node.getParent().getChild(node.getChildIndex() - 1);
892892
if (previous instanceof NameReferenceNode
893-
&& isExplicitArrayConstructorInvocation(((NameReferenceNode) previous))) {
893+
&& isExplicitArrayConstructorInvocation(((NameReferenceNode) previous).getLastName())) {
894894
updateType(((ClassReferenceType) currentType).classType());
895895
node.getArgumentNodes().stream()
896896
.map(ArgumentNode::getExpression)

0 commit comments

Comments
 (0)