[swift-evolution] Proposal: Sealed protocols

Felix Gabel felix.gabel at me.com
Thu Dec 3 16:59:45 CST 2015

Hey everyone,

I hereby propose adding a ’sealed’ modifier for protocols to enable library developers to declare protocols that can be only conformed to in the scope of the library itself. This is similar to a ’sealed trait’ in Scala with the difference that it does not limit the protocol to be only applicable in the file it is declared in.


public sealed protocol FooType {
    // this protocol can be conformed to only in scope of the library itself
    // it can NOT be conformed to by any object declared outside the library

What do you think?

Thank you for your time,

More information about the swift-evolution mailing list