KT-25272: Unused expression as last expression of normal function should have quickfix to add "return" Fixed

This commit is contained in:
Dereck Bridie
2019-03-04 14:41:41 +01:00
committed by Dmitry Gridin
parent e02877d1dc
commit a02ad76b16
17 changed files with 269 additions and 0 deletions
@@ -0,0 +1,8 @@
// "Add 'return' to last expression" "false"
// ERROR: A 'return' expression required in a function with a block body ('{...}')
// ACTION: Introduce local variable
// ACTION: Remove explicitly specified return type of enclosing function 'test'
fun test(): Boolean {
5
}<caret>
@@ -0,0 +1,5 @@
// "Add 'return' to last expression" "false"
fun test(): Nothing {
throw RuntimeException("test")
}<caret>
@@ -0,0 +1,4 @@
// "Add 'return' to last expression" "true"
fun test(): Boolean {
true
}<caret>
@@ -0,0 +1,4 @@
// "Add 'return' to last expression" "true"
fun test(): Boolean {
return true
}
@@ -0,0 +1,6 @@
// "Add 'return' to last expression" "true"
// WITH_RUNTIME
fun foo(): Any {
true
}<caret>
@@ -0,0 +1,6 @@
// "Add 'return' to last expression" "true"
// WITH_RUNTIME
fun foo(): Any {
return true
}
@@ -0,0 +1,7 @@
// "Add 'return' before the expression" "false"
// ERROR: A 'return' expression required in a function with a block body ('{...}')
// ACTION: Introduce local variable
fun test(): Boolean {
<caret>5
}
@@ -0,0 +1,6 @@
// "Add 'return' before the expression" "false"
// ACTION: Add '@Throws' annotation
fun test(): Nothing {
<caret>throw RuntimeException("test")
}
@@ -0,0 +1,4 @@
// "Add 'return' before the expression" "true"
fun test(): Boolean {
<caret>true
}
@@ -0,0 +1,4 @@
// "Add 'return' before the expression" "true"
fun test(): Boolean {
return true
}
@@ -0,0 +1,6 @@
// "Add 'return' before the expression" "true"
// WITH_RUNTIME
fun foo(): Any {
<caret>true
}
@@ -0,0 +1,6 @@
// "Add 'return' before the expression" "true"
// WITH_RUNTIME
fun foo(): Any {
return true
}