Skip to content

Commit 11208ee

Browse files
authored
Merge pull request #74164 from slavapestov/fix-rdar129255769
AST: Fix request cycle with local lazy properties
2 parents da6f015 + dd7f1fd commit 11208ee

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/AST/UnqualifiedLookup.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,15 @@ static bool implicitSelfReferenceIsUnwrapped(const ValueDecl *selfDecl) {
352352
}
353353

354354
ValueDecl *UnqualifiedLookupFactory::lookupBaseDecl(const DeclContext *baseDC) const {
355+
// If the member was not in local context, we're not going to need the
356+
// 'self' declaration, so skip all this work to avoid request cycles.
357+
if (!baseDC->isLocalContext())
358+
return nullptr;
359+
360+
// If we're only interested in type declarations, we can also skip everything.
361+
if (isOriginallyTypeLookup)
362+
return nullptr;
363+
355364
// Perform an unqualified lookup for the base decl of this result. This
356365
// handles cases where self was rebound (e.g. `guard let self = self`)
357366
// earlier in this closure or some outer closure.

test/decl/var/lazy_properties.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,15 @@ struct PropertyWrapperContainer {
219219
_ = $__lazy_storage_$_foo // This is okay.
220220
}
221221
}
222+
223+
// rdar://problem/129255769
224+
struct X {
225+
struct Y { }
226+
227+
func f() {
228+
_ = {
229+
lazy var x: [Y] = []
230+
_ = Y()
231+
}
232+
}
233+
}

0 commit comments

Comments
 (0)