Avatar
swiftbot BOT 3/24/2020 7:06 AM
Author icon
kishikawakatsumi
import Foundation struct DocumentSymbol: Encodable {} class Service { func perform() { sendDocumentSymbolRequest(context: [:], resource: "", slug: "", path: "") { (_, _) in } } private func sendDocumentSymbolRequest(context: [String : String], resource: String, slug: String, path: String, reply: @escaping (Bool, [String : Any]) -> Void) { let documentSymbols = [DocumentSymbol()] reply(true, ["result": "success", "value": encodeResponse(documentSymbols)]) } private func encodeResponse(_ documentSymbol: DocumentSymbol) -> [String: Any] { print("A") return [:] } private func encodeResponse(_ documentSymbols: [DocumentSymbol]) -> [String: Any] { print("B") return [:] } private func encodeResponse<T: Encodable>(_ response: T) -> Any { print("C") let data = try! JSONEncoder().encode(response) return try! JSONSerialization.jsonObject(with: data, options: []) } } let service = Service() service.perform()
Version:
swift-5.1.3-RELEASE
Output:
B
Error: