Skip to content

Commit f5cd224

Browse files
authored
Merge pull request #509 from ReactiveCocoa/inhabitable-type-guard-fix
Fixed the two inhabitable type guarding overloads.
2 parents 7b23858 + a63e302 commit f5cd224

File tree

2 files changed

+52
-52
lines changed

2 files changed

+52
-52
lines changed

ReactiveSwift.xcodeproj/project.pbxproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@
6868
9A1D067D1D948A2300ACF44C /* UnidirectionalBindingSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A1D067C1D948A2200ACF44C /* UnidirectionalBindingSpec.swift */; };
6969
9A1D067E1D948A2300ACF44C /* UnidirectionalBindingSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A1D067C1D948A2200ACF44C /* UnidirectionalBindingSpec.swift */; };
7070
9A1D067F1D948A2300ACF44C /* UnidirectionalBindingSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A1D067C1D948A2200ACF44C /* UnidirectionalBindingSpec.swift */; };
71-
9A5D93731EE5733300438925 /* InhabitableTypeGuards.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A5D93721EE5733300438925 /* InhabitableTypeGuards.swift */; };
72-
9A5D93741EE5733300438925 /* InhabitableTypeGuards.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A5D93721EE5733300438925 /* InhabitableTypeGuards.swift */; };
73-
9A5D93751EE5733300438925 /* InhabitableTypeGuards.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A5D93721EE5733300438925 /* InhabitableTypeGuards.swift */; };
74-
9A5D93761EE5733300438925 /* InhabitableTypeGuards.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A5D93721EE5733300438925 /* InhabitableTypeGuards.swift */; };
71+
9A67963B1F6056B90058C5B4 /* UninhabitedTypeGuards.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A67963A1F6056B90058C5B4 /* UninhabitedTypeGuards.swift */; };
72+
9A67963C1F6059420058C5B4 /* UninhabitedTypeGuards.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A67963A1F6056B90058C5B4 /* UninhabitedTypeGuards.swift */; };
73+
9A67963D1F6059430058C5B4 /* UninhabitedTypeGuards.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A67963A1F6056B90058C5B4 /* UninhabitedTypeGuards.swift */; };
74+
9A67963E1F6059440058C5B4 /* UninhabitedTypeGuards.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A67963A1F6056B90058C5B4 /* UninhabitedTypeGuards.swift */; };
7575
9A681A9E1E5A241B00B097CF /* DeprecationSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A681A9D1E5A241B00B097CF /* DeprecationSpec.swift */; };
7676
9A681A9F1E5A241B00B097CF /* DeprecationSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A681A9D1E5A241B00B097CF /* DeprecationSpec.swift */; };
7777
9A681AA01E5A241B00B097CF /* DeprecationSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A681A9D1E5A241B00B097CF /* DeprecationSpec.swift */; };
@@ -249,7 +249,7 @@
249249
9A090C131DA0309E00EE97CA /* Reactive.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Reactive.swift; sourceTree = "<group>"; };
250250
9A1A4F981E16961C006F3039 /* ValidatingPropertySpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValidatingPropertySpec.swift; sourceTree = "<group>"; };
251251
9A1D067C1D948A2200ACF44C /* UnidirectionalBindingSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnidirectionalBindingSpec.swift; sourceTree = "<group>"; };
252-
9A5D93721EE5733300438925 /* InhabitableTypeGuards.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InhabitableTypeGuards.swift; sourceTree = "<group>"; };
252+
9A67963A1F6056B90058C5B4 /* UninhabitedTypeGuards.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UninhabitedTypeGuards.swift; sourceTree = "<group>"; };
253253
9A681A9D1E5A241B00B097CF /* DeprecationSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeprecationSpec.swift; sourceTree = "<group>"; };
254254
9A9100DE1E0E6E620093E346 /* ValidatingProperty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValidatingProperty.swift; sourceTree = "<group>"; };
255255
9ABCB1841D2A5B5A00BCA243 /* Deprecations+Removals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Deprecations+Removals.swift"; sourceTree = "<group>"; };
@@ -417,7 +417,7 @@
417417
D08C54B11A69A2AC00AD8286 /* Signal.swift */,
418418
D08C54B21A69A2AC00AD8286 /* SignalProducer.swift */,
419419
BE9CF3941D751B6B003AE479 /* UnidirectionalBinding.swift */,
420-
9A5D93721EE5733300438925 /* InhabitableTypeGuards.swift */,
420+
9A67963A1F6056B90058C5B4 /* UninhabitedTypeGuards.swift */,
421421
);
422422
name = Signals;
423423
sourceTree = "<group>";
@@ -889,8 +889,8 @@
889889
57A4D1BA1BA13D7A00F7D4B1 /* Property.swift in Sources */,
890890
9A090C171DA0309E00EE97CA /* Reactive.swift in Sources */,
891891
57A4D1BB1BA13D7A00F7D4B1 /* Signal.swift in Sources */,
892+
9A67963E1F6059440058C5B4 /* UninhabitedTypeGuards.swift in Sources */,
892893
57A4D1BC1BA13D7A00F7D4B1 /* SignalProducer.swift in Sources */,
893-
9A5D93761EE5733300438925 /* InhabitableTypeGuards.swift in Sources */,
894894
57A4D1BD1BA13D7A00F7D4B1 /* Atomic.swift in Sources */,
895895
57A4D1BE1BA13D7A00F7D4B1 /* Bag.swift in Sources */,
896896
57A4D1C01BA13D7A00F7D4B1 /* FoundationExtensions.swift in Sources */,
@@ -944,8 +944,8 @@
944944
A9B315C21B3940810001CB9C /* Property.swift in Sources */,
945945
9A090C161DA0309E00EE97CA /* Reactive.swift in Sources */,
946946
A9B315C31B3940810001CB9C /* Signal.swift in Sources */,
947+
9A67963D1F6059430058C5B4 /* UninhabitedTypeGuards.swift in Sources */,
947948
A9B315C41B3940810001CB9C /* SignalProducer.swift in Sources */,
948-
9A5D93751EE5733300438925 /* InhabitableTypeGuards.swift in Sources */,
949949
A9B315C51B3940810001CB9C /* Atomic.swift in Sources */,
950950
A9B315C61B3940810001CB9C /* Bag.swift in Sources */,
951951
A9B315C81B3940810001CB9C /* FoundationExtensions.swift in Sources */,
@@ -972,8 +972,8 @@
972972
9A090C141DA0309E00EE97CA /* Reactive.swift in Sources */,
973973
D08C54B31A69A2AE00AD8286 /* Signal.swift in Sources */,
974974
D85C652A1C0D84C7005A77AD /* Flatten.swift in Sources */,
975+
9A67963B1F6056B90058C5B4 /* UninhabitedTypeGuards.swift in Sources */,
975976
D0C312CF19EF2A5800984962 /* Bag.swift in Sources */,
976-
9A5D93731EE5733300438925 /* InhabitableTypeGuards.swift in Sources */,
977977
4A0E10FF1D2A92720065D310 /* Lifetime.swift in Sources */,
978978
D0C312E719EF2A5800984962 /* Scheduler.swift in Sources */,
979979
D0C312CD19EF2A5800984962 /* Atomic.swift in Sources */,
@@ -1027,8 +1027,8 @@
10271027
EBCC7DBD1BBF01E100A2AE92 /* Observer.swift in Sources */,
10281028
9A090C151DA0309E00EE97CA /* Reactive.swift in Sources */,
10291029
D85C652B1C0E70E3005A77AD /* Flatten.swift in Sources */,
1030+
9A67963C1F6059420058C5B4 /* UninhabitedTypeGuards.swift in Sources */,
10301031
4A0E11001D2A92720065D310 /* Lifetime.swift in Sources */,
1031-
9A5D93741EE5733300438925 /* InhabitableTypeGuards.swift in Sources */,
10321032
D08C54BB1A69C54400AD8286 /* Property.swift in Sources */,
10331033
D03B4A3E19F4C39A009E02AC /* FoundationExtensions.swift in Sources */,
10341034
D08C54B71A69A3DB00AD8286 /* Event.swift in Sources */,

