Here's the code:
var error: Error?
// ... something which may or may not set error ...
switch error {
case AFError.explicitlyCancelled:
// Task was cancelled, don't continue
return
case let e?:
debugPrint(e)
self.error = e
default:
break
}
For some reason, this switch statement causes swift-frontend to blow up:
swift-frontend: /home/build-user/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = swift::ExistentialArchetypeType, From = swift::TypeBase]: Assertion `isa(Val) && "cast() argument of incompatible type!"' failed.
Restructuring this so the switch is not over an optional works fine, i.e:
if let error {
switch error {
case AFError.explicitlyCancelled:
// Task was cancelled, don't continue
return
default:
debugPrint(error)
self.error = error
}
}
Is this a known issue, or should I file one?