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:
@@ -0,0 +1,23 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// WITH_RUNTIME
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun foo(x: Int?) {}
|
||||
fun foo(y: String?) {}
|
||||
fun foo(z: Boolean) {}
|
||||
|
||||
inline fun <reified T> bar(f: (T) -> Unit, tType: String): T? {
|
||||
assertEquals(tType, T::class.simpleName)
|
||||
return null
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a1: Int? = bar(::foo, "Int")
|
||||
val a2: String? = bar(::foo, "String")
|
||||
val a3: Boolean? = bar<Boolean>(::foo, "Boolean")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user