diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eab21ff1..b27284923 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # master *Please add new entries at the top.* +1. Add primary associated types to SignalProducerConvertible & SignalProducerProtocol (#855, kudos to @braker1nine) 1. Refactor Github Actions to cover more swift versions (#858, kudos to @braker1nine) 1.Use `OSAllocatedUnfairLock` instead of `os_unfair_lock` on supported Apple platforms (#856, kudos to @mluisbrown) diff --git a/Sources/SignalProducer.swift b/Sources/SignalProducer.swift index 6740b5e67..431adb83a 100644 --- a/Sources/SignalProducer.swift +++ b/Sources/SignalProducer.swift @@ -538,6 +538,19 @@ extension SignalProducer where Error == Swift.Error { } } +#if swift(>=5.7) +/// Represents reactive primitives that can be represented by `SignalProducer`. +public protocol SignalProducerConvertible { + /// The type of values being sent by `self`. + associatedtype Value + + /// The type of error that can occur on `self`. + associatedtype Error: Swift.Error + + /// The `SignalProducer` representation of `self`. + var producer: SignalProducer { get } +} +#else /// Represents reactive primitives that can be represented by `SignalProducer`. public protocol SignalProducerConvertible { /// The type of values being sent by `self`. @@ -549,7 +562,21 @@ public protocol SignalProducerConvertible { /// The `SignalProducer` representation of `self`. var producer: SignalProducer { get } } +#endif +#if swift(>=5.7) +/// A protocol for constraining associated types to `SignalProducer`. +public protocol SignalProducerProtocol { + /// The type of values being sent by `self`. + associatedtype Value + + /// The type of error that can occur on `self`. + associatedtype Error: Swift.Error + + /// The materialized `self`. + var producer: SignalProducer { get } +} +#else /// A protocol for constraining associated types to `SignalProducer`. public protocol SignalProducerProtocol { /// The type of values being sent by `self`. @@ -561,6 +588,7 @@ public protocol SignalProducerProtocol { /// The materialized `self`. var producer: SignalProducer { get } } +#endif extension SignalProducer: SignalProducerConvertible, SignalProducerProtocol { public var producer: SignalProducer {