Skip to content

Commit 2d03e5e

Browse files
committed
Eliminate a redundant cast
1 parent 0c34639 commit 2d03e5e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/SwiftProtobuf/JSONDecoder.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,8 @@ internal struct JSONDecoder: Decoder {
469469
mutating func decodeSingularEnumField<E: Enum>(value: inout E?) throws
470470
where E.RawValue == Int {
471471
if scanner.skipOptionalNull() {
472-
if E.self is _CustomJSONCodable.Type {
473-
value = try (E.self as! _CustomJSONCodable.Type).decodedFromJSONNull() as? E
472+
if let customDecodable = E.self as? _CustomJSONCodable.Type {
473+
value = try customDecodable.decodedFromJSONNull() as? E
474474
return
475475
}
476476
value = nil
@@ -482,8 +482,8 @@ internal struct JSONDecoder: Decoder {
482482
mutating func decodeSingularEnumField<E: Enum>(value: inout E) throws
483483
where E.RawValue == Int {
484484
if scanner.skipOptionalNull() {
485-
if E.self is _CustomJSONCodable.Type {
486-
value = try (E.self as! _CustomJSONCodable.Type).decodedFromJSONNull() as! E
485+
if let customDecodable = E.self as? _CustomJSONCodable.Type {
486+
value = try customDecodable.decodedFromJSONNull() as! E
487487
return
488488
}
489489
value = E()

0 commit comments

Comments
 (0)