Skip to content

Commit 54da89e

Browse files
committed
[ASTGen] Handle 'read' and 'modify' accessors
1 parent 7add493 commit 54da89e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/ASTGen/Sources/ASTGen/Decls.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,12 @@ extension ASTGenVisitor {
393393
return .modify
394394
case .`init`:
395395
return .`init`
396+
case .read:
397+
precondition(ctx.langOptsHasFeature(.CoroutineAccessors), "(compiler bug) 'read' accessor should only be parsed with 'CoroutineAccessors' feature")
398+
return .read2
399+
case .modify:
400+
precondition(ctx.langOptsHasFeature(.CoroutineAccessors), "(compiler bug) 'modify' accessor should only be parsed with 'CoroutineAccessors' feature")
401+
return .modify2
396402
default:
397403
self.diagnose(.unknownAccessorSpecifier(specifier))
398404
return nil

test/ASTGen/decls.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11

22
// RUN: %empty-directory(%t)
33
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-concurrency -enable-experimental-feature ParserASTGen \
4+
// RUN: -enable-experimental-feature CoroutineAccessors \
45
// RUN: | %sanitize-address > %t/astgen.ast
56
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-concurrency \
7+
// RUN: -enable-experimental-feature CoroutineAccessors \
68
// RUN: | %sanitize-address > %t/cpp-parser.ast
79

810
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
911

10-
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -Xfrontend -enable-experimental-concurrency -enable-experimental-feature ParserASTGen)
12+
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -Xfrontend -enable-experimental-concurrency -enable-experimental-feature CoroutineAccessors -enable-experimental-feature ParserASTGen)
1113

1214
// REQUIRES: executable_test
1315
// REQUIRES: swift_swift_parser
1416
// REQUIRES: swift_feature_ParserASTGen
17+
// REQUIRES: swift_feature_CoroutineAccessors
1518

1619
// rdar://116686158
1720
// UNSUPPORTED: asan
@@ -108,6 +111,10 @@ func testVars() {
108111
var s: Int {
109112
get async throws { return 0 }
110113
}
114+
var t: Int {
115+
read { yield q }
116+
modify { yield &q }
117+
}
111118
}
112119

113120
func rethrowingFn(fn: () throws -> Void) rethrows {}

0 commit comments

Comments
 (0)