mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 00:21:26 +00:00
Improve inference on generics for callable references
#KT-10711 Fixed #KT-12802 Fixed #KT-12964 Fixed #KT-15439 Fixed Analyze callable references in `dependent` mode, then complete them with respect to expected types
This commit is contained in:
29
compiler/testData/codegen/box/callableReference/function/genericCallableReferenceArguments.kt
vendored
Normal file
29
compiler/testData/codegen/box/callableReference/function/genericCallableReferenceArguments.kt
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// WITH_RUNTIME
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun <T, R> foo(x: T): R = TODO()
|
||||
fun <T> fooReturnInt(x: T): Int = 1
|
||||
|
||||
inline fun <reified T, reified R> check(x: T, y: R, f: (T) -> R, tType: String, rType: String) {
|
||||
assertEquals(tType, T::class.simpleName)
|
||||
assertEquals(rType, R::class.simpleName)
|
||||
}
|
||||
|
||||
inline fun <reified T, reified R> check(f: (T) -> R, g: (T) -> R, tType: String, rType: String) {
|
||||
assertEquals(tType, T::class.simpleName)
|
||||
assertEquals(rType, R::class.simpleName)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
check("", 1, ::foo, "String", "Int")
|
||||
check("", 1, ::fooReturnInt, "String", "Int")
|
||||
check("", "", ::fooReturnInt, "String", "Any")
|
||||
|
||||
check(Int::toString, ::foo, "Int", "String")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user