Convert to expression body is forbidden for if without else #KT-12951 Fixed
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun nullable() {}
|
||||
|
||||
fun bar() {}
|
||||
|
||||
fun foo(f: Boolean) {
|
||||
<caret>nullable() ?: if (f) bar() else bar()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun nullable() {}
|
||||
|
||||
fun bar() {}
|
||||
|
||||
fun foo(f: Boolean) = nullable() ?: if (f) bar() else bar()
|
||||
@@ -0,0 +1,9 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun nullable() {}
|
||||
|
||||
fun bar() {}
|
||||
|
||||
fun foo(f: Boolean) {
|
||||
<caret>nullable() ?: if (f) bar()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun bar() {}
|
||||
|
||||
fun foo(f: Boolean) {
|
||||
<caret>if (f) bar() else bar()
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun bar() {}
|
||||
|
||||
fun foo(f: Boolean) = if (f) bar() else bar()
|
||||
@@ -0,0 +1,7 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun bar() {}
|
||||
|
||||
fun foo(f: Boolean) {
|
||||
<caret>if (f) bar()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun <T> run(f: () -> T) = f()
|
||||
fun whenExpr(flag: Boolean) {
|
||||
<caret>run {
|
||||
println("run")
|
||||
if (flag) {
|
||||
println("flag")
|
||||
}
|
||||
}
|
||||
}
|
||||
fun println(s: String) {}
|
||||
@@ -0,0 +1,10 @@
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun <T> run(f: () -> T) = f()
|
||||
fun whenExpr(flag: Boolean) = run {
|
||||
println("run")
|
||||
if (flag) {
|
||||
println("flag")
|
||||
}
|
||||
}
|
||||
fun println(s: String) {}
|
||||
@@ -0,0 +1,10 @@
|
||||
// IS_APPLICABLE: true
|
||||
enum class AccessMode { READ, WRITE, RW }
|
||||
fun whenExpr(mode: Boolean, access: AccessMode) {
|
||||
<caret>when (access) {
|
||||
AccessMode.READ -> if (mode) println("read") else println("noread")
|
||||
AccessMode.WRITE -> if (mode) println("write") else println("nowrite")
|
||||
AccessMode.RW -> if (mode) println("both") else println("no both")
|
||||
}
|
||||
}
|
||||
fun println(s: String) {}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: true
|
||||
enum class AccessMode { READ, WRITE, RW }
|
||||
fun whenExpr(mode: Boolean, access: AccessMode) = when (access) {
|
||||
AccessMode.READ -> if (mode) println("read") else println("noread")
|
||||
AccessMode.WRITE -> if (mode) println("write") else println("nowrite")
|
||||
AccessMode.RW -> if (mode) println("both") else println("no both")
|
||||
}
|
||||
fun println(s: String) {}
|
||||
@@ -0,0 +1,10 @@
|
||||
// IS_APPLICABLE: false
|
||||
enum class AccessMode { READ, WRITE, RW }
|
||||
fun whenExpr(mode: Boolean, access: AccessMode) {
|
||||
<caret>when (access) {
|
||||
AccessMode.READ -> if (mode) println("read") else println("noread")
|
||||
AccessMode.WRITE -> if (mode) println("write")
|
||||
AccessMode.RW -> if (mode) println("both") else println("no both")
|
||||
}
|
||||
}
|
||||
fun println(s: String) {}
|
||||
Reference in New Issue
Block a user