Skip to content

Commit 0a2d0b9

Browse files
committed
fixed and cleaned up fatal error for wrong types
1 parent 4e825ad commit 0a2d0b9

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Example/Source/Constant.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ private func fatalError(title: String, entries: [String]) -> Never {
88

99
internal enum Constant {
1010
enum FatalError {
11-
static func wrongTypesBeingCompared(_ actual: SpryEquatable?, _ me: SpryEquatable) -> Never {
11+
static func wrongTypesBeingCompared(self me: SpryEquatable, actual: SpryEquatable) -> Never {
1212
let title = "Wrong types being equated"
1313
let entries = [
14-
"<\(type(of: actual))> could NOT be cast as <\(type(of: me))>"
14+
"<\(actual)> could NOT be cast as <\(type(of: me))>"
1515
]
1616

1717
fatalError(title: title, entries: entries)

Example/Source/SpryEquatable.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public extension SpryEquatable {
2929
public extension SpryEquatable where Self: Equatable {
3030
func _isEqual(to actual: SpryEquatable?) -> Bool {
3131
guard let castedActual = actual as? Self else {
32-
Constant.FatalError.wrongTypesBeingCompared(actual, self)
32+
Constant.FatalError.wrongTypesBeingCompared(self: self, actual: actual)
3333
}
3434

3535
return self == castedActual
@@ -41,7 +41,7 @@ public extension SpryEquatable where Self: Equatable {
4141
public extension SpryEquatable where Self: AnyObject {
4242
func _isEqual(to actual: SpryEquatable?) -> Bool {
4343
guard let castedActual = actual as? Self else {
44-
Constant.FatalError.wrongTypesBeingCompared(actual, self)
44+
Constant.FatalError.wrongTypesBeingCompared(self: self, actual: actual)
4545
}
4646

4747
return self === castedActual
@@ -53,7 +53,7 @@ public extension SpryEquatable where Self: AnyObject {
5353
public extension SpryEquatable where Self: AnyObject & Equatable {
5454
func _isEqual(to actual: SpryEquatable?) -> Bool {
5555
guard let castedActual = actual as? Self else {
56-
Constant.FatalError.wrongTypesBeingCompared(actual, self)
56+
Constant.FatalError.wrongTypesBeingCompared(self: self, actual: actual)
5757
}
5858

5959
return self === castedActual
@@ -65,7 +65,7 @@ public extension SpryEquatable where Self: AnyObject & Equatable {
6565
public extension Array {
6666
func _isEqual(to actual: SpryEquatable?) -> Bool {
6767
guard let castedActual = actual as? Array<Element> else {
68-
Constant.FatalError.wrongTypesBeingCompared(actual, self)
68+
Constant.FatalError.wrongTypesBeingCompared(self: self, actual: actual)
6969
}
7070

7171
if self.count != castedActual.count {
@@ -91,7 +91,7 @@ public extension Array {
9191
public extension Dictionary {
9292
func _isEqual(to actual: SpryEquatable?) -> Bool {
9393
guard let castedActual = actual as? Dictionary<Key, Value> else {
94-
Constant.FatalError.wrongTypesBeingCompared(actual, self)
94+
Constant.FatalError.wrongTypesBeingCompared(self: self, actual: actual)
9595
}
9696

9797
if self.count != castedActual.count {
@@ -135,7 +135,7 @@ public extension SpryEquatable where Self: OptionalType {
135135
}
136136

137137
guard type(of: self) == type(of: actual) else {
138-
Constant.FatalError.wrongTypesBeingCompared(actual, self)
138+
Constant.FatalError.wrongTypesBeingCompared(self: self, actual: actual)
139139
}
140140

141141
let selfsWrappedValue = selfMirror.children.first?.value

0 commit comments

Comments
 (0)