KT-9839: intention introduced: convert primary constructor to secondary one
(cherry picked from commit 93aaa48)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
d4418d5686
commit
7f50e6e70e
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ConvertPrimaryConstructorToSecondaryIntention
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
annotation class Ann(val t: String)
|
||||
|
||||
class Annotated @Ann("42") constructor<caret>()
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
annotation class Ann(val t: String)
|
||||
|
||||
class Annotated {
|
||||
@Ann("42") constructor()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
annotation class Ann
|
||||
|
||||
class AnnotatedParam<caret>(@Ann x: Double) {
|
||||
val y = x
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
annotation class Ann
|
||||
|
||||
class AnnotatedParam {
|
||||
constructor(@Ann x: Double) {
|
||||
this.y = x
|
||||
}
|
||||
|
||||
val y: Double
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
annotation class Ann
|
||||
|
||||
class AnnotatedParam<caret>(val v: Double, @Ann val x: Int, var s: String)
|
||||
+1
@@ -0,0 +1 @@
|
||||
class DefaultValueChain(val<caret> x1: Int, x2: Int = x1, val x3: Int = x2, x4: Int = x3, val x5: Int = x4)
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class DefaultValueChain {
|
||||
val x1: Int
|
||||
val x3: Int
|
||||
val x5: Int
|
||||
|
||||
constructor(x1: Int, x2: Int = x1, x3: Int = x2, x4: Int = x3, x5: Int = x4) {
|
||||
this.x1 = x1
|
||||
this.x3 = x3
|
||||
this.x5 = x5
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
class InitAndParams<caret>(x: Int, z: Int) {
|
||||
val y = x
|
||||
|
||||
val w: Int
|
||||
|
||||
init {
|
||||
w = foo(y)
|
||||
}
|
||||
|
||||
fun foo(arg: Int) = arg
|
||||
|
||||
val v = w + z
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
class InitAndParams {
|
||||
constructor(x: Int, z: Int) {
|
||||
this.y = x
|
||||
w = foo(y)
|
||||
this.v = w + z
|
||||
}
|
||||
|
||||
val y: Int
|
||||
|
||||
val w: Int
|
||||
|
||||
fun foo(arg: Int) = arg
|
||||
|
||||
val v: Int
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class ParamAndProperties<caret>(x: Int, val y: Int, z: Int, val w: Int) {
|
||||
val r = x + z
|
||||
|
||||
val s = r + y
|
||||
|
||||
val t = s + w
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
class ParamAndProperties {
|
||||
val y: Int
|
||||
val w: Int
|
||||
|
||||
constructor(x: Int, y: Int, z: Int, w: Int) {
|
||||
this.y = y
|
||||
this.w = w
|
||||
this.r = x + z
|
||||
this.s = r + y
|
||||
this.t = s + w
|
||||
}
|
||||
|
||||
val r: Int
|
||||
|
||||
val s: Int
|
||||
|
||||
val t: Int
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
class Protected protected<caret> constructor(internal var s: String)
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
class Protected {
|
||||
internal var s: String
|
||||
|
||||
protected constructor(s: String) {
|
||||
this.s = s
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
class My<caret>()
|
||||
@@ -0,0 +1,3 @@
|
||||
class My {
|
||||
constructor()
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class UseParam<caret>(x: Int) {
|
||||
val y = x
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class UseParam {
|
||||
constructor(x: Int) {
|
||||
this.y = x
|
||||
}
|
||||
|
||||
val y: Int
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class UseParam<caret>(x: Int) {
|
||||
val y = x
|
||||
|
||||
val z = 2 * y
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class UseParam {
|
||||
constructor(x: Int) {
|
||||
this.y = x
|
||||
this.z = 2 * y
|
||||
}
|
||||
|
||||
val y: Int
|
||||
|
||||
val z: Int
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class VarArg(<caret>vararg x: String) {
|
||||
val strList = x.toList()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class VarArg {
|
||||
constructor(vararg x: String) {
|
||||
this.strList = x.toList()
|
||||
}
|
||||
|
||||
val strList: List<String>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class VarargVal<caret>(vararg val param: String)
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class VarargVal {
|
||||
val param: Array<out String>
|
||||
|
||||
constructor(vararg param: String) {
|
||||
this.param = param
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
abstract class Base(val x: Int)
|
||||
|
||||
class Derived<caret>(x: Int) : Base(x) {
|
||||
val y = 2 * x
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
abstract class Base(val x: Int)
|
||||
|
||||
class Derived : Base {
|
||||
constructor(x: Int) : super(x) {
|
||||
this.y = 2 * x
|
||||
}
|
||||
|
||||
val y: Int
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
interface A {
|
||||
val s: String
|
||||
}
|
||||
|
||||
interface B {
|
||||
val x: Int
|
||||
}
|
||||
|
||||
abstract class C(open val d: Double)
|
||||
|
||||
class D(<caret>open val y: Int, override val d: Double) : A, C(d), B {
|
||||
override val s = "$y -> $d"
|
||||
|
||||
override val x = y * y
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
interface A {
|
||||
val s: String
|
||||
}
|
||||
|
||||
interface B {
|
||||
val x: Int
|
||||
}
|
||||
|
||||
abstract class C(open val d: Double)
|
||||
|
||||
class D : A, C, B {
|
||||
open val y: Int
|
||||
override val d: Double
|
||||
|
||||
constructor(y: Int, d: Double) : super(d) {
|
||||
this.y = y
|
||||
this.d = d
|
||||
this.s = "$y -> $d"
|
||||
this.x = y * y
|
||||
}
|
||||
|
||||
override val s: String
|
||||
|
||||
override val x: Int
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
class WithProperties<caret>(val x: Int, val y: Int = 7, private val z: Int = 13)
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class WithProperties {
|
||||
val x: Int
|
||||
val y: Int
|
||||
private val z: Int
|
||||
|
||||
constructor(x: Int, y: Int = 7, z: Int = 13) {
|
||||
this.x = x
|
||||
this.y = y
|
||||
this.z = z
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user