-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
The compiler doesn't raise a compilation error for not calling a designated initializer for a subclass of NSWindow
if it has a let property.
Steps to reproduce
import AppKit
class AWindow: NSWindow {
let name: String
init(name: String) {
self.name = name
super.init() // Crashed when debugging: Use of unimplemented initializer 'init(contentRect:styleMask:backing:defer:)'
}
}`
_ = AWindow(name: "")
If I change var name
to let name
, the compiler raises the compilation error correctly.
class BWindow: NSWindow {
var name: String
init(name: String) {
self.name = name
super.init() // Compilation Error Must call a designated initializer of the superclass 'NSWindow'
}
}
_ = BWindow(name: "")
Expected behavior
NSWindow should have only one initializer init(contentRect:styleMask:backing:defer:) marked as NS_DESIGNATED_INITIALIZER, so both AWindow and BWindow should raise compilation errors
Environment
- Swift compiler version info: swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: arm64-apple-macosx13.0 - Xcode version info: Xcode 14.2
Build version 14C18 - Deployment target: macOS 12.3
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labelsThis issue needs more specific labels