简体   繁体   English

无法调用 <function> 带有类型为Dictionary的参数列表 <Generic, Generic>

[英]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.

相关问题 Swift:通用协议无法使用类型为参数的列表进行调用 - Swift: Generic Protocol Cannot invoke with an argument list of type 无法调用参数列表类型 - Cannot Invoke an Argument List type 无法使用类型为[AnyObject]的参数列表调用“ setViewController” - Cannot invoke" 'setViewController' with an argument list of type [AnyObject] 无法使用类型为((String)&#39;的参数列表调用&#39;performSelector&#39; - Cannot invoke 'performSelector' with an argument list of type '(String)' 无法使用StringLiteralConvertible类型的参数列表调用&#39;init&#39; - Cannot invoke 'init' with argument list of type StringLiteralConvertible 无法使用类型为((anyObject?)&#39;的参数列表调用&#39;valueForKey&#39; - Cannot invoke 'valueForKey' with an argument list of type '(anyObject?)' 无法使用类型&#39;(ChecklistItem)&#39;的参数列表调用&#39;indexOf&#39; - Cannot invoke 'indexOf' with an argument list of type '(ChecklistItem)' Swift 2 无法使用类型参数列表调用“FSEventStreamCreate” - Swift 2 Cannot invoke 'FSEventStreamCreate' with an argument list of type 无法使用类型&#39;(_)&#39;的参数列表调用&#39;perform&#39; - Cannot invoke 'perform' with an argument list of type '(_)' 无法使用类型为(([AnyObject])&#39;的参数列表调用&#39;sequence&#39; - Cannot invoke 'sequence' with an argument list of type '([AnyObject])'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM