Skip to content

Commit 836a8ee

Browse files
authored
Merge pull request swiftlang#34164 from slavapestov/fix-local-property-wrappers
AST: Find local property wrappers in ASTScope::lookupLocalDecls()
2 parents 95f1bd3 + 554e0f9 commit 836a8ee

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

lib/AST/UnqualifiedLookup.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,10 +784,17 @@ class ASTScopeDeclConsumerForLocalLookup
784784
bool consume(ArrayRef<ValueDecl *> values,
785785
NullablePtr<DeclContext> baseDC) override {
786786
for (auto *value: values) {
787-
if (!value->getName().matchesRef(name))
788-
continue;
787+
if (auto *varDecl = dyn_cast<VarDecl>(value)) {
788+
// Check if the name matches any auxiliary decls not in the AST
789+
varDecl->visitAuxiliaryDecls([&](VarDecl *auxiliaryVar) {
790+
if (name.isSimpleName(auxiliaryVar->getName())) {
791+
results.push_back(auxiliaryVar);
792+
}
793+
});
794+
}
789795

790-
results.push_back(value);
796+
if (value->getName().matchesRef(name))
797+
results.push_back(value);
791798
}
792799

793800
return (!stopAfterInnermostBraceStmt && !results.empty());

lib/Sema/PreCheckExpr.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -357,17 +357,16 @@ Expr *TypeChecker::resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE,
357357
SmallVector<ValueDecl*, 4> ResultValues;
358358

359359
auto &Context = DC->getASTContext();
360-
if (Context.LangOpts.DisableParserLookup) {
361-
// First, look for a local binding in scope.
362-
if (Loc.isValid() && !Name.isOperator()) {
363-
SmallVector<ValueDecl *, 2> localDecls;
364-
ASTScope::lookupLocalDecls(DC->getParentSourceFile(),
365-
Name.getFullName(), Loc,
366-
/*stopAfterInnermostBraceStmt=*/false,
367-
ResultValues);
368-
for (auto *localDecl : ResultValues) {
369-
Lookup.add(LookupResultEntry(localDecl), /*isOuter=*/false);
370-
}
360+
361+
// First, look for a local binding in scope.
362+
if (Loc.isValid() && !Name.isOperator()) {
363+
SmallVector<ValueDecl *, 2> localDecls;
364+
ASTScope::lookupLocalDecls(DC->getParentSourceFile(),
365+
Name.getFullName(), Loc,
366+
/*stopAfterInnermostBraceStmt=*/false,
367+
ResultValues);
368+
for (auto *localDecl : ResultValues) {
369+
Lookup.add(LookupResultEntry(localDecl), /*isOuter=*/false);
371370
}
372371
}
373372

0 commit comments

Comments
 (0)