Hi guys, just a quick question. I want to write a polyfill for the very useful JSONEncoder / JSONDecoder classes in Swift4.
The main method on JSONDecoder is:
/// Decodes a top-level value of the given type from the given JSON representation.
///
/// - parameter type: The type of the value to decode.
/// - parameter data: The data to decode from.
/// - returns: A value of the requested type.
/// - throws: `DecodingError.dataCorrupted` if values requested from the payload are corrupted, or if the given data is not valid JSON.
/// - throws: An error if any value throws an error during decoding.
open func decode<T>(_ type: T.Type, from data: Data) throws -> T where T : Decodable
This fails with error E28: Unknown type “T.Type” in Fire 2181
Is there a way to declare and use this type of func in Silver? eg take a generic class as a param and return an object of that class as the return type.
In java you would be able to use Class<T>
as the param, and return type T
Cheers