[swift-evolution] [Draft] open and public protocols

Adrian Zubarev adrian.zubarev at devandartist.com
Sun Feb 19 18:01:35 CST 2017


struct A : _ExpressibleByBuiltinIntegerLiteral {
    init() {}
    init(_builtinIntegerLiteral value: _MaxBuiltinIntegerType) {}
}

struct B : ExpressibleByIntegerLiteral {
    init(integerLiteral value: A) {}
}

B(integerLiteral: A())
Here is another example. Am I supposed to do that? Definitely not. Your lovely question: Why not? Because the protocol starts with an underscore. So? Doesn’t prevent me from abusing all semi-hidden protocols.

Where is the enum now to stop me from doing this?

Enums are so heavily abused in Swift, just because they have a special ability not being extensible with a constructor.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170220/f6b2a741/attachment.html>


More information about the swift-evolution mailing list