Skip to content

Commit 8a2173c

Browse files
authored
Merge pull request #74907 from hamishknight/any-isolation-will-do-6.0
[6.0] [Parse] Add fix-it for unknown isolation in `@isolated`
2 parents cd8bfe4 + 22fa095 commit 8a2173c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4856,11 +4856,12 @@ ParserStatus Parser::parseTypeAttribute(TypeOrCustomAttr &result,
48564856
kind = IsolatedTypeAttr::IsolationKind::Dynamic;
48574857

48584858
// Add new kinds of isolation here; be sure to update the text for
4859-
// attr_isolated_expected_kind.
4859+
// attr_isolated_expected_kind, and change the associated fix-it below.
48604860

48614861
} else {
48624862
if (!justChecking) {
4863-
diagnose(Tok, diag::attr_isolated_expected_kind);
4863+
diagnose(Tok, diag::attr_isolated_expected_kind)
4864+
.fixItReplace(Tok.getLoc(), "any");
48644865
}
48654866
invalid = true;
48664867
consumeIf(tok::identifier);

test/Parse/isolated_any.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ func testLookahead() {
1010
let array = [@isolated(any) () -> ()]()
1111
_ = array
1212
}
13+
14+
func testInvalidIsolation(_ x: @isolated(foo) () -> Void) {}
15+
// expected-error@-1 {{expected 'any' as the isolation kind}} {{42-45=any}}

0 commit comments

Comments
 (0)