mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Swift 3.0 failed to diagnose reassignments of an immutable existential variable if its initialization was governed by DI.
30 lines
600 B
Swift
30 lines
600 B
Swift
// RUN: %target-swift-frontend -emit-sil -verify %s
|
|
|
|
// rdar://problem/29716016 - Check that we properly enforce DI on `let`
|
|
// variables and class properties.
|
|
|
|
protocol P { }
|
|
|
|
extension P {
|
|
mutating func foo() {}
|
|
var bar: Int { get { return 0 } set {} }
|
|
}
|
|
|
|
class ImmutableP {
|
|
let field: P // expected-note* {{}}
|
|
|
|
init(field: P) {
|
|
self.field = field
|
|
self.field.foo() // expected-error{{}}
|
|
self.field.bar = 4 // expected-error{{}}
|
|
}
|
|
}
|
|
|
|
func immutableP(field: P) {
|
|
let x: P // expected-note* {{}}
|
|
|
|
x = field
|
|
x.foo() // expected-error{{}}
|
|
x.bar = 4 // expected-error{{}}
|
|
}
|