Skip to content

Commit 9e373a2

Browse files
committed
[Name Lookup] Remove property wrapper name lookup flags and generalize
unqualified lookup of auxiliary decl names.
1 parent 2a67c65 commit 9e373a2

File tree

5 files changed

+11
-27
lines changed

5 files changed

+11
-27
lines changed

include/swift/AST/NameLookup.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ enum class UnqualifiedLookupFlags {
225225
/// This lookup should include results from outside the innermost scope with
226226
/// results.
227227
IncludeOuterResults = 1 << 4,
228-
/// Includes property wrapper name lookup results
229-
IncludePropertyWrapperResults = 1 << 5,
230228
};
231229

232230
using UnqualifiedLookupOptions = OptionSet<UnqualifiedLookupFlags>;

lib/AST/UnqualifiedLookup.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -605,25 +605,19 @@ bool ASTScopeDeclConsumerForUnqualifiedLookup::consume(
605605

606606
auto fullName = factory.Name.getFullName();
607607
if (!value->getName().matchesRef(fullName)) {
608-
if (!factory.options.contains(UnqualifiedLookupFlags::IncludePropertyWrapperResults))
609-
continue;
610-
611-
auto *varDecl = dyn_cast<VarDecl>(value);
612-
if (!varDecl || !varDecl->hasAttachedPropertyWrapper())
613-
continue;
614-
615-
auto wrapperInfo = varDecl->getPropertyWrapperBackingPropertyInfo();
616-
if (!wrapperInfo)
617-
continue;
608+
bool foundMatch = false;
609+
if (auto *varDecl = dyn_cast<VarDecl>(value)) {
610+
// Check if the name matches any auxiliary decls not in the AST
611+
varDecl->visitAuxiliaryDecls([&](VarDecl *auxiliaryVar) {
612+
if (auxiliaryVar->ValueDecl::getName().matchesRef(fullName)) {
613+
value = auxiliaryVar;
614+
foundMatch = true;
615+
}
616+
});
617+
}
618618

619-
if (wrapperInfo.backingVar->ValueDecl::getName().matchesRef(fullName)) {
620-
value = wrapperInfo.backingVar;
621-
} else if (wrapperInfo.projectionVar &&
622-
wrapperInfo.projectionVar->ValueDecl::getName().matchesRef(fullName)) {
623-
value = wrapperInfo.projectionVar;
624-
} else {
619+
if (!foundMatch)
625620
continue;
626-
}
627621
}
628622

629623
// In order to preserve the behavior of the existing context-based lookup,

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,6 @@ Expr *TypeChecker::resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE,
538538
// name/module qualifier to access top-level name.
539539
lookupOptions |= NameLookupFlags::IncludeOuterResults;
540540

541-
// Include property wrapper results in case we have a reference to a backing
542-
// property wrapper or projected value
543-
lookupOptions |= NameLookupFlags::IncludePropertyWrapperResults;
544-
545541
if (Loc.isInvalid())
546542
DC = DC->getModuleScopeContext();
547543

lib/Sema/TypeCheckNameLookup.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ convertToUnqualifiedLookupOptions(NameLookupOptions options) {
211211
newOptions |= UnqualifiedLookupFlags::IgnoreAccessControl;
212212
if (options.contains(NameLookupFlags::IncludeOuterResults))
213213
newOptions |= UnqualifiedLookupFlags::IncludeOuterResults;
214-
if (options.contains(NameLookupFlags::IncludePropertyWrapperResults))
215-
newOptions |= UnqualifiedLookupFlags::IncludePropertyWrapperResults;
216214

217215
return newOptions;
218216
}

lib/Sema/TypeChecker.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ enum class NameLookupFlags {
192192
/// Whether to include results from outside the innermost scope that has a
193193
/// result.
194194
IncludeOuterResults = 1 << 1,
195-
/// Whether to consider property wrapper names
196-
IncludePropertyWrapperResults = 1 << 2,
197195
};
198196

199197
/// A set of options that control name lookup.

0 commit comments

Comments
 (0)