[swift-users] open/public protocol with not overridable default implementation in the future?

Adrian Zubarev adrian.zubarev at devandartist.com
Fri Sep 16 03:38:23 CDT 2016


I always wanted a way to make some protocol default implementations not overridable. Now Swift 3 got open vs. public behavior for classes. (Hopefully the inconsistency will be fixed soon and we’ll get open protocols as well.)

Imagine this scenario with open/public protocols.

// Module A
// `open protocol` means that in a diff. module I'll
// be able to conform to that protocol
open protocol Proto {}

extension Proto {
     // shouldn't this mean that the variable is not overridable  
     // from a different module? :)
     public var foo: Int { return 42 }
}

// Module B
struct A : Proto {
    // can I or can I not override `foo` from here?
}
I wonder if my thinking is correct here, or do we need something else to make extensions with default implementation to be fixed and not overridable?



-- 
Adrian Zubarev
Sent with Airmail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160916/970b985d/attachment.html>


More information about the swift-users mailing list