Skip to content

Commit 9896589

Browse files
authored
Merge pull request swiftlang#37590 from DougGregor/se-0313-enable-nonisolated
2 parents 01dd5a5 + 3fe712d commit 9896589

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
66
Swift 5.5
77
---------
88

9+
* [SE-0313][]:
10+
11+
Declarations inside an actor that would normally by actor-isolated can
12+
explicitly become non-isolated using the `nonisolated` keyword. Non-isolated
13+
declarations can be used to conform to synchronous protocol requirements:
14+
15+
```swift
16+
actor Account: Hashable {
17+
let idNumber: Int
18+
let balance: Double
19+
20+
nonisolated func hash(into hasher: inout Hasher) { // okay, non-isolated satisfies synchronous requirement
21+
hasher.combine(idNumber) // okay, can reference idNumber from outside the let
22+
hasher.combine(balance) // error: cannot synchronously access actor-isolated property
23+
}
24+
}
25+
```
26+
927
* [SE-0300][]:
1028

1129
Async functions can now be suspended using the `withUnsafeContinuation`
@@ -8506,6 +8524,7 @@ Swift 1.0
85068524
[SE-0300]: <https://github.com/apple/swift-evolution/blob/main/proposals/0300-continuation.md>
85078525
[SE-0306]: <https://github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md>
85088526
[SE-0310]: <https://github.com/apple/swift-evolution/blob/main/proposals/0310-effectful-readonly-properties.md>
8527+
[SE-0313]: <https://github.com/apple/swift-evolution/blob/main/proposals/0313-actor-isolation-control.md>
85098528

85108529
[SR-75]: <https://bugs.swift.org/browse/SR-75>
85118530
[SR-106]: <https://bugs.swift.org/browse/SR-106>

include/swift/AST/Attr.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ DECL_ATTR(completionHandlerAsync, CompletionHandlerAsync,
624624

625625
CONTEXTUAL_SIMPLE_DECL_ATTR(nonisolated, Nonisolated,
626626
DeclModifier | OnFunc | OnConstructor | OnVar | OnSubscript |
627-
ConcurrencyOnly |
628627
ABIStableToAdd | ABIStableToRemove |
629628
APIBreakingToAdd | APIStableToRemove,
630629
112)

test/SourceKit/CodeComplete/complete_override.swift.response

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,16 @@
214214
key.typerelation: source.codecompletion.typerelation.notapplicable,
215215
key.num_bytes_to_erase: 0
216216
},
217+
{
218+
key.kind: source.lang.swift.keyword,
219+
key.name: "nonisolated",
220+
key.sourcetext: "nonisolated",
221+
key.description: "nonisolated",
222+
key.typename: "",
223+
key.context: source.codecompletion.context.none,
224+
key.typerelation: source.codecompletion.typerelation.notapplicable,
225+
key.num_bytes_to_erase: 0
226+
},
217227
{
218228
key.kind: source.lang.swift.keyword,
219229
key.name: "nonmutating",

test/decl/class/actor/noconcurrency.swift

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)