Skip to content

Commit 7585f46

Browse files
committed
[test] coverage for global effectful props
1 parent e943445 commit 7585f46

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency
2+
3+
var intAsyncProp : Int {
4+
get async { 0 }
5+
}
6+
7+
var intThrowsProp : Int { // expected-note 2 {{var declared here}}
8+
get throws { 0 }
9+
}
10+
11+
var asyncThrowsProp : Int {
12+
// expected-warning@+1 {{reference to var 'intThrowsProp' is not concurrency-safe because it involves shared mutable state}}
13+
get async throws { try await intAsyncProp + intThrowsProp }
14+
}
15+
16+
func hello() async {
17+
// expected-warning@+1 {{reference to var 'intThrowsProp' is not concurrency-safe because it involves shared mutable state}}
18+
_ = intThrowsProp // expected-error{{property access can throw, but it is not marked with 'try' and the error is not handled}}
19+
20+
_ = intAsyncProp // expected-error{{property access is 'async' but is not marked with 'await'}}
21+
}
22+
23+
class C {
24+
var counter : Int = 0
25+
}
26+
27+
var refTypeThrowsProp : C { // expected-note {{var declared here}}
28+
get throws { return C() }
29+
}
30+
31+
var refTypeAsyncProp : C {
32+
get async { return C() }
33+
}
34+
35+
func salam() async {
36+
// expected-warning@+1 {{reference to var 'refTypeThrowsProp' is not concurrency-safe because it involves shared mutable state}}
37+
_ = refTypeThrowsProp // expected-error{{property access can throw, but it is not marked with 'try' and the error is not handled}}
38+
39+
40+
_ = refTypeAsyncProp // expected-error {{property access is 'async' but is not marked with 'await'}}
41+
}

0 commit comments

Comments
 (0)