Introduce quick-fix adding label to 'return' in closures #KT-16851 Fixed

This commit is contained in:
shiraji
2017-04-29 00:37:40 +09:00
committed by Mikhail Glukhikh
parent 2f7ab1c0c1
commit 56d712a02a
10 changed files with 204 additions and 0 deletions
@@ -0,0 +1,17 @@
// "Change to 'return@forEach'" "true"
// ACTION: Change to 'return@foo'
// ACTION: Introduce local variable
// ERROR: The integer literal does not conform to the expected type Unit
// WITH_RUNTIME
fun foo(f:()->Int){}
fun bar() {
foo {
listOf(1).forEach {
return<caret> 1
}
return@foo 1
}
}
@@ -0,0 +1,17 @@
// "Change to 'return@forEach'" "true"
// ACTION: Change to 'return@foo'
// ACTION: Introduce local variable
// ERROR: The integer literal does not conform to the expected type Unit
// WITH_RUNTIME
fun foo(f:()->Int){}
fun bar() {
foo {
listOf(1).forEach {
return@forEach 1
}
return@foo 1
}
}
@@ -0,0 +1,16 @@
// "Change to 'return@foo'" "true"
// ACTION: Change to 'return@forEach'
// ACTION: Introduce local variable
// WITH_RUNTIME
fun foo(f:()->Int){}
fun bar() {
foo {
listOf(1).forEach {
return<caret> 1
}
return@foo 1
}
}
@@ -0,0 +1,16 @@
// "Change to 'return@foo'" "true"
// ACTION: Change to 'return@forEach'
// ACTION: Introduce local variable
// WITH_RUNTIME
fun foo(f:()->Int){}
fun bar() {
foo {
listOf(1).forEach {
return@foo 1
}
return@foo 1
}
}
@@ -0,0 +1,10 @@
// "Change to 'return@init'" "false"
// ACTION: Introduce local variable
// ERROR: 'return' is not allowed here
// WITH_RUNTIME
class Foo {
init {
return<caret> 1
}
}
@@ -0,0 +1,9 @@
// "Change to 'return@foo'" "true"
fun foo(f:()->Int){}
fun bar() {
foo {
return<caret> 1
}
}
@@ -0,0 +1,9 @@
// "Change to 'return@foo'" "true"
fun foo(f:()->Int){}
fun bar() {
foo {
return@foo 1
}
}