Skip to content

Commit ca78a54

Browse files
committed
Fix bug where attribute names unsuffixed themselves and shadowed things
Guava's multimaps return mutable collections from `get`, and modifications to those collections are reflected in the multimap. In this case, the scenario was: - you're trying to find the declaration with attribute reference `Foo` - you search for `Foo` and get an empty collection back - you search for `FooAttribute` and add the results to that collection - the scope now has a declaration called `Foo` mapping to `FooAttribute` tl;dr mutability is evil.
1 parent 6870b14 commit ca78a54

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

delphi-frontend/src/main/java/au/com/integradev/delphi/symbol/scope/DelphiScopeImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ public Set<NameDeclaration> findDeclaration(NameOccurrence occurrence) {
318318

319319
Set<NameDeclaration> found = declarationsByName.get(occurrence.getImage());
320320
if (occurrence.isAttributeReference()) {
321+
found = new HashSet<>(found);
321322
found.addAll(declarationsByName.get(occurrence.getImage() + "Attribute"));
322323
}
323324

0 commit comments

Comments
 (0)