21fef70367
Previously, FIR used `_context_receiver_n` while FE10 used `<this>` for all context receiver parameters. This commit changes the code in FE10 to follow the convention from FIR.
91 lines
2.5 KiB
Plaintext
Vendored
91 lines
2.5 KiB
Plaintext
Vendored
data class Pair<A : Any?, B : Any?> {
|
|
constructor(first: A, second: B) /* primary */ {
|
|
super/*Any*/()
|
|
/* <init>() */
|
|
|
|
}
|
|
|
|
val first: A
|
|
field = first
|
|
get
|
|
|
|
val second: B
|
|
field = second
|
|
get
|
|
|
|
operator fun component1(): A {
|
|
return <this>.#first
|
|
}
|
|
|
|
operator fun component2(): B {
|
|
return <this>.#second
|
|
}
|
|
|
|
fun copy(first: A = <this>.#first, second: B = <this>.#second): Pair<A, B> {
|
|
return Pair<A, B>(first = first, second = second)
|
|
}
|
|
|
|
override fun toString(): String {
|
|
return "Pair(" + "first=" + <this>.#first + ", " + "second=" + <this>.#second + ")"
|
|
}
|
|
|
|
override fun hashCode(): Int {
|
|
var result: Int = when {
|
|
EQEQ(arg0 = <this>.#first, arg1 = null) -> 0
|
|
else -> <this>.#first.hashCode()
|
|
}
|
|
result = result.times(other = 31).plus(other = when {
|
|
EQEQ(arg0 = <this>.#second, arg1 = null) -> 0
|
|
else -> <this>.#second.hashCode()
|
|
})
|
|
return result
|
|
}
|
|
|
|
override operator fun equals(other: Any?): Boolean {
|
|
when {
|
|
EQEQEQ(arg0 = <this>, arg1 = other) -> return true
|
|
}
|
|
when {
|
|
other !is Pair<A, B> -> return false
|
|
}
|
|
val tmp0_other_with_cast: Pair<A, B> = other as Pair<A, B>
|
|
when {
|
|
EQEQ(arg0 = <this>.#first, arg1 = tmp0_other_with_cast.#first).not() -> return false
|
|
}
|
|
when {
|
|
EQEQ(arg0 = <this>.#second, arg1 = tmp0_other_with_cast.#second).not() -> return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
}
|
|
|
|
infix operator fun <T : Any?> T.compareTo(_context_receiver_0: Comparator<T>, other: T): Int {
|
|
return _context_receiver_0.compare(p0 = <this>, p1 = other)
|
|
}
|
|
|
|
val <T : Any?> Pair<T, T>.min: T
|
|
get(_context_receiver_0: Comparator<T>): T {
|
|
return when {
|
|
less(arg0 = <this>.<get-first>().compareTo<T>(_context_receiver_0 = _context_receiver_0, other = <this>.<get-second>()), arg1 = 0) -> <this>.<get-first>()
|
|
else -> <this>.<get-second>()
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
val comparator: Comparator<String> = local fun <anonymous>(a: @FlexibleNullability String?, b: @FlexibleNullability String?): Int {
|
|
return when {
|
|
when {
|
|
EQEQ(arg0 = a, arg1 = null) -> true
|
|
else -> EQEQ(arg0 = b, arg1 = null)
|
|
} -> 0
|
|
else -> a /*!! String */.<get-length>().compareTo(other = b /*!! String */.<get-length>())
|
|
}
|
|
}
|
|
/*-> Comparator<String> */
|
|
return with<Comparator<String>, String>(receiver = comparator, block = local fun Comparator<String>.<anonymous>(): String {
|
|
return Pair<String, String>(first = "OK", second = "fail").<get-min><String>(_context_receiver_0 = $this$with)
|
|
}
|
|
)
|
|
}
|