"Make types explicit in lambda" intention renamed to "Specify explicit lambda signature"

This commit is contained in:
Valentin Kipyatkov
2015-04-28 15:16:43 +03:00
parent f9d690db21
commit f1fa33548a
29 changed files with 90 additions and 90 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.intentions.SpecifyExplicitLambdaSignatureIntention
@@ -0,0 +1,9 @@
public class TestingUse {
fun test5(coerced: (x: Int) -> Unit, a: Int): Unit {
return coerced(5)
}
}
fun main() {
val coercion = TestingUse().test5({<caret>x -> x + 2}, 20)
}
@@ -0,0 +1,9 @@
public class TestingUse {
fun test5(coerced: (x: Int) -> Unit, a: Int): Unit {
return coerced(5)
}
}
fun main() {
val coercion = TestingUse().test5({ x: Int -> x + 2}, 20)
}
@@ -0,0 +1,4 @@
// IS_APPLICABLE: false
fun main() {
val x = {<caret> -> }
}
@@ -0,0 +1,9 @@
class TestingUse {
fun test3(double: (a: Int) -> Int, b: Int): Int {
return double(b)
}
}
fun main() {
val num = TestingUse().test3({<caret>it * 2}, 20)
}
@@ -0,0 +1,9 @@
class TestingUse {
fun test3(double: (a: Int) -> Int, b: Int): Int {
return double(b)
}
}
fun main() {
val num = TestingUse().test3({ it: Int -> it * 2}, 20)
}
@@ -0,0 +1,5 @@
fun main() {
val oom: (Int)->Int = {<caret>
it * 2
}
}
@@ -0,0 +1,6 @@
fun main() {
val oom: (Int)->Int = {
it: Int ->
it * 2
}
}
@@ -0,0 +1,4 @@
// IS_APPLICABLE: false
fun main() {
val oom = {<caret> -> 42}
}
@@ -0,0 +1,4 @@
// IS_APPLICABLE: false
fun main() {
val sum : (Int, Int) -> Int = { x, y -> <caret>x + y }
}
@@ -0,0 +1,8 @@
public class TestingUse {
fun test6(funcLitfunc: ((x: Int) -> Int) -> Boolean, innerfunc: (y: Int) -> Int): Unit {
}
}
fun main() {
val funcInfunc = TestingUse().test6({<caret>f -> f(5) > 20}, {x -> x + 2})
}
@@ -0,0 +1,8 @@
public class TestingUse {
fun test6(funcLitfunc: ((x: Int) -> Int) -> Boolean, innerfunc: (y: Int) -> Int): Unit {
}
}
fun main() {
val funcInfunc = TestingUse().test6({ f: (Int) -> Int -> f(5) > 20}, {x -> x + 2})
}
@@ -0,0 +1,8 @@
val foo: (Long) -> String = {<caret>
it.toString()
}
@@ -0,0 +1,6 @@
val foo: (Long) -> String = {
it: Long ->
it.toString()
}
@@ -0,0 +1,10 @@
class TestingUse {
fun test4(printNum: (a: Int, b: String) -> Unit, c: Int): Int {
printNum(c, "This number is")
return c
}
}
fun main() {
val num = TestingUse().test4({ <caret>x, str -> }, 5)
}
@@ -0,0 +1,10 @@
class TestingUse {
fun test4(printNum: (a: Int, b: String) -> Unit, c: Int): Int {
printNum(c, "This number is")
return c
}
}
fun main() {
val num = TestingUse().test4({ x: Int, str: String -> }, 5)
}
@@ -0,0 +1,5 @@
fun main() {
val randomFunction: (x: kotlin.support.AbstractIterator<Int>, y: kotlin.String) -> kotlin.String = { <caret>x, str -> str}
}
// WITH_RUNTIME
@@ -0,0 +1,7 @@
import kotlin.support.AbstractIterator
fun main() {
val randomFunction: (x: kotlin.support.AbstractIterator<Int>, y: kotlin.String) -> kotlin.String = { x: AbstractIterator<Int>, str: String -> str}
}
// WITH_RUNTIME
@@ -0,0 +1,9 @@
class TestingUse {
fun test3(double: (a: Int) -> Int, b: Int): Int {
return double(b)
}
}
fun main() {
val num = TestingUse().test3({<caret>x -> 2*x}, 20)
}
@@ -0,0 +1,9 @@
class TestingUse {
fun test3(double: (a: Int) -> Int, b: Int): Int {
return double(b)
}
}
fun main() {
val num = TestingUse().test3({ x: Int -> 2*x}, 20)
}
@@ -0,0 +1,4 @@
// IS_APPLICABLE: false
fun main() {
val sum = { <caret>x: Int, y: Int -> x + y }
}
@@ -0,0 +1,6 @@
// IS_APPLICABLE: false
// ERROR: Cannot infer a type for this parameter. Please specify it explicitly.
// ERROR: Cannot infer a type for this parameter. Please specify it explicitly.
fun main() {
val sum = { x, <caret>y -> x + y // Type of x and y cannot be inferred, so intention can't be used
}