Files
kotlin-fork/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.kt
T
Dmitriy Dolovov 02604060ae IR text tests: Don't dump signatures for local declarations
1. Local declarations don't participate in IR-linkage, because they
can be referenced only inside the same body -> can be dropped
from IR text tests.

2. Mangled names for private declarations computed by descriptors/fir
are actually not used anywhere (they are recomputed by IR
immediately before serialization of IR). But sometimes such
mangled names diverge between K1 and K2 -> don't check them, but
always check mangled names computed by IR even for private
declarations.

3. Also: Drop DUMP_LOCAL_DECLARATION_SIGNATURES test directive.

^KT-57428 Obsolete
^KT-57430 Obsolete
^KT-57434 Obsolete
^KT-57778 Obsolete
^KT-57775 Obsolete
2023-11-30 08:32:35 +00:00

55 lines
1.5 KiB
Kotlin
Vendored

// WITH_STDLIB
// FULL_JDK
// JVM_TARGET: 1.8
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// MUTE_SIGNATURE_COMPARISON_K2: JVM_IR JS_IR NATIVE
// ^ KT-57788: Fix computing mangled names of types with @EnhancedNullability from IR-based declaration descriptors
// KT-61141: ImplicitReceiverStack & PersistentImplicitReceiverStack miss fake overrides `forEach` & `spliterator`
// IGNORE_BACKEND: NATIVE
interface SymbolOwner<E : SymbolOwner<E>>
interface Symbol<E : SymbolOwner<E>>
interface ReceiverValue {
val type: String
}
class ImplicitReceiverValue<S : Symbol<*>>(val boundSymbol: S?, override val type: String) : ReceiverValue
abstract class ImplicitReceiverStack : Iterable<ImplicitReceiverValue<*>> {
abstract operator fun get(name: String?): ImplicitReceiverValue<*>?
}
class PersistentImplicitReceiverStack(
private val stack: List<ImplicitReceiverValue<*>>
) : ImplicitReceiverStack(), Iterable<ImplicitReceiverValue<*>> {
override operator fun iterator(): Iterator<ImplicitReceiverValue<*>> {
return stack.iterator()
}
override operator fun get(name: String?): ImplicitReceiverValue<*>? {
return stack.lastOrNull()
}
}
fun bar(s: String) {}
fun foo(stack: PersistentImplicitReceiverStack) {
stack.forEach {
it.boundSymbol
bar(it.type)
}
}
fun box(): String {
val stack = PersistentImplicitReceiverStack(
listOf(ImplicitReceiverValue(null, "O"), ImplicitReceiverValue(null, "K"))
)
foo(stack)
return stack.first().type + stack[null]?.type
}