Introduce "Function with = { ... }" inspection

#KT-17119 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-12-11 17:36:17 +09:00
committed by Mikhail Glukhikh
parent 301b3aad06
commit 538a746df9
52 changed files with 622 additions and 1 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.FunctionWithLambdaExpressionBodyInspection
@@ -0,0 +1,2 @@
// FIX: Specify explicit lambda signature
fun test(a: Int, b: Int) = <caret>{ a + b }
@@ -0,0 +1,2 @@
// FIX: Specify explicit lambda signature
fun test(a: Int, b: Int) = { -> a + b }
@@ -0,0 +1,2 @@
// FIX: Specify explicit lambda signature
val test get() = <caret>{ "" }
@@ -0,0 +1,2 @@
// FIX: Specify explicit lambda signature
val test get() = { -> "" }
@@ -0,0 +1,2 @@
// PROBLEM: none
fun test(a: Int, b: Int) = <caret>{ -> a + b }
@@ -0,0 +1,4 @@
// PROBLEM: none
fun test(a: Int, b: Int) = label@<caret>{
return@label
}
@@ -0,0 +1,2 @@
// PROBLEM: none
fun test(a: Int, b: Int) <caret>{ { a + b } }
@@ -0,0 +1,2 @@
// PROBLEM: none
fun test(a: Int, b: Int) = <caret>a + b
@@ -0,0 +1,2 @@
// PROBLEM: none
fun test(a: Int, b: Int): () -> Int = <caret>{ a + b }
@@ -0,0 +1,2 @@
// PROBLEM: none
val test get() = <caret>{ -> "" }
@@ -0,0 +1,5 @@
// PROBLEM: none
val test
get() = label@<caret>{
return@label
}
@@ -0,0 +1,2 @@
// PROBLEM: none
val test get() = <caret>""
@@ -0,0 +1,2 @@
// PROBLEM: none
val test: () -> String get() = <caret>{ "" }
@@ -0,0 +1,2 @@
// PROBLEM: none
val test get(): () -> String = <caret>{ "" }
@@ -0,0 +1,2 @@
// FIX: Remove braces
fun test(a: Int, b: Int) = <caret>{ a + b }
@@ -0,0 +1,2 @@
// FIX: Remove braces
fun test(a: Int, b: Int) = a + b
@@ -0,0 +1,3 @@
// FIX: Remove braces
// WITH_RUNTIME
fun test() = <caret>{ error("") }
@@ -0,0 +1,3 @@
// FIX: Remove braces
// WITH_RUNTIME
fun test(): Nothing = error("")
@@ -0,0 +1,2 @@
// FIX: Remove braces
val test get() = <caret>{ "" }
@@ -0,0 +1,2 @@
// FIX: Remove braces
val test get() = ""
@@ -0,0 +1,3 @@
// FIX: Remove braces
// WITH_RUNTIME
val test get() = <caret>{ error("") }
@@ -0,0 +1,3 @@
// FIX: Remove braces
// WITH_RUNTIME
val test: Nothing get() = error("")
@@ -0,0 +1,2 @@
// FIX: Specify return type explicitly
fun test(a: Int, b: Int) = <caret>{ a + b }
@@ -0,0 +1,2 @@
// FIX: Specify return type explicitly
fun test(a: Int, b: Int): () -> Int = { a + b }
@@ -0,0 +1,2 @@
// FIX: Specify type explicitly
val test get() = <caret>{ "" }
@@ -0,0 +1,2 @@
// FIX: Specify type explicitly
val test: () -> String get() = { "" }
@@ -0,0 +1,3 @@
// FIX: Convert to run { ... }
// WITH_RUNTIME
fun test(a: Int, b: Int) = <caret>{ a + b }
@@ -0,0 +1,3 @@
// FIX: Convert to run { ... }
// WITH_RUNTIME
fun test(a: Int, b: Int) = run { a + b }
@@ -0,0 +1,3 @@
// FIX: Convert to run { ... }
// WITH_RUNTIME
fun test() = <caret>{ error("") }
@@ -0,0 +1,3 @@
// FIX: Convert to run { ... }
// WITH_RUNTIME
fun test(): Nothing = run { error("") }
@@ -0,0 +1,3 @@
// FIX: Convert to run { ... }
// WITH_RUNTIME
val test get() = <caret>{ "" }
@@ -0,0 +1,3 @@
// FIX: Convert to run { ... }
// WITH_RUNTIME
val test get() = run { "" }
@@ -0,0 +1,3 @@
// FIX: Convert to run { ... }
// WITH_RUNTIME
val test get() = <caret>{ error("") }
@@ -0,0 +1,3 @@
// FIX: Convert to run { ... }
// WITH_RUNTIME
val test: Nothing get() = run { error("") }