-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareproperty wrappersFeature: property wrappersFeature: property wrappers
Description
Previous ID | SR-10929 |
Radar | rdar://problem/51809986 |
Original Reporter | @stephencelis |
Type | Bug |
Status | Resolved |
Resolution | Done |
Environment
Xcode 11 (beta 1)
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, CompilerCrash, PropertyWrappers |
Assignee | None |
Priority | Medium |
md5: 3d06fbaf3e18ebe3c1efa989fee0f169
Issue Description:
-
Create Xcode 11 single view app project with SwiftUI.
-
Replace
ContentView
with the following:
import SwiftUI
@propertyWrapper public final class Store<Value, Action>: DynamicViewProperty, BindingConvertible {
public let update: (inout Value, Action) -> Void
public private(set) var value: Value
public var binding: Binding<Value> {
Binding<Value>(
getValue: { self.value },
setValue: { self.value = $0 }
)
}
public init(_ initialValue: Value, _ update: @escaping (inout Value, Action) -> Void) {
self.update = update
self.value = initialValue
}
}
enum Action {
case increment
case decrement
}
func update(_ state: inout Int, _ action: Action) {
switch action {
case .increment:
state += 1
case .decrement:
state -= 1
}
}
struct ContentView : View {
@Store(0, update) var store
var body: some View {
Text("Hello World")
}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareproperty wrappersFeature: property wrappersFeature: property wrappers