[IR SERIALIZATION] Fix ONLY_DECLARATION_HEADERS mode

This commit is contained in:
Roman Artemev
2019-08-26 11:15:07 +03:00
committed by romanart
parent 0c7454c918
commit 2e0ab8ba3f
2 changed files with 17 additions and 25 deletions
@@ -423,30 +423,18 @@ abstract class KotlinIrLinker(
moduleReversedFileIndex.getOrPut(uniqId) { fileDeserializer }
}
when (deserializationStrategy) {
DeserializationStrategy.EXPLICITLY_EXPORTED -> {
fileProto.explicitlyExportedToCompilerList.forEach {
val symbolProto = fileDeserializer.loadSymbolData(it.index)
val topLevelUniqId = symbolProto.topLevelUniqId
val uniqId = topLevelUniqId.uniqId()
assert(uniqId.isPublic)
// if (topLevelUniqId.isLocal) {
// fileDeserializer.fileLocalDeserializationState.addUniqID(uniqId)
// } else {
moduleDeserializationState.addUniqID(uniqId)
// }
val forceLoadedIds = deserializationStrategy.run {
when {
theWholeWorld -> fileProto.declarationIdList
explicitlyExported -> fileProto.explicitlyExportedToCompilerList.map {
fileDeserializer.loadSymbolData(it.index).topLevelUniqId
}
else -> emptyList()
}
DeserializationStrategy.ALL -> {
fileProto.declarationIdList.forEach {
val uniqId = it.uniqId()
assert(uniqId.isPublic)
moduleDeserializationState.addUniqID(uniqId)
}
}
else -> error("Unexpected deserialization strategy")
}
forceLoadedIds.forEach { moduleDeserializationState.addUniqID(it.uniqId().also { i -> assert(i.isPublic) }) }
return file
}
@@ -626,11 +614,14 @@ abstract class KotlinIrLinker(
fun deserializeFullModule(moduleDescriptor: ModuleDescriptor): IrModuleFragment =
deserializeIrModuleHeader(moduleDescriptor, DeserializationStrategy.ALL)
fun deserializeOnlyHeaderModule(moduleDescriptor: ModuleDescriptor): IrModuleFragment =
deserializeIrModuleHeader(moduleDescriptor, DeserializationStrategy.ONLY_DECLARATION_HEADERS)
}
enum class DeserializationStrategy(val needBodies: Boolean) {
ONLY_REFERENCED(true),
ALL(true),
EXPLICITLY_EXPORTED(true),
ONLY_DECLARATION_HEADERS(false)
enum class DeserializationStrategy(val needBodies: Boolean, val explicitlyExported: Boolean, val theWholeWorld: Boolean) {
ONLY_REFERENCED(true, false, false),
ALL(true, true, true),
EXPLICITLY_EXPORTED(true, true, false),
ONLY_DECLARATION_HEADERS(false, false, false)
}
@@ -15,6 +15,7 @@ dependencies {
testCompile(project(":compiler:cli"))
testCompile(project(":compiler:util"))
testRuntime(project(":kotlin-reflect"))
testRuntime(intellijDep()) { includeJars("picocontainer", "trove4j", "guava", "jdom", rootProject = rootProject) }
}