@@ -3519,10 +3519,12 @@ static void diagnoseOperatorFixityAttributes(Parser &P,
3519
3519
static unsigned skipUntilMatchingRBrace (Parser &P,
3520
3520
bool &HasPoundDirective,
3521
3521
bool &HasOperatorDeclarations,
3522
- bool &HasNestedClassDeclarations) {
3522
+ bool &HasNestedClassDeclarations,
3523
+ bool &HasNestedTypeDeclarations) {
3523
3524
HasPoundDirective = false ;
3524
3525
HasOperatorDeclarations = false ;
3525
3526
HasNestedClassDeclarations = false ;
3527
+ HasNestedTypeDeclarations = false ;
3526
3528
3527
3529
unsigned OpenBraces = 1 ;
3528
3530
@@ -3541,6 +3543,10 @@ static unsigned skipUntilMatchingRBrace(Parser &P,
3541
3543
3542
3544
HasPoundDirective |= P.Tok .isAny (tok::pound_sourceLocation, tok::pound_line,
3543
3545
tok::pound_if, tok::pound_else, tok::pound_endif, tok::pound_elseif);
3546
+
3547
+ HasNestedTypeDeclarations |= P.Tok .isAny (tok::kw_class, tok::kw_struct,
3548
+ tok::kw_enum);
3549
+
3544
3550
if (P.consumeIf (tok::l_brace)) {
3545
3551
++OpenBraces;
3546
3552
continue ;
@@ -4823,10 +4829,12 @@ bool Parser::canDelayMemberDeclParsing(bool &HasOperatorDeclarations,
4823
4829
// we can't lazily parse.
4824
4830
BacktrackingScope BackTrack (*this );
4825
4831
bool HasPoundDirective;
4832
+ bool HasNestedTypeDeclarations;
4826
4833
skipUntilMatchingRBrace (*this ,
4827
4834
HasPoundDirective,
4828
4835
HasOperatorDeclarations,
4829
- HasNestedClassDeclarations);
4836
+ HasNestedClassDeclarations,
4837
+ HasNestedTypeDeclarations);
4830
4838
if (!HasPoundDirective)
4831
4839
BackTrack.cancelBacktrack ();
4832
4840
return !BackTrack.willBacktrack ();
@@ -5514,7 +5522,7 @@ static ParameterList *parseOptionalAccessorArgument(SourceLoc SpecifierLoc,
5514
5522
return ParameterList::create (P.Context , StartLoc, param, EndLoc);
5515
5523
}
5516
5524
5517
- bool Parser::skipBracedBlock () {
5525
+ bool Parser::skipBracedBlock (bool &HasNestedTypeDeclarations ) {
5518
5526
SyntaxParsingContext disabled (SyntaxContext);
5519
5527
SyntaxContext->disable ();
5520
5528
consumeToken (tok::l_brace);
@@ -5528,7 +5536,8 @@ bool Parser::skipBracedBlock() {
5528
5536
unsigned OpenBraces = skipUntilMatchingRBrace (*this ,
5529
5537
HasPoundDirectives,
5530
5538
HasOperatorDeclarations,
5531
- HasNestedClassDeclarations);
5539
+ HasNestedClassDeclarations,
5540
+ HasNestedTypeDeclarations);
5532
5541
if (consumeIf (tok::r_brace))
5533
5542
--OpenBraces;
5534
5543
return OpenBraces != 0 ;
@@ -6424,11 +6433,13 @@ void Parser::consumeAbstractFunctionBody(AbstractFunctionDecl *AFD,
6424
6433
BodyRange.Start = Tok.getLoc ();
6425
6434
6426
6435
// Advance the parser to the end of the block; '{' ... '}'.
6427
- skipBracedBlock ();
6436
+ bool HasNestedTypeDeclarations;
6437
+ skipBracedBlock (HasNestedTypeDeclarations);
6428
6438
6429
6439
BodyRange.End = PreviousLoc;
6430
6440
6431
6441
AFD->setBodyDelayed (BodyRange);
6442
+ AFD->setHasNestedTypeDeclarations (HasNestedTypeDeclarations);
6432
6443
6433
6444
if (isCodeCompletionFirstPass () &&
6434
6445
SourceMgr.rangeContainsCodeCompletionLoc (BodyRange)) {
0 commit comments