swagger-api / swagger-api/swagger-codegen
[Codegen][Swift] Generic specialization of Decoders.decode func doesn't work
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Decoders class have several specializations for decodable type:
- T - (object or primitive type)
- [T] - (array)
- [Key:T] - (dictionary)
Here there are:
static func decode<T>(clazz clazz: [T].Type, source: AnyObject) -> [T] { ... }
static func decode<T, Key: Hashable>(clazz clazz: [Key:T].Type, source: AnyObject) -> [Key:T] { ... }
static func decode<T>(clazz clazz: T.Type, source: AnyObject) -> T { ... }
Actually, only the last specialization is invoked, even on arrays (which type is printed in log as Array). Seems a problem with a type deduction in swift generics.
i'm using:
- Xcode 7.0.1 (7A1001)
- Swift 2.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the generated Swift client behavior with the Decoders.decode overloads shown in the issue, using the stated Swift 2.0 and Xcode 7.0.1 versions if available. Inspect why array and dictionary values select the generic T overload; done when the appropriate specialized overload is selected for each supported decoded type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100