Rename: Implement Rename conflict analysis for properties. Qualify property references to resove rename conflicts when possible
#KT-8732 Fixed #KT-12543 Fixed (cherry picked from commit e23029d)
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
class ShadeKotlin {
|
||||
val name1 = 1;
|
||||
fun inner() {
|
||||
val <caret>name2 = 2;
|
||||
print(name1)
|
||||
print(name2)
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
class ShadeKotlin {
|
||||
val name1 = 1;
|
||||
fun inner() {
|
||||
val name1 = 2;
|
||||
print(this.name1)
|
||||
print(name1)
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package test
|
||||
|
||||
class A {
|
||||
val foo = 1
|
||||
val /*rename*/bar = 2
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "MARKED_ELEMENT",
|
||||
"mainFile": "test/test.kt",
|
||||
"newName": "foo",
|
||||
"withRuntime": "true",
|
||||
"hint": "Property 'foo' is already declared in class 'A'"
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
class ShadeKotlin {
|
||||
val name2 = 1;
|
||||
fun inner() {
|
||||
val name2 = 2;
|
||||
print(this.name2)
|
||||
print(name2)
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
class ShadeKotlin {
|
||||
val /*rename*/name1 = 1;
|
||||
fun inner() {
|
||||
val name2 = 2;
|
||||
print(name1)
|
||||
print(name2)
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"type": "MARKED_ELEMENT",
|
||||
"mainFile": "test/test.kt",
|
||||
"newName": "name2",
|
||||
"withRuntime": "true"
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
package test
|
||||
|
||||
class X {
|
||||
val x: Int get() = 1
|
||||
|
||||
inner class A {
|
||||
val xx: Int get() = 1
|
||||
|
||||
inner class XX {
|
||||
val xx: Int get() = 1
|
||||
|
||||
fun test() {
|
||||
this@A.xx
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
package test
|
||||
|
||||
class X {
|
||||
val x: Int get() = 1
|
||||
|
||||
inner class A {
|
||||
val /*rename*/a: Int get() = 1
|
||||
|
||||
inner class XX {
|
||||
val xx: Int get() = 1
|
||||
|
||||
fun test() {
|
||||
a
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"type": "MARKED_ELEMENT",
|
||||
"mainFile": "test/test.kt",
|
||||
"newName": "xx",
|
||||
"withRuntime": "true"
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
package test
|
||||
|
||||
class X {
|
||||
val x: Int get() = 1
|
||||
|
||||
inner class A {
|
||||
val x: Int get() = 1
|
||||
|
||||
inner class XX {
|
||||
val xx: Int get() = 1
|
||||
|
||||
fun test() {
|
||||
x
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
package test
|
||||
|
||||
class X {
|
||||
val x: Int get() = 1
|
||||
|
||||
inner class A {
|
||||
val /*rename*/a: Int get() = 1
|
||||
|
||||
inner class XX {
|
||||
val xx: Int get() = 1
|
||||
|
||||
fun test() {
|
||||
a
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"type": "MARKED_ELEMENT",
|
||||
"mainFile": "test/test.kt",
|
||||
"newName": "x",
|
||||
"withRuntime": "true"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package test
|
||||
|
||||
open class A {
|
||||
val /*rename*/foo = 1
|
||||
}
|
||||
|
||||
open class B : A() {
|
||||
val bar = 2
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "MARKED_ELEMENT",
|
||||
"mainFile": "test/test.kt",
|
||||
"newName": "bar",
|
||||
"withRuntime": "true",
|
||||
"hint": "Property after rename will clash with existing property 'bar' in class 'B'"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package test
|
||||
|
||||
open class A {
|
||||
val foo = 1
|
||||
}
|
||||
|
||||
open class B : A() {
|
||||
val /*rename*/bar = 2
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "MARKED_ELEMENT",
|
||||
"mainFile": "test/test.kt",
|
||||
"newName": "foo",
|
||||
"withRuntime": "true",
|
||||
"hint": "Property after rename will clash with existing property 'foo' in class 'A'"
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
open class A(val /*rename*/foo: Int)
|
||||
|
||||
open class B : A() {
|
||||
val bar = 2
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "MARKED_ELEMENT",
|
||||
"mainFile": "test/test.kt",
|
||||
"newName": "bar",
|
||||
"withRuntime": "true",
|
||||
"hint": "Parameter after rename will clash with existing property 'bar' in class 'B'"
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
open class A(val foo: Int)
|
||||
|
||||
open class B : A() {
|
||||
val /*rename*/bar = 2
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "MARKED_ELEMENT",
|
||||
"mainFile": "test/test.kt",
|
||||
"newName": "foo",
|
||||
"withRuntime": "true",
|
||||
"hint": "Property after rename will clash with existing parameter 'foo' in class 'A'"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
class Foo(val /*rename*/a: Int) {
|
||||
val b = 1
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "MARKED_ELEMENT",
|
||||
"mainFile": "test/test.kt",
|
||||
"newName": "b",
|
||||
"withRuntime": "true",
|
||||
"hint": "Property 'b' is already declared in class 'Foo'"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
class Foo(val a: Int) {
|
||||
val /*rename*/b = 1
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "MARKED_ELEMENT",
|
||||
"mainFile": "test/test.kt",
|
||||
"newName": "a",
|
||||
"withRuntime": "true",
|
||||
"hint": "Parameter 'a' is already declared in class 'Foo'"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package test
|
||||
|
||||
val foo = 1
|
||||
val /*rename*/bar = 2
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "MARKED_ELEMENT",
|
||||
"mainFile": "test/test.kt",
|
||||
"newName": "foo",
|
||||
"withRuntime": "true",
|
||||
"hint": "Property 'foo' is already declared in package 'test'"
|
||||
}
|
||||
Reference in New Issue
Block a user