Anviking / Decodable

[Probably deprecated] Swift 2/3 JSON unmarshalling done (more) right
MIT License
1.04k stars 73 forks source link

Ambiguous use of 'decode' over Dictionary (Xcode8b6) #119

Closed polqf closed 7 years ago

polqf commented 7 years ago

Hi!

I am having troubles decoding an object that its output is a dictionary ([String : Model])

Let's say I have the following JSON.

        let json = [
            "1" : [
                "id" : "111",
                "name" : "firstName"
            ],
            "2" : [
                "id" : "222",
                "name" : "secondName"
            ]
        ]

What I used to do to get the Decoded objects was:

        let result = try! [String : Model].decode(json)

And everything was working fine in Xcode8b3. But today I migrated to Xcode8b6 and this is not working anymore. Xcode is emitting the following error:

screen shot 2016-08-25 at 17 42 39

Seems like is finding to definitions for the decode func. But if try to call the decode func from a Decodable object, or even an array of Decodable objects, everything works.

I've created a super dummy project that reproduces it, I'm attaching it.

TestDecodable.zip

Thanks a lot

Anviking commented 7 years ago

Thanks for reporting. I've removed the [Decodable: Any].decode overload which were causing the ambiguity since beta 6. (Which creates a new problem – #120, but better something's working.)

polqf commented 7 years ago

Thanks @Anviking , everything is working as before ! 👍