CallableUsageReplacementStrategy: support KtSuperTypeCallEntry

#KT-37849 Fixed
This commit is contained in:
Dmitry Gridin
2020-04-01 19:32:25 +07:00
parent aec3c22497
commit 9d8d881bff
29 changed files with 306 additions and 22 deletions
@@ -0,0 +1,12 @@
// "Replace with 'A(s = "", i = { i }, i2 = 33)'" "true"
open class A(val s: String, val i: () -> Int, val i2: Int) {
@Deprecated("Replace with primary constructor", ReplaceWith("A(s = \"\", i = { i }, i2 = 33)"))
constructor(i: Int) : this("", { i }, i)
}
class B : A<caret>(i = 42)
fun a() {
A(42)
}
@@ -0,0 +1,12 @@
// "Replace with 'A(s = "", i = { i }, i2 = 33)'" "true"
open class A(val s: String, val i: () -> Int, val i2: Int) {
@Deprecated("Replace with primary constructor", ReplaceWith("A(s = \"\", i = { i }, i2 = 33)"))
constructor(i: Int) : this("", { i }, i)
}
class B : <caret>A(s = "", i = { 42 }, i2 = 33)
fun a() {
A(42)
}
@@ -0,0 +1,15 @@
// "Replace usages of 'constructor A(Int)' in whole project" "true"
open class A(val s: String, val i: () -> Int, val i2: Int) {
@Deprecated("Replace with primary constructor", ReplaceWith("C(s = \"\", a = { i }, m = i)"))
constructor(i: Int) : this("", { i }, i)
}
open class C(val m: Int, val s: String, a: () -> Int)
class B : A<caret>(i = 31)
fun b() {
val b = 30
A(b)
}
@@ -0,0 +1,15 @@
// "Replace usages of 'constructor A(Int)' in whole project" "true"
open class A(val s: String, val i: () -> Int, val i2: Int) {
@Deprecated("Replace with primary constructor", ReplaceWith("C(s = \"\", a = { i }, m = i)"))
constructor(i: Int) : this("", { i }, i)
}
open class C(val m: Int, val s: String, a: () -> Int)
class B : C(s = "", a = { 31 }, m = 31)
fun b() {
val b = 30
C(s = "", a = { b }, m = b)
}
@@ -0,0 +1,12 @@
// "Replace usages of 'constructor A(Int)' in whole project" "true"
open class A(val b: String, val i: () -> Int) {
@Deprecated("Replace with primary constructor", ReplaceWith("A(b = \"\") { i }"))
constructor(i: Int) : this("", { i })
}
class B : A<caret>(i = 33)
fun a() {
A(42)
}
@@ -0,0 +1,12 @@
// "Replace usages of 'constructor A(Int)' in whole project" "true"
open class A(val b: String, val i: () -> Int) {
@Deprecated("Replace with primary constructor", ReplaceWith("A(b = \"\") { i }"))
constructor(i: Int) : this("", { i })
}
class B : A<caret>(b = "", { 33 })
fun a() {
A(b = "") { 42 }
}
@@ -0,0 +1,10 @@
// "class org.jetbrains.kotlin.idea.quickfix.replaceWith.DeprecatedSymbolUsageFix" "false"
abstract class NewClass(val i: () -> Int)
@Deprecated("Text", ReplaceWith("NewClass({i})"))
abstract class OldClass(val i: Int)
class F : OldClass<caret> {
constructor(i: Int) : super(i)
constructor(i: () -> Int) : super(i())
}
@@ -0,0 +1,10 @@
import newPack.NewClass
class GF : NewClass({ 24 })
class CDw : NewClass({ 1111 })
fun foos() {
val b = 432
NewClass({ b })
}
@@ -0,0 +1,8 @@
import oldPack.OldClass;
public class Hoos extends OldClass {
public Hoos(int i) {
super(i);
}
}
@@ -0,0 +1,3 @@
package newPack
open class NewClass(val i: () -> Int)
@@ -0,0 +1,4 @@
package pack
@Deprecated("Replace with NewClass", ReplaceWith("NewClass({ i })", "newPack.NewClass"))
open class OldClass(val i: Int)
@@ -0,0 +1,13 @@
// "Replace usages of 'OldClass' in whole project" "true"
import newPack.NewClass
class B : NewClass({ 42 })
class C : NewClass({ 42 })
fun foo() {
val b = 42
NewClass({ b })
}
@@ -0,0 +1,10 @@
import pack.OldClass
class GF : OldClass(24)
class CDw : OldClass(1111)
fun foos() {
val b = 432
OldClass(b)
}
@@ -0,0 +1,8 @@
import oldPack.OldClass;
public class Hoos extends OldClass {
public Hoos(int i) {
super(i);
}
}
@@ -0,0 +1,13 @@
// "Replace usages of 'OldClass' in whole project" "true"
import pack.OldClass
class B : OldClass<caret>(42)
class C : OldClass(42)
fun foo() {
val b = 42
OldClass(b)
}
@@ -0,0 +1,3 @@
package newPack
open class NewClass(val i: () -> Int)
@@ -0,0 +1,4 @@
package pack
@Deprecated("Replace with NewClass", ReplaceWith("NewClass({ i })", "newPack.NewClass"))
open class OldClass(val i: Int)
@@ -0,0 +1,12 @@
// "Replace with 'A<TElement>({t})'" "true"
open class A<T> constructor(t: () -> T) {
@Deprecated("F", ReplaceWith("A<T>({t})"))
constructor(t: T) : this({ t })
}
class B<TElement>(t: TElement) : A<caret><TElement>(t)
fun b() {
A<Int>(42)
}
@@ -0,0 +1,12 @@
// "Replace with 'A<TElement>({t})'" "true"
open class A<T> constructor(t: () -> T) {
@Deprecated("F", ReplaceWith("A<T>({t})"))
constructor(t: T) : this({ t })
}
class B<TElement>(t: TElement) : A<TElement>({ t })
fun b() {
A<Int>(42)
}
@@ -0,0 +1,13 @@
// "Replace usages of 'constructor A<T>(T, T = ...)' in whole project" "true"
// ERROR: Unresolved reference: T
open class A<T> constructor(t: () -> T, f: () -> T = t) {
@Deprecated("F", ReplaceWith("A<T>({t})"))
constructor(t: T, f: T = t) : this({ t })
}
class B<TElement>(t: TElement) : A<caret><TElement>(t)
fun b() {
A<Int>(42)
}
@@ -0,0 +1,13 @@
// "Replace usages of 'constructor A<T>(T, T = ...)' in whole project" "true"
// ERROR: Unresolved reference: T
open class A<T> constructor(t: () -> T, f: () -> T = t) {
@Deprecated("F", ReplaceWith("A<T>({t})"))
constructor(t: T, f: T = t) : this({ t })
}
class B<TElement>(t: TElement) : A<T>({ t })
fun b() {
A({ 42 })
}