@@ -5184,10 +5184,30 @@ static void skipAttribute(Parser &P) {
5184
5184
5185
5185
bool Parser::isStartOfSwiftDecl (bool allowPoundIfAttributes,
5186
5186
bool hadAttrsOrModifiers) {
5187
+ const bool isTopLevelLibrary = (SF.Kind == SourceFileKind::Library) ||
5188
+ (SF.Kind == SourceFileKind::Interface) ||
5189
+ (SF.Kind == SourceFileKind::SIL);
5187
5190
if (Tok.is (tok::at_sign) && peekToken ().is (tok::kw_rethrows)) {
5188
5191
// @rethrows does not follow the general rule of @<identifier> so
5189
5192
// it is needed to short circuit this else there will be an infinite
5190
5193
// loop on invalid attributes of just rethrows
5194
+ } else if (Context.LangOpts .hasFeature (Feature::GlobalConcurrency) &&
5195
+ (Tok.getKind () == tok::identifier) &&
5196
+ Tok.getText ().equals (" nonisolated" ) && isTopLevelLibrary &&
5197
+ !CurDeclContext->isLocalContext ()) {
5198
+ // TODO: hack to unblock proposal review by treating top-level nonisolated
5199
+ // contextual keyword like an attribute; more robust implementation pending
5200
+ BacktrackingScope backtrack (*this );
5201
+ skipAttribute (*this );
5202
+
5203
+ // If this attribute is the last element in the block,
5204
+ // consider it is a start of incomplete decl.
5205
+ if (Tok.isAny (tok::r_brace, tok::eof) ||
5206
+ (Tok.is (tok::pound_endif) && !allowPoundIfAttributes))
5207
+ return true ;
5208
+
5209
+ return isStartOfSwiftDecl (allowPoundIfAttributes,
5210
+ /* hadAttrsOrModifiers=*/ true );
5191
5211
} else if (!isKeywordPossibleDeclStart (Context.LangOpts , Tok)) {
5192
5212
// If this is obviously not the start of a decl, then we're done.
5193
5213
return false ;
0 commit comments