tristanlabelle / swift-winrt

A Swift Projection for WinRT APIs
MIT License
20 stars 2 forks source link

Derived class initializers can be incorrectly marked as override #360

Closed tristanlabelle closed 1 month ago

tristanlabelle commented 1 month ago

Initializers should be marked override iff the same initializer exists on the direct base class.


open class Base {
    public init() {}
    public init(_: Int) {}
}

open class Derived: Base {
    public override init(_: Int) { super.init(42) } // Must be marked "override"
}

open class MetaDerived: Derived {
    public init() { super.init(42) } // May not be marked "override"
    public override init(_: Int) { super.init(42) } // Must be marked "override"
}