mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Function references are now equal if they refer to the same function, and if the parameter/return type adaptation, which happens when a reference is used where some function type is expected, is exactly the same. This includes the number of expected positional parameters (which can be affected by defaults/varargs), whether the coercion of vararg parameter to Array type happened, and whether the coercion of return type to Unit happened. #KT-37543 Fixed
22 lines
585 B
Kotlin
Vendored
22 lines
585 B
Kotlin
Vendored
// IGNORE_BACKEND_FIR: JVM_IR
|
|
// FILE: test.kt
|
|
|
|
fun checkNotEqual(x: Any, y: Any) {
|
|
if (x == y || y == x) throw AssertionError("$x and $y should NOT be equal")
|
|
}
|
|
|
|
fun target(s1: String, vararg xs: Int, s2: String = "") {}
|
|
|
|
fun capture1(fn: (String, IntArray, String) -> Unit): Any = fn
|
|
fun capture2(fn: (String, Int, Int) -> Unit): Any = fn
|
|
|
|
fun box(): String {
|
|
checkNotEqual(capture1(::target), capture2(::target))
|
|
checkNotEqual(capture1(::target), captureFromOtherFile())
|
|
return "OK"
|
|
}
|
|
|
|
// FILE: fromOtherFile.kt
|
|
|
|
fun captureFromOtherFile(): Any = capture2(::target)
|