[英]Cannot invoke <function> with an argument list of type Dictionary<Generic, Generic>
I have a function with the following signature: 我有一个带有以下签名的函数:
static func dictionaryToJSON<K : ToJSON,V : ToJSON> ( dictionary : Dictionary<K,V>) -> JValue
You can find it here . 你可以在这里找到它。
When I attempt to call this function, I get the error Cannot invoke 'dictionaryToJSON' with an argument list of type '(Dictionary<Domain, Account>)'
. 当我尝试调用此函数时,出现错误
Cannot invoke 'dictionaryToJSON' with an argument list of type '(Dictionary<Domain, Account>)'
。 Here is the call: 这里是电话:
let accounts : JValue = Aeson.dictionaryToJSON( self.accounts)
self.accounts
has type Dictionary<Domain,Account>
, and Domain and Account both implement the protocol ToJSON
. self.accounts
具有Dictionary<Domain,Account>
,并且Domain和Account都实现协议ToJSON
。 Is there any reason why this doesn't type check? 有什么原因不能对此进行类型检查? This is for Swift 2 (XCode 7 beta 6), so maybe there is a compiler bug?
这是针对Swift 2(XCode 7 beta 6)的,所以也许存在编译器错误?
It looks like I commented out Domain's implementation of ToJSON to debug and forgot. 看来我已注释掉Domain对ToJSON的实现进行调试和忘记了。 It's working now.
现在正在工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.