Open
Description
Previous ID | SR-9761 |
Radar | None |
Original Reporter | @keith |
Type | Bug |
Environment
Xcode 10.2 beta 2
Swift 4.2 -> Swift 5 migrator
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, Migrator |
Assignee | None |
Priority | Medium |
md5: db350fb3d6f66b39b682595cf6f7a76d
Issue Description:
When running the migrator on this project https://github.com/lyft/mapper/ in Xcode 10.2 beta 1, it tries to migrate this:
public func optionalFrom<T>(_ field: String, transformation: (Any) throws -> T?) -> T? {
return (try? transformation(try self.JSONFromField(field))).flatMap { $0 }
}
To this:
public func optionalFrom<T>(_ field: String, transformation: (Any) throws -> T?) -> T? {
return (((try? transformation(try self.JSONFromField(field))) as T??)).flatMap { $0 }
}
The type of `JSONFromField` is:
func JSONFromField(_ field: String) throws -> Any
If I ignore this migration, and still move to Swift 5, it compiles fine. You should be able to reproduce this by cloning that repo, and migrating.