I have a problem with generic func for different classes under one Protocol:
public typealias Handler = (Result<Object, JSONError>) -> Void
private func fetchData<T>(endPoint: String, 
                          type: T.Type = T.self, 
                          completion: @escaping (Handler)) 
                          where T: Protocol { 
        completion(.success(fetchedData.object)) 
}
protocol Protocol: JSONDecodable {
    var object: Object { get }
}
class First: Protocol { 
    var object = Object()
    required init(json: JSON) throws {
             object = Object()
    }
}
I want to use it like that:
var endPoint: String = ""
var metaType: Protocol.Type
switch f.name {
case .First:
      endPoint = "/accounts/" + ""
      metaType = First.self
}
fetchData(endPoint: endPoint, type: metaType) { (result) in
}
Errors: Cannot convert value of type 'Protocol.Type' to expected argument type 'T.Type'; Generic parameter 'T' could not be inferred
Could you advise me how to approach this problem? Many thanks in advance!
