Extension with constraints cannot have an inheritance clause?

struct Wrapper<Value> {
    let value : Value
}

extension Wrapper : Equatable where Value : Equatable {
    static func ==(lhs: Wrapper, rhs: Wrapper) -> Bool {
        return lhs.value == rhs.value
    }
}


Entering the above code in a Playground in Xcode Version 9.0 beta (9M136h) gives the following error:


error: MyPlayground.playground:1:1: error: extension of type 'Wrapper' with constraints cannot have an inheritance clause

extension Wrapper : Equatable where Value : Equatable {


Isn't this supposed to work in Swift 4?

Looking at SE-0143 (github.com/apple/swift-evolution/blob/master/proposals/0143-conditional-conformances.md), it appears to have been accepted but not implemented yet. You might try asking over at one of the swift.org mailing lists to find out the current status. (Usually they add a bug number to the proposal if somebody is actively working on the implementation.)

I should have mentioned that jumping to the API docs from within Xcode 9 shows signatures with these sorts of conditional conformances like:


extension ClosedRange : Equatable where Bound : Comparable {
    public static func ==(lhs: ClosedRange<Bound>, rhs: ClosedRange<Bound>) -> Bool
}

Also, ClosedRange's comformance to Equatable is demonstrated by:


var rng: ClosedRange = 1...3
func isEqual<T : Equatable>(_ a1: T, _ a2: T) -> Bool { return a1 == a2 }
isEqual(rng, rng)


I wonder if maybe it is just a current shortcoming of the beta compiler.

I don't know. I still suggest you ask over on swift-users (but post the answer here if you find out, pls!).

Extension with constraints cannot have an inheritance clause?
 
 
Q