mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Ensure that we wire up *all* custom attribute initializer contexts
Thank you again, Rintaro
This commit is contained in:
@@ -8580,20 +8580,12 @@ Parser::parseDeclVar(ParseDeclOptions Flags,
|
||||
|
||||
// Parse an initializer if present.
|
||||
if (Tok.is(tok::equal)) {
|
||||
// If we're not in a local context, we'll need a context to parse initializers
|
||||
// into (should we have one). This happens for properties and global
|
||||
// variables in libraries.
|
||||
|
||||
// If we have no local context to parse the initial value into, create one
|
||||
// for the PBD we'll eventually create. This allows us to have reasonable
|
||||
// DeclContexts for any closures that may live inside of initializers.
|
||||
if (!CurDeclContext->isLocalContext() && !topLevelDecl) {
|
||||
assert(!initContext && "There cannot be an init context yet");
|
||||
initContext = PatternBindingInitializer::create(CurDeclContext);
|
||||
|
||||
if (auto attributeInit = Attributes.findCustomAttributeInitializer()) {
|
||||
attributeInit->setEnclosingInitializer(initContext);
|
||||
}
|
||||
}
|
||||
|
||||
// If we're using a local context (either a TopLevelCodeDecl or a
|
||||
|
||||
Reference in New Issue
Block a user