Skip to content

Commit c8d7db8

Browse files
committed
[Parse] Set AttrRange for @nonisolated
Make sure we set the `AttrRange` in cases where `@` is present, but `unsafe` isn't present. rdar://147965036
1 parent da521b9 commit c8d7db8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3741,6 +3741,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
37413741
break;
37423742
}
37433743
case DeclAttrKind::Nonisolated: {
3744+
AttrRange = Loc;
37443745
std::optional<bool> isUnsafe(false);
37453746
if (EnableParameterizedNonisolated) {
37463747
isUnsafe =

test/Concurrency/nonisolated_rules.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,12 @@ final class KlassB: Sendable {
166166
// expected-error@+1 {{'nonisolated' cannot be applied to mutable stored properties}}
167167
nonisolated var test: Int = 1
168168
}
169+
170+
// rdar://147965036 - Make sure we don't crash.
171+
func rdar147965036() {
172+
func test(_: () -> Void) {}
173+
test { @nonisolated in
174+
// expected-error@-1 {{'nonisolated' is a declaration modifier, not an attribute}}
175+
// expected-error@-2 {{'nonisolated' is not supported on a closure}}
176+
}
177+
}

0 commit comments

Comments
 (0)