@@ -5435,10 +5435,30 @@ static void skipAttribute(Parser &P) {
54355435
54365436bool Parser::isStartOfSwiftDecl (bool allowPoundIfAttributes,
54375437 bool hadAttrsOrModifiers) {
5438+ const bool isTopLevelLibrary = (SF.Kind == SourceFileKind::Library) ||
5439+ (SF.Kind == SourceFileKind::Interface) ||
5440+ (SF.Kind == SourceFileKind::SIL);
54385441 if (Tok.is (tok::at_sign) && peekToken ().is (tok::kw_rethrows)) {
54395442 // @rethrows does not follow the general rule of @<identifier> so
54405443 // it is needed to short circuit this else there will be an infinite
54415444 // 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 );
54425462 } else if (!isKeywordPossibleDeclStart (Context.LangOpts , Tok)) {
54435463 // If this is obviously not the start of a decl, then we're done.
54445464 return false ;
0 commit comments