Elvis -> if intention: don't produce boilerplate code for return/break/continue/throw in RHS
#KT-14369 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
160de2dbe2
commit
2c424afefa
@@ -0,0 +1,5 @@
|
||||
fun foo(s: String?) {
|
||||
while (true) {
|
||||
val t = s?.hashCode() ?:<caret> break
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun foo(s: String?) {
|
||||
while (true) {
|
||||
val t = s?.hashCode()
|
||||
if (t == null) break
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun foo(s: String?) {
|
||||
while (true) {
|
||||
val t = s?.hashCode() ?:<caret> continue
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun foo(s: String?) {
|
||||
while (true) {
|
||||
val t = s?.hashCode()
|
||||
if (t == null) continue
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(s: String?) {
|
||||
val t = s?.hashCode() ?:<caret> return
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun foo(s: String?) {
|
||||
val t = s?.hashCode()
|
||||
if (t == null) return
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(s: String?) {
|
||||
val t = s?.hashCode() ?:<caret> throw Exception()
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(s: String?) {
|
||||
val t = s?.hashCode()
|
||||
if (t == null) throw Exception()
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class My(val x: Int)
|
||||
fun foo(arg: Any) {
|
||||
val y = (arg as? My)?.x <caret>?: return
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class My(val x: Int)
|
||||
fun foo(arg: Any) {
|
||||
val y = if (arg is My) arg.x else return
|
||||
}
|
||||
Reference in New Issue
Block a user