K2: Fix priority for implicit receiver + extensionInvoke
See K1 counterpart at org.jetbrains.kotlin.resolve.calls.tower.TowerResolver.Task.processImplicitReceiver ^KT-58943 Fixed ^KT-59541 Fixed
This commit is contained in:
committed by
Space Team
parent
1f120ecd20
commit
3279313f2c
@@ -1,10 +1,5 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR, NATIVE, WASM
|
||||
// FIR status:
|
||||
// java.lang.StackOverflowError
|
||||
// at Nat$Companion$invoke$1.next(kt36853_fibonacci.kt:40) ...
|
||||
|
||||
fun box(): String {
|
||||
Nat<Int>(
|
||||
nil = 0,
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// ISSUE: KT-59541
|
||||
interface WriteContext {
|
||||
val x: String
|
||||
}
|
||||
|
||||
interface ReadContext {
|
||||
val y: String
|
||||
}
|
||||
|
||||
interface Codec<T> {
|
||||
fun WriteContext.encode(value: T)
|
||||
fun ReadContext.decode(): T?
|
||||
}
|
||||
|
||||
fun <T> codec(
|
||||
encode: WriteContext.(T) -> Unit,
|
||||
decode: ReadContext.() -> T?
|
||||
): Codec<T> = object : Codec<T> {
|
||||
// Mostly, we check in this test that both `encode(value)` and `decode()` are resolved
|
||||
// to the corresponding parameters of `codec` function (see KT-59541)
|
||||
// Because before the fix for KT-37375, they both were resolved to the members of the anonymous objects
|
||||
// leading to recursion and stack overflow.
|
||||
override fun WriteContext.encode(value: T) = encode(value)
|
||||
override fun ReadContext.decode(): T? = decode()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
|
||||
val t = codec(
|
||||
{
|
||||
result += x + it
|
||||
},
|
||||
{
|
||||
y
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
with(t) {
|
||||
object : WriteContext {
|
||||
override val x: String
|
||||
get() = "O"
|
||||
}.encode("K")
|
||||
|
||||
result += object : ReadContext {
|
||||
override val y: String
|
||||
get() = "123"
|
||||
}.decode()
|
||||
}
|
||||
|
||||
if (result != "OK123") return "fail: $result"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user