Xcode 8.3 beta 2 Regression: enum inheriting from OSStatus can't also conform to RawRepresentable

Originator:igeek1
Number:rdar://30386658 Date Originated:06-Feb-2017 07:06 PM
Status:Resolved Resolved:09-Mar-2017 11:51 AM
Product:Developer Tools Product Version:Xcode 8.3 beta 2 (8W120l)
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
In Xcode 8.2, an enum inheriting from OSStatus can also be conformed to RawRepresentable in an extension. In Xcode 8.3 beta 2, this throws a compiler error.

Steps to Reproduce:
1. Paste this code into a macOS or iOS playground:

enum Status: OSStatus {
    case myStatus
}

extension Status: RawRepresentable {

    var description: String {
        switch self {
        case .myStatus: return "foo"
        }
    }

}

Status.myStatus.description

// END CODE SAMPLE

Expected Results:
The code builds and runs, outputting “foo”.

Actual Results:
The code fails to compile with the error:
Playground execution failed: error: 8.playground:1:14: error: use of undeclared type 'OSStatus'
enum Status: OSStatus {
             ^~~~~~~~

error: 8.playground:1:6: error: type 'Status' does not conform to protocol 'RawRepresentable'
enum Status: OSStatus {
     ^

Swift.RawRepresentable:96:20: note: protocol requires nested type 'RawValue'; do you want to add it?
    associatedtype RawValue
                   ^

error: 8.playground:5:19: error: redundant conformance of 'Status' to protocol 'RawRepresentable'
extension Status: RawRepresentable {
                  ^

8.playground:1:6: note: 'Status' declares conformance to protocol 'RawRepresentable' here
enum Status: OSStatus {
     ^
// END COMPILATION ERROR SAMPLE

Regression:
The code compiles and runs correctly in Xcode 8.2.1

Notes:
I encountered this when trying to build a project in Xcode 8.3 beta 2. The project has a dependency on the KeychainAccess library, which has an enum that inherits from OSStatus and then conforms to RawRepresentable in an extension. I filed a bug on that library to track this bug there as well: https://github.com/kishikawakatsumi/KeychainAccess/issues/306

Comments

The original code is now accepted by Xcode 8.3 beta 4 (as it was by 8.3 beta 3). This issue has been verified as resolved and can be closed.

My reply

That's weird, because the code from the sample builds and runs in a macOS playground in Xcode 8.3 beta 3. I'll leave this open, but please close this if you were right the first time, and it actually is fixed, because it looks fixed as far as I can tell.

Message from Apple Developer Relations

Please ignore previous email. The fix is not the current Xcode beta yet.

Message from Apple Developer Relations

Please verify this issue with the Xcode 8.3 beta and update your bug report at https://bugreport.apple.com/ with your results.

Xcode 8.3 beta 3 (8W132p) https://developer.apple.com/download/ Posted Date: Feb 20th, 2017

Attached screenshot for proof: https://cl.ly/j3pn

Yes. The code, as submitted, compiles and runs in an Xcode 8.2.1 macOS playground (with import AppKit at the top).

Message from Apple Developer Relations

Engineering has the following feedback for you:

The OSStatus error goes away if you import Foundation or AppKit, which seems correct to me. Did Swift 3 accept the redundant RawRep conformance?

Please provide your response or results by updating your bug report and compress any bundled files (e.g. nested folders) prior to uploading.

I forgot to add that the playground should have import AppKit at the top. The bug still exists if you do that.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!