Skip to content

Commit 9bee3ca

Browse files
committed
Generalize storage implementations to support generalized accessors.
The storage kind has been replaced with three separate "impl kinds", one for each of the basic access kinds (read, write, and read/write). This makes it far easier to mix-and-match implementations of different accessors, as well as subtleties like implementing both a setter and an independent read/write operation. AccessStrategy has become a bit more explicit about how exactly the access should be implemented. For example, the accessor-based kinds now carry the exact accessor intended to be used. Also, I've shifted responsibilities slightly between AccessStrategy and AccessSemantics so that AccessSemantics::Ordinary can be used except in the sorts of semantic-bypasses that accessor synthesis wants. This requires knowing the correct DC of the access when computing the access strategy; the upshot is that SILGenFunction now needs a DC. Accessor synthesis has been reworked so that only the declarations are built immediately; body synthesis can be safely delayed out of the main decl-checking path. This caused a large number of ramifications, especially for lazy properties, and greatly inflated the size of this patch. That is... really regrettable. The impetus for changing this was necessity: I needed to rework accessor synthesis to end its reliance on distinctions like Stored vs. StoredWithTrivialAccessors, and those fixes were exposing serious re-entrancy problems, and fixing that... well. Breaking the fixes apart at this point would be a serious endeavor.
1 parent aef0253 commit 9bee3ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2718
-1866
lines changed

include/swift/AST/ASTWalker.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ class ASTWalker {
201201
/// params in AbstractFunctionDecl and NominalTypeDecl.
202202
virtual bool shouldWalkIntoGenericParams() { return false; }
203203

204+
/// This method configures whether the walker should walk into the
205+
/// initializers of lazy variables. These initializers are semantically
206+
/// different from other initializers in their context and so sometimes
207+
/// should not be visited.
208+
///
209+
/// Note that visiting the body of the lazy getter will find a
210+
/// LazyInitializerExpr with the initializer as its sub-expression.
211+
/// However, ASTWalker does not walk into LazyInitializerExprs on its own.
212+
virtual bool shouldWalkIntoLazyInitializers() { return true; }
213+
204214
/// walkToParameterListPre - This method is called when first visiting a
205215
/// ParameterList, before walking into its parameters. If it returns false,
206216
/// the subtree is skipped.

0 commit comments

Comments
 (0)