"Change to return with label" quick fix: apply for type mismatch
#KT-32280 Fixed
This commit is contained in:
committed by
Yan Zhulanow
parent
016e78e483
commit
f76e98868c
@@ -0,0 +1,9 @@
|
||||
// "Change to 'return@foo'" "true"
|
||||
inline fun foo(f: (Int) -> Int) {}
|
||||
|
||||
fun test() {
|
||||
foo { i ->
|
||||
if (i == 1) return 1<caret>
|
||||
0
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Change to 'return@foo'" "true"
|
||||
inline fun foo(f: (Int) -> Int) {}
|
||||
|
||||
fun test() {
|
||||
foo { i ->
|
||||
if (i == 1) return@foo 1
|
||||
0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Change to 'return@foo'" "true"
|
||||
inline fun foo(f: (Int) -> Int?) {}
|
||||
|
||||
fun baz(): Int = 0
|
||||
|
||||
fun test() {
|
||||
foo { i ->
|
||||
if (i == 1) return null<caret>
|
||||
0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Change to 'return@foo'" "true"
|
||||
inline fun foo(f: (Int) -> Int?) {}
|
||||
|
||||
fun baz(): Int = 0
|
||||
|
||||
fun test() {
|
||||
foo { i ->
|
||||
if (i == 1) return@foo null
|
||||
0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Change to 'return@foo'" "false"
|
||||
// ACTION: Add braces to 'if' statement
|
||||
// ACTION: Change return type of enclosing function 'test' to 'Unit?'
|
||||
// DISABLE-ERRORS
|
||||
inline fun foo(f: (Int) -> Int) {}
|
||||
|
||||
fun baz(): Int = 0
|
||||
|
||||
fun test() {
|
||||
foo { i ->
|
||||
if (i == 1) return null<caret>
|
||||
0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Change to 'return@foo'" "true"
|
||||
inline fun foo(f: (Int) -> Int) {}
|
||||
|
||||
fun baz(): Int = 0
|
||||
|
||||
fun test() {
|
||||
foo { i ->
|
||||
if (i == 1) return baz()<caret>
|
||||
0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Change to 'return@foo'" "true"
|
||||
inline fun foo(f: (Int) -> Int) {}
|
||||
|
||||
fun baz(): Int = 0
|
||||
|
||||
fun test() {
|
||||
foo { i ->
|
||||
if (i == 1) return@foo baz()
|
||||
0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Change to 'return@foo'" "false"
|
||||
// ACTION: Add braces to 'if' statement
|
||||
// ACTION: Change parameter 'f' type of function 'foo' to '(Int) -> Unit'
|
||||
// ACTION: Change return type of called function 'baz' to 'Unit'
|
||||
// ACTION: Change return type of enclosing function 'test' to 'String'
|
||||
// ACTION: Convert to single-line lambda
|
||||
// ACTION: Enable a trailing comma by default in the formatter
|
||||
// ACTION: Move lambda argument into parentheses
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// DISABLE-ERRORS
|
||||
inline fun foo(f: (Int) -> Int) {}
|
||||
|
||||
fun baz(): String = ""
|
||||
|
||||
fun test() {
|
||||
foo { i ->
|
||||
if (i == 1) return baz()<caret>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user