mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
I will remove the `syntactic-rename` refactoring action in a follow-up commit. Clients should always ask for rename ranges and perform the rename by themselves instead of asking for a renamed file.
60 lines
1.4 KiB
Plaintext
60 lines
1.4 KiB
Plaintext
@propertyWrapper
|
|
struct /*wrapper:def*/<base>Foo</base><T> {
|
|
public var wrappedValue: T
|
|
init(initialValue: T) {
|
|
wrappedValue = initialValue
|
|
}
|
|
init(initialValue: T, otherThing: Bool) {
|
|
self.init(initialValue: initialValue)
|
|
}
|
|
var projectedValue: Projection<T> {
|
|
get { Projection(item: wrappedValue) }
|
|
}
|
|
}
|
|
|
|
struct Projection<T> {
|
|
var item: T
|
|
}
|
|
|
|
@resultBuilder
|
|
struct /*builder:def*/Other {
|
|
public static func buildBlock(_ components: String...) -> String {
|
|
return components.joined()
|
|
}
|
|
}
|
|
|
|
struct Bar {
|
|
@/*wrapper*/<base>Foo</base>
|
|
var /*wrapped:def*/foo: Int = 10
|
|
@/*wrapper*/<base>Foo</base>(initialValue: "hello")
|
|
var bar: String
|
|
@/*wrapper*/<base>Foo</base>
|
|
var jim: String = {
|
|
struct Bar {
|
|
@/*wrapper*/<base>Foo</base>
|
|
var inner: String = "It's 42"
|
|
}
|
|
return Bar().inner
|
|
}()
|
|
|
|
func combined(@/*builder*/Other _ a: () -> String) -> String {
|
|
return a()
|
|
}
|
|
|
|
@/*builder*/Other
|
|
func hello() -> String {
|
|
"hello"
|
|
"there"
|
|
}
|
|
|
|
func baz() {
|
|
let _: /*wrapper*/<base>Foo</base><Int> = /*wrapped+1*/_foo
|
|
let _: Int = /*wrapped+1*/_foo.wrappedValue
|
|
let _: Int = /*wrapped*/foo
|
|
let _: Projection<Int> = /*wrapped+1*/$foo
|
|
let _: /*wrapper*/<base>Foo</base><String> = _bar
|
|
}
|
|
}
|
|
|
|
|