Overrides in extension (same module)

I saw a FIXME in the codebase around allowing an override of a Swift class declaration to be placed in an extension of a class as long as the extension is in the same module as the class:

class X {
  func foo() { ... }
}

class Y: X {}
extension Y {
  override func foo() { ... } // Okay if `Y` and `extension Y` are in the same module
}

I also found this proposal by @jrose but it seems to be about having the extension in a different module than the class.

It looks like "override in same-module class extension" feature was planned but just not implemented, so I am wondering if the change would need to go through evolution today or can it be implemented without needing a proposal?

2 Likes

The most recent discussion of this is here: Allow `override` of `open` methods in & from extensions in same file as main class. I personally think at this point it should go through the proposal process since it's been a language rule for years, even if it is a difference from Objective-C.

4 Likes

I don’t think I’m skilled enough to write up a proposal on my own.