Skip to content

Commit

Permalink
Signal: using Signal.Event.promoteValue
Browse files Browse the repository at this point in the history
This fixes compilation on `Xcode 11` / `Swift 5.1`.
  • Loading branch information
NachoSoto committed Jun 3, 2019
1 parent aa25add commit b9c65dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
26 changes: 16 additions & 10 deletions Sources/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1015,17 +1015,23 @@ extension Signal.Event where Value == Never {
internal static func promoteValue<U>(_: U.Type) -> Transformation<U, Error> {
return { action, _ in
return { event in
switch event {
case .value:
fatalError("Never is impossible to construct")
case let .failed(error):
action(.failed(error))
case .completed:
action(.completed)
case .interrupted:
action(.interrupted)
}
action(event.promoteValue())
}
}
}
}

extension Signal.Event where Value == Never {
internal func promoteValue<U>() -> Signal<U, Error>.Event {
switch event {
case .value:
fatalError("Never is impossible to construct")
case let .failed(error):
return .failed(error)
case .completed:
return .completed
case .interrupted:
return .interrupted
}
}
}
2 changes: 1 addition & 1 deletion Sources/Signal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1848,7 +1848,7 @@ extension Signal {
}

for (index, action) in builder.startHandlers.enumerated() where !lifetime.hasEnded {
lifetime += action(index, strategy) { observer.send($0.map { _ in fatalError() }) }
lifetime += action(index, strategy) { observer.send($0.promoteValue()) }
}
}
}
Expand Down

0 comments on commit b9c65dd

Please sign in to comment.