mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
With AST transform enabled by default most of the previously invalid declarations became valid (due to SE-0373 being implemented only for AST transform).
55 lines
1023 B
Swift
55 lines
1023 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
@resultBuilder
|
|
struct DummyBuilder {
|
|
static func buildBlock<T>(_ t: T) -> T {
|
|
return t
|
|
}
|
|
}
|
|
|
|
func dummy<T>(@DummyBuilder _: () -> T) {}
|
|
|
|
dummy {
|
|
var computedVar: Int { return 123 }
|
|
()
|
|
}
|
|
|
|
dummy {
|
|
lazy var lazyVar: Int = 123
|
|
()
|
|
}
|
|
|
|
dummy {
|
|
var observedVar: Int = 123 {
|
|
// expected-warning@-1 {{variable 'observedVar' was never used; consider replacing with '_' or removing it}}
|
|
didSet {}
|
|
}
|
|
|
|
()
|
|
}
|
|
|
|
dummy {
|
|
var observedVar: Int = 123 {
|
|
// expected-warning@-1 {{variable 'observedVar' was never used; consider replacing with '_' or removing it}}
|
|
willSet {}
|
|
}
|
|
|
|
()
|
|
}
|
|
|
|
@propertyWrapper struct Wrapper {
|
|
var wrappedValue: Int
|
|
}
|
|
|
|
dummy {
|
|
@Wrapper var wrappedVar: Int = 123
|
|
()
|
|
}
|
|
|
|
dummy {
|
|
@resultBuilder var attributedVar: Int = 123
|
|
// expected-error@-1 {{'@resultBuilder' attribute cannot be applied to this declaration}}
|
|
// expected-warning@-2 {{variable 'attributedVar' was never used; consider replacing with '_' or removing it}}
|
|
()
|
|
}
|