"Make types explicit in lambda" intention: not available on right brace + adapted to new lambda syntax + refactored

This commit is contained in:
Valentin Kipyatkov
2015-04-28 15:12:02 +03:00
parent 252399b9a9
commit f9d690db21
29 changed files with 34 additions and 158 deletions
@@ -5,5 +5,5 @@ public class TestingUse {
}
fun main() {
val coercion = TestingUse().test5({(x: Int): Unit -> x + 2}, 20)
val coercion = TestingUse().test5({ x: Int -> x + 2}, 20)
}
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
fun main() {
val x = {<caret>(): Unit -> }
val x = {<caret> -> }
}
@@ -5,5 +5,5 @@ class TestingUse {
}
fun main() {
val num = TestingUse().test3({(it: Int): Int -> it * 2}, 20)
val num = TestingUse().test3({ it: Int -> it * 2}, 20)
}
@@ -1,6 +1,6 @@
fun main() {
val oom: (Int)->Int = {
(it: Int): Int ->
it: Int ->
it * 2
}
}
@@ -1,3 +1,4 @@
// IS_APPLICABLE: false
fun main() {
val oom = {<caret> -> 42}
}
@@ -1,3 +0,0 @@
fun main() {
val oom = {(): Int -> 42}
}
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
fun main() {
val sum : (Int, Int) -> Int = { (x, y) -> <caret>x + y }
val sum : (Int, Int) -> Int = { x, y -> <caret>x + y }
}
@@ -4,5 +4,5 @@ public class TestingUse {
}
fun main() {
val funcInfunc = TestingUse().test6({(f: (Int) -> Int): Boolean -> f(5) > 20}, {x -> x + 2})
val funcInfunc = TestingUse().test6({ f: (Int) -> Int -> f(5) > 20}, {x -> x + 2})
}
@@ -1,5 +1,5 @@
val foo: (Long) -> String = {
(it: Long): String ->
it: Long ->
it.toString()
@@ -6,5 +6,5 @@ class TestingUse {
}
fun main() {
val num = TestingUse().test4({(<caret>x, str) -> }, 5)
val num = TestingUse().test4({ <caret>x, str -> }, 5)
}
@@ -6,5 +6,5 @@ class TestingUse {
}
fun main() {
val num = TestingUse().test4({(x: Int, str: String): Unit -> }, 5)
val num = TestingUse().test4({ x: Int, str: String -> }, 5)
}
@@ -1,3 +0,0 @@
fun main() {
val foo: (Int) -> String = {(x: Int) -> "This number is " + x<caret>}
}
@@ -1,3 +0,0 @@
fun main() {
val foo: (Int) -> String = {(x: Int): String -> "This number is " + x}
}
@@ -1,3 +0,0 @@
fun main() {
val bar: (Array<String>) -> Int = {<caret>(arr): Int -> arr.size()}
}
@@ -1,3 +0,0 @@
fun main() {
val bar: (Array<String>) -> Int = {(arr: Array<String>): Int -> arr.size()}
}
@@ -1,5 +1,5 @@
fun main() {
val randomFunction: (x: kotlin.support.AbstractIterator<Int>, y: kotlin.String) -> kotlin.String = {(<caret>x, str) -> str}
val randomFunction: (x: kotlin.support.AbstractIterator<Int>, y: kotlin.String) -> kotlin.String = { <caret>x, str -> str}
}
// WITH_RUNTIME
@@ -1,7 +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): String -> str}
val randomFunction: (x: kotlin.support.AbstractIterator<Int>, y: kotlin.String) -> kotlin.String = { x: AbstractIterator<Int>, str: String -> str}
}
// WITH_RUNTIME
@@ -1,5 +0,0 @@
fun main() {
val randomFunction: kotlin.support.AbstractIterator<kotlin.Int>.(x: Int) -> Boolean = {<caret>y -> if (this.next() < y) true else false}
}
// WITH_RUNTIME
@@ -1,7 +0,0 @@
import kotlin.support.AbstractIterator
fun main() {
val randomFunction: kotlin.support.AbstractIterator<kotlin.Int>.(x: Int) -> Boolean = { AbstractIterator<Int>.(y: Int): Boolean -> if (this.next() < y) true else false}
}
// WITH_RUNTIME
@@ -1,5 +0,0 @@
fun main(c: kotlin.support.AbstractIterator<Int>) {
val f = { <caret>(x: Int) -> c}
}
// WITH_RUNTIME
@@ -1,7 +0,0 @@
import kotlin.support.AbstractIterator
fun main(c: kotlin.support.AbstractIterator<Int>) {
val f = {(x: Int): AbstractIterator<Int> -> c}
}
// WITH_RUNTIME
@@ -5,5 +5,5 @@ class TestingUse {
}
fun main() {
val num = TestingUse().test3({(x: Int): Int -> 2*x}, 20)
val num = TestingUse().test3({ x: Int -> 2*x}, 20)
}
@@ -1,9 +0,0 @@
class TestingUse {
fun test(sum: Int.(a: Int) -> Int, b: Int): Int {
return b.sum(b)
}
}
fun main() {
val num = TestingUse().test({ <caret>x -> x + 2 }, 20)
}
@@ -1,9 +0,0 @@
class TestingUse {
fun test(sum: Int.(a: Int) -> Int, b: Int): Int {
return b.sum(b)
}
}
fun main() {
val num = TestingUse().test({ Int.(x: Int): Int -> x + 2 }, 20)
}
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
fun main() {
val sum = { Int.(<caret>x: Int, y: Int) : Int -> x + y }
val sum = { <caret>x: Int, y: Int -> x + y }
}
@@ -2,5 +2,5 @@
// 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
val sum = { x, <caret>y -> x + y // Type of x and y cannot be inferred, so intention can't be used
}