Sources/InhabitableTypeGuards.swift renamed to Sources/UninhabitedTypeGuards.swift

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,105 +3,105 @@ import Result
33
// Observation
44
extension SignalProducer where Value == Never {
55
@discardableResult
6-
@available(*, deprecated, message:"`Result.success` is never delivered - `Value` is inhabitable (Instantiation at runtime would trap)")
7-
public func startWithResult(_ action: @escaping (Result<Value, Error>) -> Void) -> Disposable { observingInhabitableTypeError() }
8-
9-
@discardableResult
10-
@available(*, deprecated, message:"Observer is never called - `Value` is inhabitable (Instantiation at runtime would trap)")
11-
public func startWithValues(_ action: @escaping (Value) -> Void) -> Disposable { observingInhabitableTypeError() }
6+
@available(*, deprecated, message:"`Result.success` is never delivered - value type `Never` is uninstantiable (Use at runtime would trap)")
7+
public func startWithResult(_ action: @escaping (Result<Value, Error>) -> Void) -> Disposable { observingUninhabitedTypeError() }
128
}
139

1410
extension SignalProducer where Value == Never, Error == NoError {
1511
@discardableResult
16-
@available(*, deprecated, message:"Observer is never called - `Value` and `Error` are inhabitable (Instantiation at runtime would trap)")
17-
public func startWithResult(_ action: @escaping (Result<Value, Error>) -> Void) -> Disposable { observingInhabitableTypeError() }
12+
@available(*, deprecated, message:"Observer is never called - value type `Never` and error type `NoError` are uninstantiable (Use at runtime would trap)")
13+
public func startWithResult(_ action: @escaping (Result<Value, Error>) -> Void) -> Disposable { observingUninhabitedTypeError() }
14+
15+
@discardableResult
16+
@available(*, deprecated, message:"Observer is never called - value type `Never` is uninstantiable (Use at runtime would trap)")
17+
public func startWithValues(_ action: @escaping (Value) -> Void) -> Disposable { observingUninhabitedTypeError() }
1818
}
1919

