Skip to content

Commit 8bbb1b1

Browse files
cirrasfourls
authored andcommitted
Fix type resolution failures on property/routine attribute lists
Specifically... - `PropertyNameDeclaration::attributeTypes` were always unknown. - `RoutineNameDeclaration::attributeTypes` were unknown for implementation-local routines.
1 parent 5c92eb7 commit 8bbb1b1

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
### Fixed
2727

2828
- Name resolution failures on generic routine invocations where later type parameters are constrained by earlier type parameters.
29+
- Type resolution failures on property attribute lists.
30+
- Type resolution failures on implementation-local routine attribute lists.
2931
- Type resolution failures on `as` casts where the type is returned from a routine invocation.
3032
- Inaccurate type resolution when calling a constructor on a class reference type.
3133
- Grammar ambiguity causing attributes to be misinterpreted as interface GUIDs.

delphi-frontend/src/main/java/au/com/integradev/delphi/antlr/ast/visitors/SymbolTableVisitor.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import javax.annotation.Nullable;
6464
import org.sonar.plugins.communitydelphi.api.ast.AnonymousMethodNode;
6565
import org.sonar.plugins.communitydelphi.api.ast.ArrayConstructorNode;
66+
import org.sonar.plugins.communitydelphi.api.ast.AttributeListNode;
6667
import org.sonar.plugins.communitydelphi.api.ast.AttributeNode;
6768
import org.sonar.plugins.communitydelphi.api.ast.CaseItemStatementNode;
6869
import org.sonar.plugins.communitydelphi.api.ast.CaseStatementNode;
@@ -111,6 +112,7 @@
111112
import org.sonar.plugins.communitydelphi.api.ast.RepeatStatementNode;
112113
import org.sonar.plugins.communitydelphi.api.ast.RoutineBodyNode;
113114
import org.sonar.plugins.communitydelphi.api.ast.RoutineDeclarationNode;
115+
import org.sonar.plugins.communitydelphi.api.ast.RoutineHeadingNode;
114116
import org.sonar.plugins.communitydelphi.api.ast.RoutineImplementationNode;
115117
import org.sonar.plugins.communitydelphi.api.ast.RoutineNameNode;
116118
import org.sonar.plugins.communitydelphi.api.ast.RoutineNode;
@@ -825,6 +827,23 @@ public Data visit(PrimaryExpressionNode node, Data data) {
825827
return data;
826828
}
827829

830+
@Override
831+
public Data visit(AttributeListNode node, Data data) {
832+
DelphiNode parent = node.getParent();
833+
834+
if (parent instanceof PropertyNode) {
835+
// Already resolved by the PropertyNode visit.
836+
return data;
837+
}
838+
839+
if (parent instanceof RoutineHeadingNode) {
840+
// Already resolved by the RoutineNode visit.
841+
return data;
842+
}
843+
844+
return DelphiParserVisitor.super.visit(node, data);
845+
}
846+
828847
@Override
829848
public Data visit(AttributeNode node, Data data) {
830849
data.nameResolutionHelper.resolve(node);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ public void resolve(NameReferenceNode reference) {
167167
resolver.addToSymbolTable();
168168
}
169169

170+
private void resolve(@Nullable AttributeListNode attributeList) {
171+
if (attributeList != null) {
172+
attributeList.getAttributes().forEach(this::resolve);
173+
}
174+
}
175+
170176
public void resolve(AttributeNode attribute) {
171177
NameResolver resolver = createNameResolver();
172178
resolver.readAttribute(attribute);
@@ -255,6 +261,7 @@ public void resolve(MethodResolutionClauseNode resolutionClause) {
255261
}
256262

257263
public void resolve(PropertyNode property) {
264+
resolve(property.getAttributeList());
258265
resolve(property.getParameterListNode());
259266

260267
TypeNode type = property.getTypeNode();
@@ -427,6 +434,7 @@ private static boolean isBareInterfaceRoutineReference(
427434
}
428435

429436
private void resolveRoutine(RoutineNode routine) {
437+
resolve(routine.getRoutineHeading().getAttributeList());
430438
SearchMode previousSearchMode = searchMode;
431439
try {
432440
searchMode = SearchMode.ROUTINE_HEADING;

0 commit comments

Comments
 (0)