Files
Vladimir Sukharev 3aa6c9e74d [K/N] Run irText tests for K1/Native
^KT-58240
2023-09-05 11:42:45 +00:00

23 lines
602 B
Kotlin
Vendored

// !LANGUAGE: +ContextReceivers
// IGNORE_BACKEND: JS_IR
// KT-61141: kotlin.Comparator instead of java.util.Comparator
// IGNORE_BACKEND: NATIVE
data class Pair<A, B>(val first: A, val second: B)
context(Comparator<T>)
infix operator fun <T> T.compareTo(other: T) = compare(this, other)
context(Comparator<T>)
val <T> Pair<T, T>.min get() = if (first < second) first else second
fun box(): String {
val comparator = Comparator<String> { a, b ->
if (a == null || b == null) 0 else a.length.compareTo(b.length)
}
return with(comparator) {
Pair("OK", "fail").min
}
}