Files
swift-mirror/test/SILOptimizer/definite_init_inout_super_init.swift
Nate Chandler a3198dc017 [Test] Remove -disable-sil-ownership-verifier use.
The flag had been used in
test/SILOptimizer/definite_init_inout_super_init.swift because SILGen
generated invalid SIL which would only be diagnosed during DI.  Thanks
to https://github.com/apple/swift/pull/73664 , this is diagnosed before
SILGen.

One other test case use (test/PrintAsObjC/extensions.swift) remains.
2024-05-31 08:30:14 -07:00

48 lines
923 B
Swift

// RUN: %target-swiftc_driver -emit-sil %s -o /dev/null -Xfrontend -verify
// TODO: Change this back to using target-swift-frontend once we move errors to
// type checker and SILGen.
class Klass {}
class B {
init(x: inout Int) {}
init(x: inout Klass) {}
}
class A : B {
let x: Int // expected-note {{change 'let' to 'var' to make it mutable}}
init() {
self.x = 12
super.init(x: &x) // expected-error {{cannot pass immutable value as inout argument: 'x' is a 'let' constant}}
}
}
class C : B {
let x: Klass // expected-note {{change 'let' to 'var' to make it mutable}}
init() {
self.x = Klass()
super.init(x: &x) // expected-error {{cannot pass immutable value as inout argument: 'x' is a 'let' constant}}
}
}
class D : B {
var x: Int
init() {
self.x = 12
super.init(x: &x)
}
}
class E : B {
var x: Klass
init() {
self.x = Klass()
super.init(x: &x)
}
}