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

(Davor Jankolija) #1

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