2020
extension SignalProducer where Error == NoError {
2121
@discardableResult
22-
@available(*, deprecated, message:"`Error` is inhabitable so the observer is never called (Instantiation at runtime would trap)")
23-
public func startWithFailed(_ action: @escaping (Error) -> Void) -> Disposable { observingInhabitableTypeError() }
22+
@available(*, deprecated, message:"Observer is never called - error type `NoError` is uninstantiable (Use at runtime would trap)")
23+
public func startWithFailed(_ action: @escaping (Error) -> Void) -> Disposable { observingUninhabitedTypeError() }
2424
}
2525

2626
extension Signal where Value == Never {
2727
@discardableResult
28-
@available(*, deprecated, message:"`Result.success` is never delivered - `Value` is inhabitable (Instantiation at runtime would trap)")
29-
public func observeResult(_ action: @escaping (Result<Value, Error>) -> Void) -> Disposable? { observingInhabitableTypeError() }
30-
31-
@discardableResult
32-
@available(*, deprecated, message:"Observer is never called - `Value` is inhabitable (Instantiation at runtime would trap)")
33-
public func observeValues(_ action: @escaping (Value) -> Void) -> Disposable? { observingInhabitableTypeError() }
28+
@available(*, deprecated, message:"`Result.success` is never delivered - value type `Never` is uninstantiable (Use at runtime would trap)")
29+
public func observeResult(_ action: @escaping (Result<Value, Error>) -> Void) -> Disposable? { observingUninhabitedTypeError() }
3430
}
3531

