bignerdranch / Freddy

A reusable framework for parsing JSON in Swift.
MIT License
1.09k stars 120 forks source link

enum doesn't conform to expected type 'JSONDecodable' #221

Closed okla closed 7 years ago

okla commented 7 years ago

Following code causes error:

enum Numbers: String {

  case one, two, three
}

// In argument type 'Numbers.Type', 'Numbers' does not conform to expected type 'JSONDecodable'
let number = try? json.decode(at: 0, type: Numbers.self)

But if I add

extension Numbers: JSONDecodable {}

the error's gone.

Shouldn't Numbers adopt JSONDecodable implicitly?

Swift 3, Xcode 8

zwaldowski commented 7 years ago

This is fully intended behavior. We can't make your types conform to JSONDecodable for you; we can only provide default implementations for your implementation.

okla commented 7 years ago

Ok, thanks!