MoyaAvailability.swift marks Moya.Error as unavaliable, but also tries to use Moya.Error in the same file

Created on 4 Feb 2017  路  14Comments  路  Source: Moya/Moya

As of Jan 4 commit, MoyaAvailability.swift marks Moya.Error as unavaliable, but also tries to use Moya.Error in the same file:

@available(*, unavailable, renamed: "MoyaError", message: "Moya.Error has been renamed to MoyaError in version 8.0.0")
public typealias Error = MoyaError

...
    func didReceiveResponse(result: Result<Moya.Response, Moya.Error>, target: TargetType) { fatalError() }

Generates a compiler error.

bug?

Most helpful comment

This sounds like a bug fix to me, but I'll raise it with the core team.

All 14 comments

Ah - it's only a compiler error in Swift 3.1. Swift 3.0 seems to only apply the @unavailable outside the file.

Thanks for bringing that up though! We should put that on our radar for Swift 3.1 release @Moya/contributors.

Since Swift 3.1 is supposed to be backwards compatible with Swift 3.0, I think the Swift dev team will be interested by this: @DougGregor @jckarter

This is true indeed; Swift 3.1 should be source compatible with 3.0.

This sounds like a bug fix to me, but I'll raise it with the core team.

There was a fix that attempted to emulate the 3.0 behavior and emit warnings in this case:

https://github.com/apple/swift/commit/9489f10ce1feb60e9fb0a32857a273a22420253b

It's recent enough that it may not have made it into 8.3 beta 1. Do you still see the error in 8.3 beta 2, or in a Swift 3.1 snapshot toolchain from swift.org?

The Swift 3.0 compatibility fix @jckarter referred to was first introduced in Xcode 8.3 beta 2.

@DougGregor This is still happening on Xcode 8.3 Beta 2 and with the latest 3.1 Toolchain (2017-02-07).

Should this meanwhile be fixed in Moya (and renamed to MoyaError)?

@ened as long as we can verify that doing so still offers the fix-its when trying to use the renamed methods, I think that is reasonable.

The availability fixits should still appear. Let us know if they don't. The only change should have been to tighten up the checking of availability on typealiases.

Thanks everyone. PR inbound.

I am trying to convert my Project from Swift 2.3 to Swift 3 in Xcode 8.3 beta 2. What should be done here to fix this issue. If I try to rename Error to MoyaError, Xcode cribs that I file is locked to changes. Still new to Swift and this migration is getting little painful. Any help is appreciated.

Thanks.

This fix has not been included in a release yet, right @scottrhoyt?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JianweiWangs picture JianweiWangs  路  3Comments

GurpalRajput picture GurpalRajput  路  3Comments

ghost picture ghost  路  3Comments

cocoatoucher picture cocoatoucher  路  3Comments

fenixsolorzano picture fenixsolorzano  路  3Comments