I have this vanilla piece of code I virtually use everywhere in my code:
let configuration = URLSessionConfiguration.default
let session = URLSession(configuration:configuration)
let listTask = session.dataTask(with: theRequest, completionHandler:{[weak self](data, response, error) in
})
Yet in one particular class the compiler reports:
Cannot invoke 'dataTask' with an argument list of type '(with: URLRequest, completionHandler: (Data?, URLResponse?, Error?) -> ())' Expected an argument list of type '(with: URLRequest, completionHandler: (Data?, URLResponse?, Error?) -> Void)'
How does it infer the return value of the closure to be () instead of Void?
I copied the code from other classes repeatedly lest I wrote something wrongly.