@@ -5680,14 +5680,16 @@ ParserStatus Parser::parseGetSet(ParseDeclOptions Flags,
5680
5680
5681
5681
// / Parse the brace-enclosed getter and setter for a variable.
5682
5682
ParserResult<VarDecl>
5683
- Parser::parseDeclVarGetSet (Pattern *pattern , ParseDeclOptions Flags,
5683
+ Parser::parseDeclVarGetSet (PatternBindingEntry &entry , ParseDeclOptions Flags,
5684
5684
SourceLoc StaticLoc,
5685
5685
StaticSpellingKind StaticSpelling,
5686
5686
SourceLoc VarLoc, bool hasInitializer,
5687
5687
const DeclAttributes &Attributes,
5688
5688
SmallVectorImpl<Decl *> &Decls) {
5689
5689
bool Invalid = false ;
5690
-
5690
+
5691
+ auto *pattern = entry.getPattern ();
5692
+
5691
5693
// The grammar syntactically requires a simple identifier for the variable
5692
5694
// name. Complain if that isn't what we got. But for recovery purposes,
5693
5695
// make an effort to look through other things anyway.
@@ -5730,22 +5732,12 @@ Parser::parseDeclVarGetSet(Pattern *pattern, ParseDeclOptions Flags,
5730
5732
VarDecl::Introducer::Var,
5731
5733
VarLoc, Identifier (),
5732
5734
CurDeclContext);
5733
- storage->setImplicit (true );
5734
5735
storage->setInvalid ();
5735
5736
5736
- Pattern * pattern =
5737
+ pattern =
5737
5738
TypedPattern::createImplicit (Context, new (Context) NamedPattern (storage),
5738
5739
ErrorType::get (Context));
5739
- PatternBindingEntry entry (pattern, /* EqualLoc*/ SourceLoc (),
5740
- /* Init*/ nullptr , /* InitContext*/ nullptr );
5741
- auto binding = PatternBindingDecl::create (Context, StaticLoc,
5742
- StaticSpelling,
5743
- VarLoc, entry, CurDeclContext);
5744
- binding->setInvalid ();
5745
- storage->setParentPatternBinding (binding);
5746
-
5747
- Decls.push_back (binding);
5748
- Decls.push_back (storage);
5740
+ entry.setPattern (pattern);
5749
5741
}
5750
5742
5751
5743
// Parse getter and setter.
@@ -6157,7 +6149,8 @@ Parser::parseDeclVar(ParseDeclOptions Flags,
6157
6149
if (Tok.is (tok::l_brace)) {
6158
6150
HasAccessors = true ;
6159
6151
auto boundVar =
6160
- parseDeclVarGetSet (pattern, Flags, StaticLoc, StaticSpelling, VarLoc,
6152
+ parseDeclVarGetSet (PBDEntries.back (),
6153
+ Flags, StaticLoc, StaticSpelling, VarLoc,
6161
6154
PatternInit != nullptr , Attributes, Decls);
6162
6155
if (boundVar.hasCodeCompletion ())
6163
6156
return makeResult (makeParserCodeCompletionStatus ());
0 commit comments