Files
swift-mirror/test/SILOptimizer/definite_init_existential_let.swift
Michael Gottesman 2cacbc6403 [di] Enable SIL Ownership verification on all definite init tests.
*NOTE* DefiniteInit is still running /after/ ownership is stripped. This is just
making sure that the code we are producing can actually pass the verifier.

rdar://31521023
2017-09-06 16:31:20 -07:00

30 lines
622 B
Swift

// RUN: %target-swift-frontend -emit-sil -enable-sil-ownership -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{{}}
}