Skip to content

Commit 32e68c7

Browse files
committed
Factor out synthesizePropertyWrapperStorageWrapperProperties()
1 parent 2564a6e commit 32e68c7

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

lib/Sema/LookupVisibleDecls.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ static void collectVisibleMemberDecls(const DeclContext *CurrDC, LookupState LS,
205205
}
206206
}
207207

208+
static void
209+
synthesizePropertyWrapperStorageWrapperProperties(IterableDeclContext *IDC);
210+
208211
/// Lookup members in extensions of \p LookupType, using \p BaseType as the
209212
/// underlying type when checking any constraints on the extensions.
210213
static void doGlobalExtensionLookup(Type BaseType,
@@ -222,6 +225,8 @@ static void doGlobalExtensionLookup(Type BaseType,
222225
extension)), false))
223226
continue;
224227

228+
synthesizePropertyWrapperStorageWrapperProperties(extension);
229+
225230
collectVisibleMemberDecls(CurrDC, LS, BaseType, extension, FoundDecls);
226231
}
227232

@@ -476,6 +481,20 @@ static void
476481
lookupTypeMembers(BaseTy, PT, Consumer, CurrDC, LS, Reason);
477482
}
478483

484+
// Generate '$' and '_' prefixed variables that have attached property
485+
// wrappers.
486+
static void
487+
synthesizePropertyWrapperStorageWrapperProperties(IterableDeclContext *IDC) {
488+
auto SF = IDC->getDecl()->getDeclContext()->getParentSourceFile();
489+
if (!SF || SF->Kind == SourceFileKind::Interface)
490+
return;
491+
492+
for (auto Member : IDC->getMembers())
493+
if (auto var = dyn_cast<VarDecl>(Member))
494+
if (var->hasAttachedPropertyWrapper())
495+
(void)var->getPropertyWrapperBackingPropertyInfo();
496+
}
497+
479498
/// Trigger synthesizing implicit member declarations to make them "visible".
480499
static void synthesizeMemberDeclsForLookup(NominalTypeDecl *NTD,
481500
const DeclContext *DC) {
@@ -505,22 +524,7 @@ static void synthesizeMemberDeclsForLookup(NominalTypeDecl *NTD,
505524
}
506525
}
507526

508-
// Generate '$' and '_' prefixed variables that have attached property
509-
// wrappers.
510-
auto synthesizePropertyWrappers = [](IterableDeclContext *IDC) {
511-
for (auto Member : IDC->getMembers()) {
512-
if (auto var = dyn_cast<VarDecl>(Member)) {
513-
if (var->hasAttachedPropertyWrapper()) {
514-
auto sourceFile = var->getDeclContext()->getParentSourceFile();
515-
if (sourceFile && sourceFile->Kind != SourceFileKind::Interface)
516-
(void)var->getPropertyWrapperBackingPropertyInfo();
517-
}
518-
}
519-
}
520-
};
521-
synthesizePropertyWrappers(NTD);
522-
for (auto ED : NTD->getExtensions())
523-
synthesizePropertyWrappers(ED);
527+
synthesizePropertyWrapperStorageWrapperProperties(NTD);
524528
}
525529

526530
static void lookupVisibleMemberDeclsImpl(

0 commit comments

Comments
 (0)