@@ -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 ;
@@ -4819,10 +4825,12 @@ bool Parser::canDelayMemberDeclParsing(bool &HasOperatorDeclarations,
4819
4825
// we can't lazily parse.
4820
4826
BacktrackingScope BackTrack (*this );
4821
4827
bool HasPoundDirective;
4828
+ bool HasNestedTypeDeclarations;
4822
4829
skipUntilMatchingRBrace (*this ,
4823
4830
HasPoundDirective,
4824
4831
HasOperatorDeclarations,
4825
- HasNestedClassDeclarations);
4832
+ HasNestedClassDeclarations,
4833
+ HasNestedTypeDeclarations);
4826
4834
if (!HasPoundDirective)
4827
4835
BackTrack.cancelBacktrack ();
4828
4836
return !BackTrack.willBacktrack ();
@@ -5510,7 +5518,7 @@ static ParameterList *parseOptionalAccessorArgument(SourceLoc SpecifierLoc,
5510
5518
return ParameterList::create (P.Context , StartLoc, param, EndLoc);
5511
5519
}
5512
5520
5513
- bool Parser::skipBracedBlock () {
5521
+ bool Parser::skipBracedBlock (bool &HasNestedTypeDeclarations ) {
5514
5522
SyntaxParsingContext disabled (SyntaxContext);
5515
5523
SyntaxContext->disable ();
5516
5524
consumeToken (tok::l_brace);
@@ -5524,7 +5532,8 @@ bool Parser::skipBracedBlock() {
5524
5532
unsigned OpenBraces = skipUntilMatchingRBrace (*this ,
5525
5533
HasPoundDirectives,
5526
5534
HasOperatorDeclarations,
5527
- HasNestedClassDeclarations);
5535
+ HasNestedClassDeclarations,
5536
+ HasNestedTypeDeclarations);
5528
5537
if (consumeIf (tok::r_brace))
5529
5538
--OpenBraces;
5530
5539
return OpenBraces != 0 ;
@@ -6420,11 +6429,13 @@ void Parser::consumeAbstractFunctionBody(AbstractFunctionDecl *AFD,
6420
6429
BodyRange.Start = Tok.getLoc ();
6421
6430
6422
6431
// Advance the parser to the end of the block; '{' ... '}'.
6423
- skipBracedBlock ();
6432
+ bool HasNestedTypeDeclarations;
6433
+ skipBracedBlock (HasNestedTypeDeclarations);
6424
6434
6425
6435
BodyRange.End = PreviousLoc;
6426
6436
6427
6437
AFD->setBodyDelayed (BodyRange);
6438
+ AFD->setHasNestedTypeDeclarations (HasNestedTypeDeclarations);
6428
6439
6429
6440
if (isCodeCompletionFirstPass () &&
6430
6441
SourceMgr.rangeContainsCodeCompletionLoc (BodyRange)) {
0 commit comments