Skip to content

Commit e943445

Browse files
committed
[test] effectful properties + property wrappers
They're currently incompatible, but it should be possible to enable this, with some care taken to ensure that effectful wrappers are composed correctly.
1 parent 9b09d8a commit e943445

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+
// Currently, we don't support having property wrappers that are effectful.
4+
// Eventually we'd like to add this.
5+
6+
@propertyWrapper
7+
struct Abstraction<T> {
8+
private var value : T
9+
10+
init(_ initial : T) { self.value = initial }
11+
12+
var wrappedValue : T {
13+
get throws { return value } // expected-error{{property wrappers currently cannot define an 'async' or 'throws' accessor}}
14+
}
15+
16+
// its OK to have effectul props that are not `wrappedValue`
17+
18+
var prop1 : T {
19+
get async { value }
20+
}
21+
var prop2 : T {
22+
get throws { value }
23+
}
24+
var prop3 : T {
25+
get async throws { value }
26+
}
27+
}
28+
29+
@propertyWrapper
30+
struct NeedlessIntWrapper {
31+
var wrappedValue : Int {
32+
get {}
33+
}
34+
}
35+
36+
struct S {
37+
// expected-error@+1 {{property wrapper cannot be applied to a computed property}}
38+
@NeedlessIntWrapper var throwingProp : Int {
39+
get throws { 0 }
40+
}
41+
}

0 commit comments

Comments
 (0)