Checking for unsupported return's

This commit is contained in:
Valentin Kipyatkov
2016-10-25 18:38:32 +03:00
parent 779ed32a4b
commit 85e1e53354
6 changed files with 79 additions and 2 deletions
@@ -0,0 +1,14 @@
// ERROR: Cannot perform refactoring.\nInline Function is not supported for functions with multiple return statements.
fun <caret>f(p1: Int, p2: Int): Int {
if (p1 > 0) {
return p2
}
else {
return -1
}
}
fun g() {
f(1, 2)
}
@@ -0,0 +1,13 @@
// ERROR: Cannot perform refactoring.\nInline Function is not supported for functions with return statements not at the end of the body.
fun <caret>f(p1: Int, p2: Int): Int {
while (true) {
if (x() > p1) return@f p2
}
}
fun x(): Int = TODO()
fun g() {
f(1, 2)
}
@@ -0,0 +1,10 @@
fun <caret>f(list: List<String>): Boolean {
return list.any {
if (it.isEmpty()) return@any false
it.length < 10
}
}
fun g() {
println(f(listOf("a", "b")))
}
@@ -0,0 +1,6 @@
fun g() {
println(listOf("a", "b").any {
if (it.isEmpty()) return@any false
it.length < 10
})
}