mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Support for implicit closures was already added in c452e4cc13:
init() {
bool_member1 = false
bool_member2 = false || bool_member1 // implicit closure
}
But this didn't work for initializers of derived classes.
rdar://66420045
84 lines
1006 B
Swift
84 lines
1006 B
Swift
// RUN: %target-swift-frontend -emit-sil %s -o /dev/null
|
|
|
|
// Test boolean operators with implicit closures
|
|
|
|
struct Simple {
|
|
let x: Bool
|
|
let y: Bool
|
|
|
|
init() {
|
|
x = false
|
|
y = false || x
|
|
}
|
|
}
|
|
|
|
struct NestedClosures {
|
|
let x: Bool
|
|
let y: Bool
|
|
let z: Bool
|
|
|
|
init(a: Bool) {
|
|
x = false
|
|
y = false
|
|
z = false || (y || (x || a))
|
|
}
|
|
|
|
init(b: Bool) {
|
|
x = false
|
|
y = false
|
|
// With explicit self
|
|
z = false || (self.y || (self.x || b))
|
|
}
|
|
}
|
|
|
|
class SimpleClass {
|
|
let x: Bool
|
|
let y: Bool
|
|
|
|
init() {
|
|
x = false
|
|
y = false || x
|
|
}
|
|
}
|
|
|
|
func forward(_ b: inout Bool) -> Bool {
|
|
return b
|
|
}
|
|
|
|
struct InoutUse {
|
|
var x: Bool
|
|
var y: Bool
|
|
|
|
init() {
|
|
x = false
|
|
y = false || forward(&x)
|
|
}
|
|
}
|
|
|
|
protocol P {
|
|
var b: Bool { get }
|
|
}
|
|
|
|
struct Generic<T : P> {
|
|
let x: T
|
|
let y: Bool
|
|
|
|
init(_ t: T) {
|
|
x = t
|
|
y = false || x.b
|
|
}
|
|
}
|
|
|
|
class Base { }
|
|
|
|
class Derived : Base {
|
|
var x: Bool
|
|
var y: Bool
|
|
|
|
init(_: Int) {
|
|
x = false
|
|
y = true || x
|
|
}
|
|
}
|
|
|