[swift-evolution] [swift-evolution-announce] [Review #2] SE-0117: Default classes to be non-subclassable publicly

Davor Jankolija djankolija at gmail.com
Mon Jul 18 13:59:50 CDT 2016


I would just like to voice my support for the current proposal and apologize in advance if this has already been adressed but the restriction on superclasses having to also be open is something I find awkward to say the least. To me it just seems that by doing so the issue of avoiding subclassing of a class that simply shouldn’t be subclassed gets a bit moot.

As the current proposal states: "These are conservative restrictions that reduce the scope of this proposal; it will be possible to revisit them in a later proposal.”

I’m not sure if allowing a superclass to not have to be open would increase the scope by that much, although I understand this isn’t necessarily the case.

Just to make sure I got everything right, as it stands this would be possible:

/// Module A

public open class SomeSuperClass {
    // Unsuitable for subclassing
}

public open class SomeClass: SomeSuperClass {
	// Suitable for subclassing
}

/// Module B

class SubClass: SomeSuperClass {
	/// …
}

Even though the point of subclassing should be SomeClass there’s really nothing preventing the caller from subclassing the SomeSuperClass which is unsuitable for it.

- Davor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160718/0a44e463/attachment.html>


More information about the swift-evolution mailing list