<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 25 Apr 2016, at 3:08 PM, Thorsten Seitz via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><div class="">I think the underlying problem is that you cannot "internally" conform to the internal protocol.<br class=""></div><div class=""><br data-mce-bogus="1" class=""></div><div class="">Desirable would be something like the following:<br data-mce-bogus="1" class=""></div><div class=""><br data-mce-bogus="1" class=""></div><div class="">public class SomePublicClass: internal SomeInternalProtocol { // note internal conformance<br class="">&nbsp; public convenience init(someOtherParameter: Int) {<br class="">&nbsp;&nbsp;&nbsp; self.init(parameter: SomeInternalClass())<br class="">&nbsp; }<br class="">&nbsp; internal required init(parameter: SomeInternalClass) {<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // do something<br class="">&nbsp; }<br class="">}</div><div class=""><br data-mce-bogus="1" class=""></div><div class="">i.e. when conforming internally the required init would only have to have internal visibility and you could introduce a convenience init for the public API. SomePublicClass would only be usable as SomeInternalProtocol within the module.&nbsp;</div></div></div></blockquote><div><br class=""></div><div>I like that. So I guess, more broadly, my proposal is:</div><div><br class=""></div><div><i class="">Provide a mechanism that allows a non-final class to conform to an internal protocol that has an initializer requirement without needing to expose that initializer publicly.</i></div><div><br class=""></div><div>And to recap, my suggestion was:</div><div><br class=""></div><div>- Allow a class to be marked publicly final, but internally non-final.</div><div><br class=""></div><div>And yours was:</div><div><br class=""></div><div>- Allow a class to “internally” conform to a protocol.</div><div><br class=""></div><div>Both approaches solve the same problem. Anyone got any other thoughts? Thanks.</div><div><br class=""></div><div>Matt</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="">Am 25. April 2016 um 08:27 schrieb Matt Comi via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt;:<br class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="msg-quote"><div class="_stretch"><span class="body-text-content">Consider a public class that conforms to an internal protocol that has an initializer requirement:<br class=""><br class="">internal class SomeInternalClass { }<br class=""><br class="">internal protocol SomeInternalProtocol {<br class=""> init(parameter: SomeInternalClass)<br class="">}<br class=""><br class="">public class SomePublicClass: SomeInternalProtocol {<br class=""> // compiler error: initializer requirement ‘init(parameter:)’ can only be satisfied by a `required` initializer in non-final class ‘SomePublicClass’<br class=""> init(parameter: SomeInternalClass) { }<br class="">}<br class=""><br class="">To resolve this error, init(parameter:) must be made public required, or SomePublicClass must be made final.<br class=""><br class="">If init(parameter:) were made public required, it would expose the module's internal structure; SomeInternalClass would need to be made public also. This makes sense, of course; if SomePublicClass is public and non-final, it may be subclassed outside the module and any subclass would need to know about init(parameter:) in order to remain conformant to SomeInternalProtocol.<br class=""><br class="">Alternatively, If SomePublicClass were made final, it could not be subclassed outside the module and thus, SomeInternalClass would not need to be exposed, but subclassing SomePublicClass within the module would also be impossible also.<br class=""><br class="">I propose that it should be possible to mark a class as publicly final while remaining internally non-final. This would resolve both issues: SomeInternalClass can remain internal, and SomePublicClass can be subclassed within the module.<br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" data-mce-href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" data-mce-href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></span></div></div></blockquote></div></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>