mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Make sure they handle the case when a property wrapper type's constructor is called with the first argument coming from the var initializer, and the rest from the custom attribute's argument.
27 lines
1.1 KiB
Swift
27 lines
1.1 KiB
Swift
@propertyWrapper
|
|
struct Wrapper<T> {
|
|
var wrappedValue: T
|
|
/*split:def*/init(initialValue: T, fieldName: String, special: Bool = false) {
|
|
wrappedValue = initialValue
|
|
}
|
|
}
|
|
let /*someValue:def*/someValue = "some"
|
|
struct User {
|
|
@/*split:call*/Wrapper(fieldName: "bar")
|
|
var bar = 10
|
|
|
|
@/*split:call*/Wrapper(fieldName: {
|
|
return /*someValue*/someValue
|
|
}(), special: true)
|
|
var complex: Int = {
|
|
return /*someValue*/someValue.starts(with: "b") ? 43 : 0
|
|
}()
|
|
}
|
|
|
|
|
|
// RUN: %empty-directory(%t.ranges)
|
|
// RUN: %refactor -find-rename-ranges -source-filename %s -pos="someValue" -old-name "someValue" >> %t.ranges/property-wrapper-split-someValue.swift
|
|
// RUN: diff -u %S/FindRangeOutputs/property-wrapper-split/someValue.swift.expected %t.ranges/property-wrapper-split-someValue.swift
|
|
// RUN: %refactor -find-rename-ranges -source-filename %s -pos="split" -is-function-like -old-name "init(initialValue:fieldName:special:)" >> %t.ranges/property-wrapper-split-split.swift
|
|
// RUN: diff -u %S/FindRangeOutputs/property-wrapper-split/split.swift.expected %t.ranges/property-wrapper-split-split.swift
|