[KLIB] Correctly restore top level property order during deserialization - Add test - Fix KT-34273
This commit is contained in:
-1
@@ -1292,7 +1292,6 @@ open class IrFileSerializer(
|
|||||||
file.declarations
|
file.declarations
|
||||||
.filterIsInstance<IrProperty>()
|
.filterIsInstance<IrProperty>()
|
||||||
.filter { it.backingField?.initializer != null && !it.isConst }
|
.filter { it.backingField?.initializer != null && !it.isConst }
|
||||||
.filter { it.visibility.let { it == Visibilities.PUBLIC || it == Visibilities.INTERNAL } }
|
|
||||||
.forEach { proto.addExplicitlyExportedToCompiler(serializeIrSymbol(it.backingField!!.symbol)) }
|
.forEach { proto.addExplicitlyExportedToCompiler(serializeIrSymbol(it.backingField!!.symbol)) }
|
||||||
|
|
||||||
// TODO: Konan specific
|
// TODO: Konan specific
|
||||||
|
|||||||
+15
-14
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.ir.util.NaiveSourceBasedFileEntryImpl
|
|||||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||||
import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite.newInstance
|
import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite.newInstance
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.ProtoContainer
|
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
@@ -408,24 +407,26 @@ abstract class KotlinIrLinker(
|
|||||||
fileDeserializer.file = file
|
fileDeserializer.file = file
|
||||||
fileToDeserializerMap[file] = fileDeserializer
|
fileToDeserializerMap[file] = fileDeserializer
|
||||||
|
|
||||||
fileProto.declarationIdList.forEach {
|
val fileUniqIdIndex = fileProto.declarationIdList.map { UniqId(it) }
|
||||||
val uniqId = UniqId(it)
|
|
||||||
moduleReversedFileIndex.getOrPut(uniqId) { fileDeserializer }
|
fileUniqIdIndex.forEach {
|
||||||
|
moduleReversedFileIndex.getOrPut(it) { fileDeserializer }
|
||||||
}
|
}
|
||||||
|
|
||||||
val forceLoadedIds = deserializationStrategy.run {
|
for (d in fileProto.explicitlyExportedToCompilerList) {
|
||||||
when {
|
fileDeserializer.run {
|
||||||
theWholeWorld -> fileProto.declarationIdList.map { UniqId(it) }
|
fileLocalDeserializationState.addUniqID(UniqId(loadSymbolData(d).topLevelUniqIdIndex))
|
||||||
explicitlyExported -> fileProto.explicitlyExportedToCompilerList.map {
|
|
||||||
fileDeserializer.loadSymbolData(it).run {
|
|
||||||
UniqId(topLevelUniqIdIndex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> emptyList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
forceLoadedIds.forEach { moduleDeserializationState.addUniqID(it.also { i -> assert(i.isPublic) }) }
|
if (deserializationStrategy.theWholeWorld) {
|
||||||
|
for (id in fileUniqIdIndex) {
|
||||||
|
assert(id.isPublic)
|
||||||
|
moduleDeserializationState.addUniqID(id)
|
||||||
|
}
|
||||||
|
} else if (deserializationStrategy.explicitlyExported) {
|
||||||
|
modulesWithReachableTopLevels.add(this)
|
||||||
|
}
|
||||||
|
|
||||||
return file
|
return file
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// MODULE: lib
|
||||||
|
// FILE: lib.kt
|
||||||
|
|
||||||
|
// KT-34273
|
||||||
|
|
||||||
|
class Foo(val str: String)
|
||||||
|
|
||||||
|
private val foo1 = Foo("OK")
|
||||||
|
|
||||||
|
val foo2 = foo1
|
||||||
|
|
||||||
|
// MODULE: main(lib)
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
fun box(): String = foo2.str
|
||||||
+5
@@ -18459,6 +18459,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
|
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("initOrderMultiModule.kt")
|
||||||
|
public void testInitOrderMultiModule() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("javaPropertyBoxedGetter.kt")
|
@TestMetadata("javaPropertyBoxedGetter.kt")
|
||||||
public void testJavaPropertyBoxedGetter() throws Exception {
|
public void testJavaPropertyBoxedGetter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/properties/javaPropertyBoxedGetter.kt");
|
runTest("compiler/testData/codegen/box/properties/javaPropertyBoxedGetter.kt");
|
||||||
|
|||||||
+5
@@ -18459,6 +18459,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
|
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("initOrderMultiModule.kt")
|
||||||
|
public void testInitOrderMultiModule() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("javaPropertyBoxedGetter.kt")
|
@TestMetadata("javaPropertyBoxedGetter.kt")
|
||||||
public void testJavaPropertyBoxedGetter() throws Exception {
|
public void testJavaPropertyBoxedGetter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/properties/javaPropertyBoxedGetter.kt");
|
runTest("compiler/testData/codegen/box/properties/javaPropertyBoxedGetter.kt");
|
||||||
|
|||||||
+5
@@ -17339,6 +17339,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
|
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("initOrderMultiModule.kt")
|
||||||
|
public void testInitOrderMultiModule() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("javaPropertyBoxedGetter.kt")
|
@TestMetadata("javaPropertyBoxedGetter.kt")
|
||||||
public void testJavaPropertyBoxedGetter() throws Exception {
|
public void testJavaPropertyBoxedGetter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/properties/javaPropertyBoxedGetter.kt");
|
runTest("compiler/testData/codegen/box/properties/javaPropertyBoxedGetter.kt");
|
||||||
|
|||||||
Generated
+5
@@ -14314,6 +14314,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
|
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("initOrderMultiModule.kt")
|
||||||
|
public void testInitOrderMultiModule() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt10715.kt")
|
@TestMetadata("kt10715.kt")
|
||||||
public void testKt10715() throws Exception {
|
public void testKt10715() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/properties/kt10715.kt");
|
runTest("compiler/testData/codegen/box/properties/kt10715.kt");
|
||||||
|
|||||||
+5
@@ -15469,6 +15469,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
|
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("initOrderMultiModule.kt")
|
||||||
|
public void testInitOrderMultiModule() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt10715.kt")
|
@TestMetadata("kt10715.kt")
|
||||||
public void testKt10715() throws Exception {
|
public void testKt10715() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/properties/kt10715.kt");
|
runTest("compiler/testData/codegen/box/properties/kt10715.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user