MoveLambdaOutsideParentheses: intention -> inspection #KT-21413 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
83573ed517
commit
decf9939fe
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.MoveLambdaOutsideParenthesesInspection
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// IS_AVAILABLE: true
|
||||
// ERROR: None of the following functions can be called with the arguments supplied: <br>public fun bar(a: Int = ..., f: (Int) -> Int): Unit defined in root package in file ambigousOverload.kt<br>public fun bar(a: Int, b: Int, f: (Int) -> Int): Unit defined in root package in file ambigousOverload.kt
|
||||
// ERROR: Unresolved reference: it
|
||||
// SKIP_ERRORS_AFTER
|
||||
|
||||
fun foo() {
|
||||
bar(<caret>{ it })
|
||||
}
|
||||
|
||||
fun bar(a: Int = 0, f: (Int) -> Int) { }
|
||||
fun bar(a: Int, b: Int, f: (Int) -> Int) { }
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// IS_AVAILABLE: true
|
||||
// ERROR: None of the following functions can be called with the arguments supplied: <br>public fun bar(a: Int = ..., f: (Int) -> Int): Unit defined in root package in file ambigousOverload.kt<br>public fun bar(a: Int, b: Int, f: (Int) -> Int): Unit defined in root package in file ambigousOverload.kt
|
||||
// ERROR: Unresolved reference: it
|
||||
// SKIP_ERRORS_AFTER
|
||||
|
||||
fun foo() {
|
||||
bar<caret> { it }
|
||||
}
|
||||
|
||||
fun bar(a: Int = 0, f: (Int) -> Int) { }
|
||||
fun bar(a: Int, b: Int, f: (Int) -> Int) { }
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(p: (Int, () -> Int) -> Unit) {
|
||||
p(1, <caret>{ 2 })
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(p: (Int, () -> Int) -> Unit) {
|
||||
p(1<caret>) { 2 }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: none
|
||||
fun foo() {
|
||||
bar() <caret>{ it }
|
||||
}
|
||||
|
||||
fun bar(b: (Int) -> Int) {
|
||||
b(1)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: none
|
||||
fun <T> doSomething(a: T) {}
|
||||
|
||||
fun foo(x: Int) {
|
||||
if (x == 1) <caret>{
|
||||
doSomething(x)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
fun <T> doSomething(a: T) {}
|
||||
|
||||
fun foo(x: Int) {
|
||||
if (x == 1) {
|
||||
doSomething(x)
|
||||
}
|
||||
}
|
||||
|
||||
fun x() <caret>{ doSomething("x") }
|
||||
idea/testData/inspectionsLocal/moveLambdaOutsideParentheses/inapplicableAlreadyHasFunctionLiteral.kt
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: none
|
||||
fun foo() {
|
||||
bar(<caret>{ it }) {it}
|
||||
}
|
||||
|
||||
fun bar(p1: (Int) -> Int, p2: (Int) -> Int) { }
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: none
|
||||
fun foo() {
|
||||
bar(<caret>{ it })
|
||||
}
|
||||
|
||||
fun bar(b: (Int) -> Int, option: Int = 0) { }
|
||||
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun foo() {
|
||||
bar(2, <caret>l@{ it })
|
||||
}
|
||||
|
||||
fun bar(a: Int, b: (Int) -> Int) {
|
||||
b(a)
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun foo() {
|
||||
bar(2) l@{ it }
|
||||
}
|
||||
|
||||
fun bar(a: Int, b: (Int) -> Int) {
|
||||
b(a)
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun bar(f: () -> Unit) {}
|
||||
fun foo(a: Int, b: Int) = 2
|
||||
|
||||
fun test() {
|
||||
bar({
|
||||
<caret>val a = foo(1, 2)
|
||||
})
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun bar(f: () -> Unit) {}
|
||||
fun foo(a: Int, b: Int) = 2
|
||||
|
||||
fun test() {
|
||||
bar {
|
||||
val a = foo(1, 2)
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun bar(x: Int, f: () -> Unit) {}
|
||||
fun foo(a: Int, b: Int) = 2
|
||||
|
||||
fun test() {
|
||||
bar(1, {
|
||||
<caret>val a = foo(1, 2)
|
||||
})
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun bar(x: Int, f: () -> Unit) {}
|
||||
fun foo(a: Int, b: Int) = 2
|
||||
|
||||
fun test() {
|
||||
bar(1) {
|
||||
val a = foo(1, 2)
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun bar(a: Int, b: Int, f: () -> Unit) {}
|
||||
fun foo(a: Int, b: Int) = 2
|
||||
|
||||
fun test() {
|
||||
bar(1, 2, /* , , */ {
|
||||
<caret>val a = foo(1, 2)
|
||||
})
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun bar(a: Int, b: Int, f: () -> Unit) {}
|
||||
fun foo(a: Int, b: Int) = 2
|
||||
|
||||
fun test() {
|
||||
bar(1, 2 /* , , */) {
|
||||
val a = foo(1, 2)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun foo() {
|
||||
bar(2, <caret>{ it })
|
||||
}
|
||||
|
||||
fun bar(a: Int, b: (Int) -> Int) {
|
||||
b(a)
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun foo() {
|
||||
bar(2) { it }
|
||||
}
|
||||
|
||||
fun bar(a: Int, b: (Int) -> Int) {
|
||||
b(a)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun foo() {
|
||||
bar(a = 2, b = {<caret> it })
|
||||
}
|
||||
|
||||
fun bar(a: Int, b: (Int) -> Int) {
|
||||
b(a)
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun foo() {
|
||||
bar(a = 2) { it }
|
||||
}
|
||||
|
||||
fun bar(a: Int, b: (Int) -> Int) {
|
||||
b(a)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// IS_APPLICABLE: true
|
||||
// ERROR: Type mismatch: inferred type is () -> ??? but Int was expected
|
||||
// ERROR: No value passed for parameter 'b'
|
||||
// ERROR: Unresolved reference: it
|
||||
// SKIP_ERRORS_AFTER
|
||||
fun foo() {
|
||||
bar({ it <caret>})
|
||||
}
|
||||
|
||||
fun bar(a: Int, b: (Int) -> Int) {
|
||||
b(a)
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// IS_APPLICABLE: true
|
||||
// ERROR: Type mismatch: inferred type is () -> ??? but Int was expected
|
||||
// ERROR: No value passed for parameter 'b'
|
||||
// ERROR: Unresolved reference: it
|
||||
// SKIP_ERRORS_AFTER
|
||||
fun foo() {
|
||||
bar<caret> { it }
|
||||
}
|
||||
|
||||
fun bar(a: Int, b: (Int) -> Int) {
|
||||
b(a)
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun foo() {
|
||||
bar(2, {
|
||||
val x = 3
|
||||
it * x
|
||||
<caret>})
|
||||
}
|
||||
|
||||
fun bar(a: Int, b: (Int) -> Int) {
|
||||
b(a)
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun foo() {
|
||||
bar(2) {
|
||||
val x = 3
|
||||
it * x
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(a: Int, b: (Int) -> Int) {
|
||||
b(a)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun foo() {
|
||||
bar(name1 = 3, name2 = 2, name3 = 1, <caret>name4 = { it })
|
||||
}
|
||||
|
||||
fun bar(name1: Int, name2: Int, name3: Int, name4: (Int) -> Int) : Int {
|
||||
return name4(name1) + name2 + name3
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun foo() {
|
||||
bar(name1 = 3, name2 = 2, name3 = 1) { it }
|
||||
}
|
||||
|
||||
fun bar(name1: Int, name2: Int, name3: Int, name4: (Int) -> Int) : Int {
|
||||
return name4(name1) + name2 + name3
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun foo() {
|
||||
bar(3, 2, 1, { it <caret>})
|
||||
}
|
||||
|
||||
fun bar(name1: Int, name2: Int, name3: Int, name4: (Int) -> Int) : Int {
|
||||
return name4(name1) + name2 + name3
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: true
|
||||
fun foo() {
|
||||
bar(3, 2, 1) { it }
|
||||
}
|
||||
|
||||
fun bar(name1: Int, name2: Int, name3: Int, name4: (Int) -> Int) : Int {
|
||||
return name4(name1) + name2 + name3
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fun bar() {
|
||||
foo { "one" } (<caret>{ "two" })
|
||||
}
|
||||
|
||||
fun foo(a: () -> String): (() -> String) -> Unit {
|
||||
return { }
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
fun bar() {
|
||||
foo { "one" } () { "two" }
|
||||
}
|
||||
|
||||
fun foo(a: () -> String): (() -> String) -> Unit {
|
||||
return { }
|
||||
}
|
||||
Reference in New Issue
Block a user