xcodeswiftgenericsswift2xcode7-beta6

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


Solution

  • It looks like I commented out Domain's implementation of ToJSON to debug and forgot. It's working now.