Files
swift-mirror/validation-test/compiler_crashers_2_fixed/0198-rdar52081852.swift
Doug Gregor bee789e277 [SE-0258] Check for an invalid property wrapper type definition.
Fixes the crash-on-invalid in rdar://problem/52081852.
2019-07-08 16:07:51 -07:00

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))
}