mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This change makes us treat it exactly as we do 'init'. We don't allow renaming the base name,
and don't fail if the basename doesn't match for calls.
Also:
- explicit init calls/references like `MyType.init(42)` are now reported with
'init' as a keywordBase range, rather than nothing.
- cursor info no longer reports rename as available on init/callAsFunction
calls without arguments, as there's nothing to rename in that case.
- Improved detection of when a referenced function is a call (rather than
reference) across syntactic rename, cursor-info, and indexing.
Resolves rdar://problem/60340429
18 lines
705 B
Swift
18 lines
705 B
Swift
struct Adder {
|
|
var base: Int
|
|
func /*test:def*/callAsFunction(x: Int, y: Int) -> Adder {
|
|
return self
|
|
}
|
|
}
|
|
|
|
let add3 = Adder(base: 3)
|
|
_ = add3/*test:call*/(x: 10, y: 11)
|
|
_ = add3 . /*test:call*/callAsFunction(x: 10, y: 11)
|
|
_ = add3 . /*test:ref*/callAsFunction(x:y:)
|
|
_ = add3 . /*test:ref*/callAsFunction
|
|
_ = (add3 . /*test:call*/callAsFunction())/*test:call*/(x: 10, y: 11)
|
|
|
|
// RUN: %empty-directory(%t.ranges)
|
|
// RUN: %refactor -find-rename-ranges -source-filename %s -pos="test" -is-function-like -old-name "callAsFunction(x:y:)" >> %t.ranges/call-as-function.swift.expected
|
|
// RUN: diff -u %S/FindRangeOutputs/call-as-function.swift.expected %t.ranges/call-as-function.swift.expected
|