无法使用类型的参数列表调用 'dataTask'

Cannot invoke 'dataTask' with an argument list of type

我有一段普通代码,我几乎在我的代码中到处使用:

let configuration = URLSessionConfiguration.default
let session = URLSession(configuration:configuration)
let listTask = session.dataTask(with: theRequest, completionHandler: {[weak self](data, response, error) in
})

但在一个特定的 class 编译器抱怨:

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)'

它如何推断闭包的 return 值为 () 而不是预期的 Void?我反复复制其他classes的代码,以免写错了。

在 xcode 8 beta 6 和 swift 3 playground 中试过

    let configuration = URLSessionConfiguration.default
    let session = URLSession(configuration:configuration)
    let theRequest = URLRequest(url: URL(string: "")!)
    let task = session.dataTask(with: URL(string: "")!) { (data:Data?, response:URLResponse?, error:Error?) in

    }

    let task1 = session.dataTask(with: theRequest) { (data:Data?, response:URLResponse?, error:Error?) in

    }

出于某种原因添加:

return () 

在关闭结束时,按照 Apple 论坛上的建议,解决了这个问题。