Add code transformations for if/when in local property initializers
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
fun test(n: Int): String? {
|
||||
val res = <caret>if (n == 1) {
|
||||
if (3 > 2) {
|
||||
println("***")
|
||||
"one"
|
||||
} else {
|
||||
println("***")
|
||||
"???"
|
||||
}
|
||||
} else if (n == 2) {
|
||||
println("***")
|
||||
null
|
||||
} else {
|
||||
println("***")
|
||||
"too many"
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
fun test(n: Int): String? {
|
||||
val res:<caret> String?
|
||||
if (n == 1) {
|
||||
res = if (3 > 2) {
|
||||
println("***")
|
||||
"one"
|
||||
} else {
|
||||
println("***")
|
||||
"???"
|
||||
}
|
||||
} else res = if (n == 2) {
|
||||
println("***")
|
||||
null
|
||||
} else {
|
||||
println("***")
|
||||
"too many"
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
fun test(n: Int): String? {
|
||||
var res = <caret>if (n == 1) {
|
||||
if (3 > 2) {
|
||||
println("***")
|
||||
"one"
|
||||
} else {
|
||||
println("***")
|
||||
"???"
|
||||
}
|
||||
} else if (n == 2) {
|
||||
println("***")
|
||||
null
|
||||
} else {
|
||||
println("***")
|
||||
"too many"
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
fun test(n: Int): String? {
|
||||
var res:<caret> String?
|
||||
if (n == 1) {
|
||||
res = if (3 > 2) {
|
||||
println("***")
|
||||
"one"
|
||||
} else {
|
||||
println("***")
|
||||
"???"
|
||||
}
|
||||
} else res = if (n == 2) {
|
||||
println("***")
|
||||
null
|
||||
} else {
|
||||
println("***")
|
||||
"too many"
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// IS_APPLICABLE: false
|
||||
val<caret> x = if (false) "0" else "1"
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// IS_APPLICABLE: false
|
||||
var<caret> x = if (false) "0" else "1"
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun test(n: Int): String {
|
||||
val <caret>res = if (n == 1) "one" else "two"
|
||||
|
||||
return res
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun test(n: Int): String {
|
||||
val <caret>res: String
|
||||
if (n == 1) res = "one" else res = "two"
|
||||
|
||||
return res
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun test(n: Int): String {
|
||||
var <caret>res = if (n == 1) "one" else "two"
|
||||
|
||||
return res
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun test(n: Int): String {
|
||||
var <caret>res: String
|
||||
if (n == 1) res = "one" else res = "two"
|
||||
|
||||
return res
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fun test(n: Int): String {
|
||||
val res<caret> = if (n == 1) {
|
||||
println("***")
|
||||
"one"
|
||||
} else {
|
||||
println("***")
|
||||
"two"
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fun test(n: Int): String {
|
||||
val res<caret>: String
|
||||
if (n == 1) {
|
||||
println("***")
|
||||
res = "one"
|
||||
} else {
|
||||
println("***")
|
||||
res = "two"
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fun test(n: Int): String {
|
||||
var res<caret> = if (n == 1) {
|
||||
println("***")
|
||||
"one"
|
||||
} else {
|
||||
println("***")
|
||||
"two"
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fun test(n: Int): String {
|
||||
var res<caret>: String
|
||||
if (n == 1) {
|
||||
println("***")
|
||||
res = "one"
|
||||
} else {
|
||||
println("***")
|
||||
res = "two"
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun test(n: Int): String {
|
||||
val <caret>res: jet.String = if (n == 1) "one" else "two"
|
||||
|
||||
return res
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun test(n: Int): String {
|
||||
val <caret>res: jet.String
|
||||
if (n == 1) res = "one" else res = "two"
|
||||
|
||||
return res
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: false
|
||||
val n = 10
|
||||
|
||||
val res<caret> = when(n) {
|
||||
1 -> "one"
|
||||
2 -> "two"
|
||||
else -> null
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: false
|
||||
val n = 10
|
||||
|
||||
var res<caret> = when(n) {
|
||||
1 -> "one"
|
||||
2 -> "two"
|
||||
else -> null
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fun test(n: Int): String? {
|
||||
val res<caret> = when(n) {
|
||||
1 -> "one"
|
||||
2 -> "two"
|
||||
else -> null
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun test(n: Int): String? {
|
||||
val res<caret>: String?
|
||||
when(n) {
|
||||
1 -> res = "one"
|
||||
2 -> res = "two"
|
||||
else -> res = null
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fun test(n: Int): String? {
|
||||
var res<caret> = when(n) {
|
||||
1 -> "one"
|
||||
2 -> "two"
|
||||
else -> null
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun test(n: Int): String? {
|
||||
var res<caret>: String?
|
||||
when(n) {
|
||||
1 -> res = "one"
|
||||
2 -> res = "two"
|
||||
else -> res = null
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
fun test(n: Int): String {
|
||||
val res<caret> = when (n) {
|
||||
1 -> {
|
||||
println("***")
|
||||
"one"
|
||||
}
|
||||
else -> {
|
||||
println("***")
|
||||
"two"
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fun test(n: Int): String {
|
||||
val res<caret>: String
|
||||
when (n) {
|
||||
1 -> {
|
||||
println("***")
|
||||
res = "one"
|
||||
}
|
||||
else -> {
|
||||
println("***")
|
||||
res = "two"
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
fun test(n: Int): String {
|
||||
var res<caret> = when (n) {
|
||||
1 -> {
|
||||
println("***")
|
||||
"one"
|
||||
}
|
||||
else -> {
|
||||
println("***")
|
||||
"two"
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fun test(n: Int): String {
|
||||
var res<caret>: String
|
||||
when (n) {
|
||||
1 -> {
|
||||
println("***")
|
||||
res = "one"
|
||||
}
|
||||
else -> {
|
||||
println("***")
|
||||
res = "two"
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fun test(n: Int): String? {
|
||||
val res<caret>: jet.String? = when(n) {
|
||||
1 -> "one"
|
||||
2 -> "two"
|
||||
else -> null
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun test(n: Int): String? {
|
||||
val res<caret>: jet.String?
|
||||
when(n) {
|
||||
1 -> res = "one"
|
||||
2 -> res = "two"
|
||||
else -> res = null
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
Reference in New Issue
Block a user