@@ -5435,10 +5435,30 @@ static void skipAttribute(Parser &P) {
5435
5435
5436
5436
bool Parser::isStartOfSwiftDecl (bool allowPoundIfAttributes,
5437
5437
bool hadAttrsOrModifiers) {
5438
+ const bool isTopLevelLibrary = (SF.Kind == SourceFileKind::Library) ||
5439
+ (SF.Kind == SourceFileKind::Interface) ||
5440
+ (SF.Kind == SourceFileKind::SIL);
5438
5441
if (Tok.is (tok::at_sign) && peekToken ().is (tok::kw_rethrows)) {
5439
5442
// @rethrows does not follow the general rule of @<identifier> so
5440
5443
// it is needed to short circuit this else there will be an infinite
5441
5444
// loop on invalid attributes of just rethrows
5445
+ } else if (Context.LangOpts .hasFeature (Feature::GlobalConcurrency) &&
5446
+ (Tok.getKind () == tok::identifier) &&
5447
+ Tok.getText ().equals (" nonisolated" ) && isTopLevelLibrary &&
5448
+ !CurDeclContext->isLocalContext ()) {
5449
+ // TODO: hack to unblock proposal review by treating top-level nonisolated
5450
+ // contextual keyword like an attribute; more robust implementation pending
5451
+ BacktrackingScope backtrack (*this );
5452
+ skipAttribute (*this );
5453
+
5454
+ // If this attribute is the last element in the block,
5455
+ // consider it is a start of incomplete decl.
5456
+ if (Tok.isAny (tok::r_brace, tok::eof) ||
5457
+ (Tok.is (tok::pound_endif) && !allowPoundIfAttributes))
5458
+ return true ;
5459
+
5460
+ return isStartOfSwiftDecl (allowPoundIfAttributes,
5461
+ /* hadAttrsOrModifiers=*/ true );
5442
5462
} else if (!isKeywordPossibleDeclStart (Context.LangOpts , Tok)) {
5443
5463
// If this is obviously not the start of a decl, then we're done.
5444
5464
return false ;
0 commit comments