File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,19 @@ Swift Next
6161 }
6262 ```
6363
64+ * [ SE-0298] [ ] :
65+
66+ The "for" loop can be used to traverse asynchronous sequences in asynchronous code:
67+
68+ ```swift
69+ for try await line in myFile.lines() {
70+ // Do something with each line
71+ }
72+ ```
73+
74+ Asynchronous for loops use asynchronous sequences, defined by the protocol
75+ ` AsyncSequence ` and its corresponding ` AsyncIterator ` .
76+
6477** Add new entries to the top of this section, not here!**
6578
6679Swift 5.4
@@ -8309,6 +8322,7 @@ Swift 1.0
83098322[SE- 0286 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0286-forward-scan-trailing-closures.md>
83108323[SE- 0287 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0287-implicit-member-chains.md>
83118324[SE- 0296 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0296-async-await.md>
8325+ [SE- 0298 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
83128326
83138327[SR- 75 ]: < https: // bugs.swift.org/browse/SR-75>
83148328[SR- 106 ]: < https: // bugs.swift.org/browse/SR-106>
Original file line number Diff line number Diff line change @@ -2127,11 +2127,9 @@ ParserResult<Stmt> Parser::parseStmtForEach(LabeledStmtInfo LabelInfo) {
21272127 SourceLoc AwaitLoc;
21282128 SourceLoc TryLoc;
21292129
2130- if (shouldParseExperimentalConcurrency () &&
2131- Tok.isContextualKeyword (" await" )) {
2130+ if (Tok.isContextualKeyword (" await" )) {
21322131 AwaitLoc = consumeToken ();
2133- } else if (shouldParseExperimentalConcurrency () &&
2134- Tok.is (tok::kw_try)) {
2132+ } else if (Tok.is (tok::kw_try)) {
21352133 TryLoc = consumeToken ();
21362134 if (Tok.isContextualKeyword (" await" )) {
21372135 AwaitLoc = consumeToken ();
Original file line number Diff line number Diff line change 1- // RUN: %target-typecheck-verify-swift -enable-experimental-concurrency
1+ // RUN: %target-typecheck-verify-swift
22// REQUIRES: concurrency
3+ import _Concurrency
34
45struct AsyncRange < Bound: Comparable & Strideable > : AsyncSequence , AsyncIteratorProtocol where Bound. Stride : SignedInteger {
56 var range : Range < Bound > . Iterator
You can’t perform that action at this time.
0 commit comments