Skip to content

Commit 6329fc0

Browse files
committed
Add fixed crasher from rdar://problem/54609704
1 parent 187647d commit 6329fc0

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: %target-swift-frontend -c %s
2+
3+
@propertyWrapper
4+
class OneOf<Value: Equatable> {
5+
var wrappedValue: Value {
6+
get { value }
7+
set { storeIfAllowed(newValue) }
8+
}
9+
10+
private var value: Value
11+
12+
private let allowedValues: [Value]
13+
14+
init(wrappedValue value: Value, _ allowedValues: Value...) {
15+
precondition(allowedValues.contains(value))
16+
self.value = value
17+
self.allowedValues = allowedValues
18+
}
19+
20+
private func storeIfAllowed(_ value: Value) {
21+
guard allowedValues.contains(value) else {
22+
return
23+
}
24+
25+
self.value = value
26+
}
27+
}
28+
29+
struct Test {
30+
@OneOf(4, 8, 15, 16, 23, 42) private var numbers: Int = 4
31+
}
32+
func test() {
33+
_ = Test()
34+
}

0 commit comments

Comments
 (0)