Skip to content

Commit 297eb4d

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents d3794e6 + 3065843 commit 297eb4d

21 files changed

+208
-2
lines changed

lib/IDE/Refactoring.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ bool RefactoringActionLocalRename::performChange() {
784784
CursorInfoResolver Resolver(*TheFile);
785785
ResolvedCursorInfo CursorInfo = Resolver.resolve(StartLoc);
786786
if (CursorInfo.isValid() && CursorInfo.ValueD) {
787-
ValueDecl *VD = CursorInfo.ValueD;
787+
ValueDecl *VD = CursorInfo.CtorTyRef ? CursorInfo.CtorTyRef : CursorInfo.ValueD;
788788
llvm::SmallVector<DeclContext *, 8> Scopes;
789789
analyzeRenameScope(VD, DiagEngine, Scopes);
790790
if (Scopes.empty())
@@ -3526,7 +3526,7 @@ int swift::ide::findLocalRenameRanges(
35263526
Diags.diagnose(StartLoc, diag::unresolved_location);
35273527
return true;
35283528
}
3529-
ValueDecl *VD = CursorInfo.ValueD;
3529+
ValueDecl *VD = CursorInfo.CtorTyRef ? CursorInfo.CtorTyRef : CursorInfo.ValueD;
35303530
llvm::SmallVector<DeclContext *, 8> Scopes;
35313531
analyzeRenameScope(VD, Diags, Scopes);
35323532
if (Scopes.empty())

test/refactoring/rename/Outputs/basic/C1.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic/E1.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic/S1.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic/SLocal.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic/SLocal_init.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
struct S1 {}
2+
func foo1(a: S1) {}
3+
class C1 {}
4+
func foo2(c : C1) {}
5+
enum E1 {}
6+
func foo3(e : E1) {}
7+
func foo4(a : S1, b : C1, c: E1) { foo4(a: a, b: b, c :c) }
8+
9+
func test() {
10+
struct SLocal {
11+
init(x: S1) {}
12+
}
13+
func local(a: SLocal) {}
14+
local(a: SLocal(x: S1()))
15+
}
16+
17+
guard let top = Optional.some("top") else {
18+
fatalError()
19+
}
20+
print(top)
21+
22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct new_SP1: P1 {}
26+
return new_SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic/foo4.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic/foo4_multi.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic/local.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic/top_level.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let bottom = Optional.some("top") else {
1919
}
2020
print(bottom)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic_ranges/C1.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic_ranges/E1.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic_ranges/S1.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic_ranges/SLocal.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic_ranges/SLocal_init.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
struct S1 {}
2+
func foo1(a: S1) {}
3+
class C1 {}
4+
func foo2(c : C1) {}
5+
enum E1 {}
6+
func foo3(e : E1) {}
7+
func foo4(a : S1, b : C1, c: E1) { foo4(a: a, b: b, c :c) }
8+
9+
func test() {
10+
struct SLocal {
11+
init(x: S1) {}
12+
}
13+
func local(a: SLocal) {}
14+
local(a: SLocal(x: S1()))
15+
}
16+
17+
guard let top = Optional.some("top") else {
18+
fatalError()
19+
}
20+
print(top)
21+
22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct <base>SP1</base>: P1 {}
26+
return <base>SP1</base>()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic_ranges/foo4.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic_ranges/local.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/Outputs/basic_ranges/top_level.swift.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ guard let <base>top</base> = Optional.some("top") else {
1919
}
2020
print(<base>top</base>)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+

test/refactoring/rename/basic.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ guard let top = Optional.some("top") else {
1919
}
2020
print(top)
2121

22+
protocol P1 {}
23+
struct Test {
24+
var test: P1 {
25+
struct SP1: P1 {}
26+
return SP1()
27+
}
28+
}
29+
2230
// RUN: %empty-directory(%t.result)
2331
// RUN: %refactor -rename -source-filename %s -pos=2:15 -new-name new_S1 >> %t.result/S1.swift
2432
// RUN: diff -u %S/Outputs/basic/S1.swift.expected %t.result/S1.swift
@@ -46,6 +54,8 @@ print(top)
4654
// RUN: diff -u %S/Outputs/basic/local.swift.expected %t.result/local.swift
4755
// RUN: %refactor -rename -source-filename %s -pos=20:7 -new-name 'bottom' > %t.result/top_level.swift
4856
// RUN: diff -u %S/Outputs/basic/top_level.swift.expected %t.result/top_level.swift
57+
// RUN: %refactor -rename -source-filename %s -pos=26:12 -new-name new_SP1 > %t.result/SP1.swift
58+
// RUN: diff -u %S/Outputs/basic/SP1.swift.expected %t.result/SP1.swift
4959
// RUN: %empty-directory(%t.ranges)
5060
// RUN: %refactor -find-local-rename-ranges -source-filename %s -pos=2:15 > %t.ranges/S1.swift
5161
// RUN: diff -u %S/Outputs/basic_ranges/S1.swift.expected %t.ranges/S1.swift
@@ -71,3 +81,5 @@ print(top)
7181
// RUN: diff -u %S/Outputs/basic_ranges/local.swift.expected %t.ranges/local.swift
7282
// RUN: %refactor -find-local-rename-ranges -source-filename %s -pos=20:7 > %t.result/top_level.swift
7383
// RUN: diff -u %S/Outputs/basic_ranges/top_level.swift.expected %t.result/top_level.swift
84+
// RUN: %refactor -find-local-rename-ranges -source-filename %s -pos=26:12 > %t.result/SP1.swift
85+
// RUN: diff -u %S/Outputs/basic_ranges/SP1.swift.expected %t.result/SP1.swift

0 commit comments

Comments
 (0)