Added diagnostic tests for inference and incorporation
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo(a: Any, f: ()->Int) = f()
|
||||
fun foo(a: Any, f: (Any)->Int) = f(a)
|
||||
fun foo(i: Int, f: Int.()->Int) = i.f()
|
||||
|
||||
fun test1() {
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(1) { ->
|
||||
<!NO_THIS!>this<!>
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
internal fun foo(/*0*/ a: kotlin.Any, /*1*/ f: () -> kotlin.Int): kotlin.Int
|
||||
internal fun foo(/*0*/ a: kotlin.Any, /*1*/ f: (kotlin.Any) -> kotlin.Int): kotlin.Int
|
||||
internal fun foo(/*0*/ i: kotlin.Int, /*1*/ f: kotlin.Int.() -> kotlin.Int): kotlin.Int
|
||||
internal fun test1(): kotlin.Unit
|
||||
@@ -0,0 +1,8 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun <T, R> foo(first: () -> T, second: (T) -> R): R = throw Exception()
|
||||
fun test() {
|
||||
val r = foo( { 4 }, { "${it + 1}" } )
|
||||
r checkType { _<String>() }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
internal fun </*0*/ T, /*1*/ R> foo(/*0*/ first: () -> T, /*1*/ second: (T) -> R): R
|
||||
internal fun test(): kotlin.Unit
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun <T> foo(f: () -> Collection<T>, p: (T) -> Boolean): Collection<T> = throw Exception()
|
||||
|
||||
fun emptyList<T>(): List<T> = throw Exception()
|
||||
|
||||
fun test(): Collection<Int> = foo({ emptyList<Int>() }, { x -> x > 0 })
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
internal fun </*0*/ T> emptyList(): kotlin.List<T>
|
||||
internal fun </*0*/ T> foo(/*0*/ f: () -> kotlin.Collection<T>, /*1*/ p: (T) -> kotlin.Boolean): kotlin.Collection<T>
|
||||
internal fun test(): kotlin.Collection<kotlin.Int>
|
||||
+17
-17
@@ -10,26 +10,26 @@ fun foo(s: String, a: Any) = s + a
|
||||
fun foo(a: Any, s: String) = s + a
|
||||
fun foo(i: Int, j: Int) = i + j
|
||||
fun foo(a: Any, i: Int) = "$a$i"
|
||||
fun foo(f: (Int)->Int, i: Int) = f(i)
|
||||
fun foo(f: (String)->Int, s: String) = f(s)
|
||||
fun foo(f: (Any)->Int, a: Any) = f(a)
|
||||
fun foo(s: String, f: (String)->Int) = f(s)
|
||||
fun foo(a: Any, f: (Any)->Int) = f(a)
|
||||
fun foo(f: (Int) -> Int, i: Int) = f(i)
|
||||
fun foo(f: (String) -> Int, s: String) = f(s)
|
||||
fun foo(f: (Any) -> Int, a: Any) = f(a)
|
||||
fun foo(s: String, f: (String) -> Int) = f(s)
|
||||
fun foo(a: Any, f: (Any) -> Int) = f(a)
|
||||
//appropriate function
|
||||
fun foo(i: Int, f: (Int)->Int) = f(i)
|
||||
fun foo(i: Int, f: (Int) -> Int) = f(i)
|
||||
|
||||
fun id<T>(t: T) = t
|
||||
|
||||
fun test() {
|
||||
foo(1, id { <!DEPRECATED_LAMBDA_SYNTAX!>(x1: Int):Int<!> ->
|
||||
foo(2, id { <!DEPRECATED_LAMBDA_SYNTAX!>(x2: Int): Int<!> ->
|
||||
foo(3, id { <!DEPRECATED_LAMBDA_SYNTAX!>(x3: Int): Int<!> ->
|
||||
foo(4, id { <!DEPRECATED_LAMBDA_SYNTAX!>(x4: Int): Int<!> ->
|
||||
foo(5, id { <!DEPRECATED_LAMBDA_SYNTAX!>(x5: Int): Int<!> ->
|
||||
x1 + x2 + x3 + x4 + x5 + A.iii
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
foo(1, id(fun(x1: Int) =
|
||||
foo(2, id(fun(x2: Int) =
|
||||
foo(3, id(fun(x3: Int) =
|
||||
foo(4, id(fun(x4: Int) =
|
||||
foo(5, id(fun(x5: Int) =
|
||||
x1 + x2 + x3 + x4 + x5 + A.iii
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user