Skip to content

Commit

Permalink
Remove Never usage
Browse files Browse the repository at this point in the history
this is a try to fix the chaos `Never` introduced inside this library,
there is a high chance change below is the final source.
swiftlang/swift#64899

At least unit test passes after it removed.
  • Loading branch information
apporc committed Mar 18, 2024
1 parent cc014e4 commit d28b8b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
12 changes: 0 additions & 12 deletions Sources/EOSIO/ABICodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,6 @@ public struct BinaryExtension<Value: ABICodable>: ABICodable {
extension BinaryExtension: Equatable where Value: Equatable {}
extension BinaryExtension: Hashable where Value: Hashable {}

extension Never: ABICodable {
public init(from decoder: Decoder) throws {
let ctx = DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Attempted to decode Never")
throw DecodingError.dataCorrupted(ctx)
}

public func encode(to encoder: Encoder) throws {
let ctx = EncodingError.Context(codingPath: encoder.codingPath, debugDescription: "Attempted to encode Never")
throw EncodingError.invalidValue(self, ctx)
}
}

// MARK: Dynamic ABI Coding

public extension CodingUserInfoKey {
Expand Down
11 changes: 8 additions & 3 deletions Sources/EOSIO/Chain/ABI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ public extension ABI {
let errorCode: UInt64
let errorMsg: String
}

private struct ExtensionsEntry: ABICodable, Equatable, Hashable {
let errorCode: UInt16
let errorMsg: Data
}
}

// MARK: ABI Coding
Expand Down Expand Up @@ -345,7 +350,7 @@ extension ABI: ABICodable {
self.tables = try decoder.decode([ABI.Table].self)
self.ricardianClauses = try decoder.decode([ABI.Clause].self)
_ = try decoder.decode([ABI.ErrorMessage].self) // ignore error messages, used only by abi compiler
_ = try decoder.decode([Never].self) // abi extensions not used
_ = try decoder.decode([ABI.ExtensionsEntry].self) // abi extensions not used
// decode variant typedefs (Y U NO USE EXTENSIONS?!)
do {
self.variants = try decoder.decode([ABI.Variant].self)
Expand All @@ -362,8 +367,8 @@ extension ABI: ABICodable {
try container.encode(self.actions, forKey: .actions)
try container.encode(self.tables, forKey: .tables)
try container.encode(self.ricardianClauses, forKey: .ricardianClauses)
try container.encode([] as [Never], forKey: .errorMessages)
try container.encode([] as [Never], forKey: .abiExtensions)
try container.encode([] as [ABI.ErrorMessage], forKey: .errorMessages)
try container.encode([] as [ABI.ExtensionsEntry], forKey: .abiExtensions)
try container.encode(self.variants, forKey: .variants)
}
}
Expand Down

0 comments on commit d28b8b7

Please sign in to comment.