@@ -3519,10 +3519,12 @@ static void diagnoseOperatorFixityAttributes(Parser &P,
35193519static unsigned skipUntilMatchingRBrace (Parser &P,
35203520 bool &HasPoundDirective,
35213521 bool &HasOperatorDeclarations,
3522- bool &HasNestedClassDeclarations) {
3522+ bool &HasNestedClassDeclarations,
3523+ bool &HasNestedTypeDeclarations) {
35233524 HasPoundDirective = false ;
35243525 HasOperatorDeclarations = false ;
35253526 HasNestedClassDeclarations = false ;
3527+ HasNestedTypeDeclarations = false ;
35263528
35273529 unsigned OpenBraces = 1 ;
35283530
@@ -3541,6 +3543,10 @@ static unsigned skipUntilMatchingRBrace(Parser &P,
35413543
35423544 HasPoundDirective |= P.Tok .isAny (tok::pound_sourceLocation, tok::pound_line,
35433545 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+
35443550 if (P.consumeIf (tok::l_brace)) {
35453551 ++OpenBraces;
35463552 continue ;
@@ -4819,10 +4825,12 @@ bool Parser::canDelayMemberDeclParsing(bool &HasOperatorDeclarations,
48194825 // we can't lazily parse.
48204826 BacktrackingScope BackTrack (*this );
48214827 bool HasPoundDirective;
4828+ bool HasNestedTypeDeclarations;
48224829 skipUntilMatchingRBrace (*this ,
48234830 HasPoundDirective,
48244831 HasOperatorDeclarations,
4825- HasNestedClassDeclarations);
4832+ HasNestedClassDeclarations,
4833+ HasNestedTypeDeclarations);
48264834 if (!HasPoundDirective)
48274835 BackTrack.cancelBacktrack ();
48284836 return !BackTrack.willBacktrack ();
@@ -5510,7 +5518,7 @@ static ParameterList *parseOptionalAccessorArgument(SourceLoc SpecifierLoc,
55105518 return ParameterList::create (P.Context , StartLoc, param, EndLoc);
55115519}
55125520
5513- bool Parser::skipBracedBlock () {
5521+ bool Parser::skipBracedBlock (bool &HasNestedTypeDeclarations ) {
55145522 SyntaxParsingContext disabled (SyntaxContext);
55155523 SyntaxContext->disable ();
55165524 consumeToken (tok::l_brace);
@@ -5524,7 +5532,8 @@ bool Parser::skipBracedBlock() {
55245532 unsigned OpenBraces = skipUntilMatchingRBrace (*this ,
55255533 HasPoundDirectives,
55265534 HasOperatorDeclarations,
5527- HasNestedClassDeclarations);
5535+ HasNestedClassDeclarations,
5536+ HasNestedTypeDeclarations);
55285537 if (consumeIf (tok::r_brace))
55295538 --OpenBraces;
55305539 return OpenBraces != 0 ;
@@ -6420,11 +6429,13 @@ void Parser::consumeAbstractFunctionBody(AbstractFunctionDecl *AFD,
64206429 BodyRange.Start = Tok.getLoc ();
64216430
64226431 // Advance the parser to the end of the block; '{' ... '}'.
6423- skipBracedBlock ();
6432+ bool HasNestedTypeDeclarations;
6433+ skipBracedBlock (HasNestedTypeDeclarations);
64246434
64256435 BodyRange.End = PreviousLoc;
64266436
64276437 AFD->setBodyDelayed (BodyRange);
6438+ AFD->setHasNestedTypeDeclarations (HasNestedTypeDeclarations);
64286439
64296440 if (isCodeCompletionFirstPass () &&
64306441 SourceMgr.rangeContainsCodeCompletionLoc (BodyRange)) {
0 commit comments