mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
It's used as a superclass for anonymous classes for adapted function references. Its main feature is that it _doesn't_ inherit from KFunction (as opposed to FunctionReference), as per the decision to postpone reflection support for adapted function references in KT-36024. #KT-36024 Fixed
35 lines
1.2 KiB
Kotlin
Vendored
35 lines
1.2 KiB
Kotlin
Vendored
// IGNORE_BACKEND: JS, JS_IR, NATIVE
|
|
// IGNORE_BACKEND_FIR: JVM_IR
|
|
// FILE: test.kt
|
|
|
|
fun checkEqual(x: Any, y: Any) {
|
|
if (x != y || y != x) throw AssertionError("$x and $y should be equal")
|
|
if (x.hashCode() != y.hashCode()) throw AssertionError("$x and $y should have the same hash code")
|
|
}
|
|
|
|
fun checkNotEqual(x: Any, y: Any) {
|
|
if (x == y || y == x) throw AssertionError("$x and $y should NOT be equal")
|
|
}
|
|
|
|
fun target(x: Int, y: String = "", z: String = ""): Int = x
|
|
|
|
fun captureNoDefaults(fn: (Int, String, String) -> Unit): Any = fn
|
|
fun captureOneDefault(fn: (Int, String) -> Unit): Any = fn
|
|
fun captureAllDefaults(fn: (Int) -> Unit): Any = fn
|
|
|
|
fun box(): String {
|
|
checkEqual(captureNoDefaults(::target), captureNoDefaults(::target))
|
|
checkEqual(captureOneDefault(::target), captureOneDefault(::target))
|
|
checkEqual(captureAllDefaults(::target), captureAllDefaults(::target))
|
|
checkEqual(captureNoDefaults(::target), captureNoDefaultsFromOtherFile())
|
|
|
|
checkNotEqual(captureNoDefaults(::target), captureOneDefault(::target))
|
|
checkNotEqual(captureNoDefaults(::target), captureAllDefaults(::target))
|
|
|
|
return "OK"
|
|
}
|
|
|
|
// FILE: fromOtherFile.kt
|
|
|
|
fun captureNoDefaultsFromOtherFile(): Any = captureNoDefaults(::target)
|