3632
extension Signal where Value == Never, Error == NoError {
3733
@discardableResult
38-
@available(*, deprecated, message:"Observer is never called - `Value` and `Error` are inhabitable (Instantiation at runtime would trap)")
39-
public func observeResult(_ action: @escaping (Result<Value, Error>) -> Void) -> Disposable? { observingInhabitableTypeError() }
34+
@available(*, deprecated, message:"Observer is never called - value type `Never` and error type `NoError` are uninstantiable (Use at runtime would trap)")
35+
public func observeResult(_ action: @escaping (Result<Value, Error>) -> Void) -> Disposable? { observingUninhabitedTypeError() }
36+
37+
@discardableResult
38+
@available(*, deprecated, message:"Observer is never called - value type `Never` is uninstantiable (Use at runtime would trap)")
39+
public func observeValues(_ action: @escaping (Value) -> Void) -> Disposable? { observingUninhabitedTypeError() }
4040
}
4141

4242
extension Signal where Error == NoError {
4343
@discardableResult
44-
@available(*, deprecated, message:"Observer is never invoked - `Error` is inhabitable (Instantiation at runtime would trap)")
45-
public func observeFailed(_ action: @escaping (Error) -> Void) -> Disposable? { observingInhabitableTypeError() }
44+
@available(*, deprecated, message:"Observer is never invoked - error type `NoError` is uninstantiable (Use at runtime would trap)")
45+
public func observeFailed(_ action: @escaping (Error) -> Void) -> Disposable? { observingUninhabitedTypeError() }
4646
}
4747

4848
// flatMap
4949
extension SignalProducer where Value == Never {
5050
@discardableResult
51-
@available(*, deprecated, message:"Use `promoteValue` instead - `Value` is inhabitable (Instantiation at runtime would trap)")
52-
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> SignalProducer<Inner.Value, Error> where Inner.Error == Error { observingInhabitableTypeError() }
51+
@available(*, deprecated, message:"Use `promoteValue` instead - value type `Never` is uninstantiable (Use at runtime would trap)")
52+
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> SignalProducer<Inner.Value, Error> where Inner.Error == Error { observingUninhabitedTypeError() }
5353

5454
@discardableResult
55-
@available(*, deprecated, message:"Use `promoteValue` instead - `Value` is inhabitable (Instantiation at runtime would trap)")
56-
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> SignalProducer<Inner.Value, Error> where Inner.Error == NoError { observingInhabitableTypeError() }
55+
@available(*, deprecated, message:"Use `promoteValue` instead - value type `Never` is uninstantiable (Use at runtime would trap)")
56+
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> SignalProducer<Inner.Value, Error> where Inner.Error == NoError { observingUninhabitedTypeError() }
5757
}
5858

5959
extension SignalProducer where Value == Never, Error == NoError {
6060
@discardableResult
61-
@available(*, deprecated, message:"Use `promoteValue` instead - `Value` and `Error` are inhabitable (Instantiation at runtime would trap)")
62-
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> SignalProducer<Inner.Value, Inner.Error> { observingInhabitableTypeError() }
61+
@available(*, deprecated, message:"Use `promoteValue` instead - value type `Never` and error type `NoError` are uninstantiable (Use at runtime would trap)")
62+
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> SignalProducer<Inner.Value, Inner.Error> { observingUninhabitedTypeError() }
6363

6464
@discardableResult
65-
@available(*, deprecated, message:"Use `promoteValue` instead - `Value` and `Error` are inhabitable (Instantiation at runtime would trap)")
66-
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> SignalProducer<Inner.Value, Inner.Error> where Inner.Error == Error { observingInhabitableTypeError() }
65+
@available(*, deprecated, message:"Use `promoteValue` instead - value type `Never` and error type `NoError` are uninstantiable (Use at runtime would trap)")
66+
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> SignalProducer<Inner.Value, Inner.Error> where Inner.Error == Error { observingUninhabitedTypeError() }
6767
}
6868

6969
extension SignalProducer where Error == NoError {
7070
@discardableResult
71-
@available(*, deprecated, message:"Use `promoteError` instead - `Error` is inhabitable (Instantiation at runtime would trap)")
72-
public func flatMapError<NewError>(_ transform: @escaping (Error) -> SignalProducer<Value, NewError>) -> SignalProducer<Value, NewError> { observingInhabitableTypeError() }
71+
@available(*, deprecated, message:"Use `promoteError` instead - error type `NoError` is uninstantiable (Use at runtime would trap)")
72+
public func flatMapError<NewError>(_ transform: @escaping (Error) -> SignalProducer<Value, NewError>) -> SignalProducer<Value, NewError> { observingUninhabitedTypeError() }
7373
}
7474

