Protocol conformance for protocols through extension

Assume we have a simple protocol:

protocol Test {
     var test: String { get }
}


It is possible to extend it to add functions & properties:

extension Test {
     var description: String {
          return self.test
     }
}


Why is it not possible to also declare protocol conformance for protocols?

extension Test: CustomStringConvertible {
     var description: String {
          return self.test
     }
}


Is this just not implemented (yet?) or is there a technical reason this won't work?

I guess you already know you can do this:

protocol Test: CustomStringConvertible {
    var test: String { get }
}


extension Test {
    var description: String {
        return self.test
    }
}

and you are asking why it is not possible to declare conformance to eg CustomStringConvertible through an extension?

It seems like it would be a fairly big leap to allow this. Normally, you need to add protocol conformance explicitly to each type. These protocol conformance protocol extensions would essentially be declaring protocol conformance for all types that implement another protocol. While this would be convenient in many cases, it also makes the system substantially more complex, since protocol conformance would no longer be fully explicit, but could instead happen through spooky action at a distance.


A workaround is to extend a protocol with an implementation for when Self implements another protocol. In that case, each type would still have to opt in to conformance and be able to override the implementation, but you can still write the default implementation once:


extension CustomStringConvertible where Self: Test { ... }
Protocol conformance for protocols through extension
 
 
Q