mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
In cases where a subclass was unable to synthesize any initializers (for example, because there were missing designated initializers in the superclass), we were skipping checking of superclass required initializers. This meant that we would silently accept subclasses that cannot be initialized directly (that would produce an error), but could at runtime be initialized via a required initializer... that didn't account for the subclass. Fixes the original problem from https://github.com/apple/swift/issues/69965, but not the most minimal one.
21 lines
552 B
Swift
21 lines
552 B
Swift
// RUN: rm -rf %t
|
|
// RUN: split-file %s %t
|
|
|
|
// RUN: %target-swift-frontend -emit-module-path %t/MyModule.swiftmodule %t/Inputs/MyModule.swift
|
|
|
|
// RUN: %target-swift-frontend -typecheck -verify -I %t %t/test.swift
|
|
|
|
//--- Inputs/MyModule.swift
|
|
open class MySuperclassA {
|
|
required public init() { }
|
|
internal init(boop: Bool) {}
|
|
}
|
|
|
|
//--- test.swift
|
|
import MyModule
|
|
|
|
class MySubclassA: MySuperclassA {
|
|
// expected-warning{{'required' initializer 'init()' must be provided by subclass of 'MySuperclassA'; this is an error in Swift 6}}
|
|
var hi: String
|
|
}
|