7575
extension Signal where Value == Never {
7676
@discardableResult
77-
@available(*, deprecated, message:"Use `promoteValue` instead - `Value` is inhabitable (Instantiation at runtime would trap)")
78-
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> Signal<Inner.Value, Error> where Inner.Error == Error { observingInhabitableTypeError() }
77+
@available(*, deprecated, message:"Use `promoteValue` instead - value type `Never` is uninstantiable (Use at runtime would trap)")
78+
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> Signal<Inner.Value, Error> where Inner.Error == Error { observingUninhabitedTypeError() }
7979

8080
@discardableResult
81-
@available(*, deprecated, message:"Use `promoteValue` instead - `Value` is inhabitable (Instantiation at runtime would trap)")
82-
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> Signal<Inner.Value, Error> where Inner.Error == NoError { observingInhabitableTypeError() }
81+
@available(*, deprecated, message:"Use `promoteValue` instead - value type `Never` is uninstantiable (Use at runtime would trap)")
82+
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> Signal<Inner.Value, Error> where Inner.Error == NoError { observingUninhabitedTypeError() }
8383

8484
}
8585

8686
extension Signal where Value == Never, Error == NoError {
8787
@discardableResult
88-
@available(*, deprecated, message:"Use `promoteValue` instead - `Value` and `Error` are inhabitable (Instantiation at runtime would trap)")
89-
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> Signal<Inner.Value, Inner.Error> { observingInhabitableTypeError() }
88+
@available(*, deprecated, message:"Use `promoteValue` instead - value type `Never` and error type `NoError` are uninstantiable (Use at runtime would trap)")
89+
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> Signal<Inner.Value, Inner.Error> { observingUninhabitedTypeError() }
9090

9191
@discardableResult
92-
@available(*, deprecated, message:"Use `promoteValue` instead - `Value` and `Error` are inhabitable (Instantiation at runtime would trap)")
93-
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> Signal<Inner.Value, Inner.Error> where Inner.Error == Error { observingInhabitableTypeError() }
92+
@available(*, deprecated, message:"Use `promoteValue` instead - value type `Never` and error type `NoError` are uninstantiable (Use at runtime would trap)")
93+
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> Signal<Inner.Value, Inner.Error> where Inner.Error == Error { observingUninhabitedTypeError() }
9494
}
9595

9696
extension Signal where Error == NoError {
9797
@discardableResult
98-
@available(*, deprecated, message:"Use `promoteError` instead - `Error` is inhabitable (Instantiation at runtime would trap)")
99-
public func flatMapError<NewError>(_ transform: @escaping (Error) -> SignalProducer<Value, NewError>) -> Signal<Value, NewError> { observingInhabitableTypeError() }
98+
@available(*, deprecated, message:"Use `promoteError` instead - error type `NoError` is uninstantiable (Use at runtime would trap)")
99+
public func flatMapError<NewError>(_ transform: @escaping (Error) -> SignalProducer<Value, NewError>) -> Signal<Value, NewError> { observingUninhabitedTypeError() }
100100
}
101101

102102
@inline(never)
103-
private func observingInhabitableTypeError() -> Never {
104-
fatalError("Detected an attempt to instantiate a `Signal` or `SignalProducer` that observes an inhabitable type, e.g. `Never` or `NoError`. This is considered a logical error, and appropriate operators should be used instead. Please refer to the warnings raised by the compiler.")
103+
private func observingUninhabitedTypeError() -> Never {
104+
fatalError("Detected an attempt to observe (or create streams to transform) uninstantiable events. This is considered a logical error, and appropriate operators should be used instead. Please refer to the warnings raised by the compiler.")
105105
}
106106

107107
/*

0 commit comments

Comments
 (0)