Support cascade if / when in lift return / assignment intentions

So #KT-13458 Fixed
So #KT-13436 Fixed
This commit is contained in:
Toshiaki Kameyama
2017-06-16 11:48:36 +03:00
committed by Mikhail Glukhikh
parent ed04b4debd
commit c2707bb81b
14 changed files with 272 additions and 107 deletions
@@ -0,0 +1,18 @@
// WITH_RUNTIME
fun test(x: Any) {
var res: String
<caret>if (x is String)
when {
x.length > 3 -> res = "long string"
else -> res = "short string"
}
else if (x is Int)
when {
x > 999 || x < -99 -> res = "long int"
else -> res = "short int"
}
else if (x is Long)
TODO()
else
res = "I don't know"
}
@@ -0,0 +1,18 @@
// WITH_RUNTIME
fun test(x: Any) {
var res: String
<caret>res = if (x is String)
when {
x.length > 3 -> "long string"
else -> "short string"
}
else if (x is Int)
when {
x > 999 || x < -99 -> "long int"
else -> "short int"
}
else if (x is Long)
TODO()
else
"I don't know"
}
@@ -0,0 +1,17 @@
// WITH_RUNTIME
fun test(x: Any): String {
<caret>if (x is String)
when {
x.length > 3 -> return "long string"
else -> return "short string"
}
else if (x is Int)
when {
x > 999 || x < -99 -> return "long int"
else -> return "short int"
}
else if (x is Long)
TODO()
else
return "I don't know"
}
@@ -0,0 +1,17 @@
// WITH_RUNTIME
fun test(x: Any): String {
<caret>return if (x is String)
when {
x.length > 3 -> "long string"
else -> "short string"
}
else if (x is Int)
when {
x > 999 || x < -99 -> "long int"
else -> "short int"
}
else if (x is Long)
TODO()
else
"I don't know"
}
@@ -0,0 +1,16 @@
// WITH_RUNTIME
fun test(x: Any) {
var res: String
<caret>when (x) {
is String ->
if (x.length > 3) res = "long string"
else res = "short string"
is Int ->
if (x > 999 || x < -99) res = "long int"
else res = "short int"
is Long ->
TODO()
else ->
res = "I don't know"
}
}
@@ -0,0 +1,16 @@
// WITH_RUNTIME
fun test(x: Any) {
var res: String
<caret>res = when (x) {
is String ->
if (x.length > 3) "long string"
else "short string"
is Int ->
if (x > 999 || x < -99) "long int"
else "short int"
is Long ->
TODO()
else ->
"I don't know"
}
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
fun test(x: Any): String {
<caret>when (x) {
is String ->
if (x.length > 3) return "long string"
else return "short string"
is Int ->
if (x > 999 || x < -99) return "long int"
else return "short int"
is Long ->
TODO()
else ->
return "I don't know"
}
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
fun test(x: Any): String {
<caret>return when (x) {
is String ->
if (x.length > 3) "long string"
else "short string"
is Int ->
if (x > 999 || x < -99) "long int"
else "short int"
is Long ->
TODO()
else ->
"I don't know"
}
}