mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
42 lines
862 B
Swift
42 lines
862 B
Swift
// RUN: not %target-swift-frontend -typecheck %s
|
|
@propertyWrapper
|
|
public struct Wrapper<T> {
|
|
public var wrappedV: T // part-way through typing wrappedValue
|
|
|
|
public init(initialValue: T) {
|
|
self.value = initialValue
|
|
}
|
|
|
|
public init(body: () -> T) {
|
|
self.value = body()
|
|
}
|
|
}
|
|
|
|
var globalInt: Int { return 17 }
|
|
|
|
public struct HasWrappers {
|
|
@Wrapper
|
|
public var x: Int = globalInt
|
|
|
|
@Wrapper(body: { globalInt })
|
|
public var y: Int
|
|
|
|
@Wrapper(body: {
|
|
struct Inner {
|
|
@Wrapper
|
|
var x: Int = globalInt
|
|
}
|
|
return Inner().x + globalInt
|
|
})
|
|
public var z: Int
|
|
|
|
func backingUse() {
|
|
_ = $y.value + $z.value + x + $x.value
|
|
}
|
|
}
|
|
|
|
func useMemberwiseInits(i: Int) {
|
|
_ = HasWrappers(x: i)
|
|
_ = HasWrappers(y: Wrapper(initialValue: i))
|
|
}
|