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