[PL] Native: Remove harmful private visibility guard in deserialization of LazyIr
Kotlin/Native codegen needs to deserialize all fields throughout the class hierarchy to build the proper binary class layout. That becomes impossible with the guard condition that prevents loading private top-level classes from another module in LazyIR (see https://github.com/JetBrains/kotlin/blob/2a4d8800374578c1aa9ec9c996b393a98f5a6e3b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt#L701). The guard suits well for the partial linkage needs, but it causes the codegen to fail with `Unbound public symbol IrClassPublicSymbolImpl: [ File '/file/in/the/library.kt' <- private.top.level/ClassDeclaration|null[0] ]` error. To prevent this the guard is removed. This does not influence the partial linkage in general except for the different error message being generated: `Function 'foo' can not be called: Private function declared in module <A> can not be accessed in module <B>` instead of `Function 'foo' can not be called: No function found for symbol '<symbol>'`. #KT-54469
This commit is contained in:
@@ -242,3 +242,16 @@ enum class StableEnum {
|
||||
abstract val test: String
|
||||
}
|
||||
|
||||
// This is required to check that the guard condition initially added in commit
|
||||
// https://github.com/JetBrains/kotlin/blob/2a4d8800374578c1aa9ec9c996b393a98f5a6e3b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt#L701
|
||||
// does not break Native codegen anymore.
|
||||
class StableInheritorOfClassThatUsesPrivateTopLevelClass : AbstractIterator<String>() {
|
||||
private var i = 0
|
||||
public override fun computeNext() {
|
||||
if (i < 5) setNext((i++).toString()) else done()
|
||||
}
|
||||
}
|
||||
|
||||
fun testStableInheritorOfClassThatUsesPrivateTopLevelClass(): String = buildString {
|
||||
for (s in StableInheritorOfClassThatUsesPrivateTopLevelClass()) append(s)
|
||||
}
|
||||
|
||||
@@ -210,4 +210,6 @@ fun box() = abiTest {
|
||||
|
||||
expectSuccess { StableEnum.FOO.test }
|
||||
expectSuccess { StableEnum.BAR.test }
|
||||
|
||||
expectSuccess("01234") { testStableInheritorOfClassThatUsesPrivateTopLevelClass() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user