Swift 2: enum ErrorType with attached Class lose their type

Originator:gwendal.roue
Number:rdar://21707972 Date Originated:2015-07-07
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 7.0 beta (7A121l)
Classification:Serious Bug Reproducible:Always
 
Summary:
One can throw a specific enum ErrorType, and be unable to catch it:

import XCTest

class Context {
}

enum LostError : ErrorType {
    case A(Context)
    case B(Context)
}

class LostErrorTests: XCTestCase {
    func testLostError() {
        do {
            throw LostError.B(Context())
        } catch LostError.B {
            // OK: B expected
        } catch LostError.A {
            XCTFail("Expected B")      <--- Fail
        } catch {
            // OK: B expected
        }
    }
}

Steps to Reproduce:
Run the code above.

Expected Results:
 The caught error should be LostError.B

Actual Results:
 The caught error is LostError.A

Version:
Xcode 7.0 beta (7A121l)
OSX 10.10.3 (14D136)

Notes:
Remove the Context from case A, and the test pass.

  enum LostError : ErrorType {
-     case A(Context)
+    case A
      case B(Context)
  }

Comments


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!