Skip to content

Commit 5e5c6f4

Browse files
authored
Merge pull request #74892 from hamishknight/any-isolation-will-do
[Parse] Add fix-it for unknown isolation in `@isolated`
2 parents 6d088fc + ff09cad commit 5e5c6f4

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
@@ -4850,11 +4850,12 @@ ParserStatus Parser::parseTypeAttribute(TypeOrCustomAttr &result,
48504850
kind = IsolatedTypeAttr::IsolationKind::Dynamic;
48514851

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

48554855
} else {
48564856
if (!justChecking) {
4857-
diagnose(Tok, diag::attr_isolated_expected_kind);
4857+
diagnose(Tok, diag::attr_isolated_expected_kind)
4858+
.fixItReplace(Tok.getLoc(), "any");
48584859
}
48594860
invalid = true;
48604861
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)