This code gives me the commented error:
struct T { }
public typealias Alias<S> = Result<S, NSError>
let response: Alias<T> = .success(T())
if case let Alias.success(value) = response { // ❌ Operator function '~=' requires that 'T' conform to 'Equatable'
print("\(value)")
}
However, if I change the pattern variable binding to the following, it compiles just fine:
if case let .success(value) = response { // ✅ works
print("\(value)")
}
If I forego the type alias I also get no problems:
struct T { }
let response: Result<T, Error> = .success(T())
if case let Result.success(value) = response { // ✅ works
print("\(value)")
}
I don't understand why stating the type Alias
explicitly would give me this error.