[IR] Don't use linker fake override builder in Ir actualizer
Now, it uses fake override builder from in Fir2IrComponents. It would also allow using it in lazy classes in the future. ^KT-61934
This commit is contained in:
committed by
Space Team
parent
9fd057d7c3
commit
ed7e458828
+4
-44
@@ -5,10 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.actualizer
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.linkage.partial.PartialLinkageSupportForLinker
|
||||
import org.jetbrains.kotlin.backend.common.overrides.FileLocalAwareLinker
|
||||
import org.jetbrains.kotlin.backend.common.overrides.IrLinkerFakeOverrideProvider
|
||||
import org.jetbrains.kotlin.backend.common.serialization.CompatibilityMode
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyDeclarationBase
|
||||
@@ -16,13 +12,11 @@ import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
|
||||
import org.jetbrains.kotlin.ir.expressions.IrLocalDelegatedPropertyReference
|
||||
import org.jetbrains.kotlin.ir.expressions.IrPropertyReference
|
||||
import org.jetbrains.kotlin.ir.overrides.IrOverridingUtil
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrPropertySymbolImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrTypeSystemContext
|
||||
import org.jetbrains.kotlin.ir.types.getClass
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
@@ -58,11 +52,7 @@ import org.jetbrains.kotlin.utils.newHashSetWithExpectedSize
|
||||
*/
|
||||
class FakeOverrideRebuilder(
|
||||
val symbolTable: SymbolTable,
|
||||
val mangler: KotlinMangler.IrMangler,
|
||||
typeSystemContext: IrTypeSystemContext,
|
||||
val irModule: IrModuleFragment,
|
||||
// TODO: drop this argument in favor of using [IrModuleDescriptor::shouldSeeInternalsOf] in FakeOverrideBuilder KT-61384
|
||||
friendModules: Map<String, List<String>>
|
||||
val irOverridingUtil: IrOverridingUtil,
|
||||
) {
|
||||
private val removedFakeOverrides = mutableMapOf<IrClassSymbol, List<IrSymbol>>()
|
||||
private val processedClasses = hashSetOf<IrClass>()
|
||||
@@ -70,17 +60,8 @@ class FakeOverrideRebuilder(
|
||||
// Map from the old fake override symbol to the new (rebuilt) symbol.
|
||||
private val fakeOverrideMap = hashMapOf<IrSymbol, IrSymbol>()
|
||||
|
||||
private val fakeOverrideBuilder = IrLinkerFakeOverrideProvider(
|
||||
LocalFakeOverridesStorage(),
|
||||
symbolTable,
|
||||
mangler,
|
||||
typeSystemContext,
|
||||
friendModules,
|
||||
PartialLinkageSupportForLinker.DISABLED,
|
||||
externalOverridabilityConditions = emptyList(), // TODO: KT-61370, KT-61804.
|
||||
)
|
||||
|
||||
fun rebuildFakeOverrides() {
|
||||
fun rebuildFakeOverrides(irModule: IrModuleFragment) {
|
||||
irModule.acceptVoid(RemoveFakeOverridesVisitor(removedFakeOverrides, symbolTable))
|
||||
for (clazz in removedFakeOverrides.keys) {
|
||||
rebuildClassFakeOverrides(clazz.owner)
|
||||
@@ -134,7 +115,7 @@ class FakeOverrideRebuilder(
|
||||
for (c in irClass.superTypes) {
|
||||
c.getClass()?.let { rebuildClassFakeOverrides(it) }
|
||||
}
|
||||
fakeOverrideBuilder.buildFakeOverridesForSingleClass(irClass, CompatibilityMode.CURRENT)
|
||||
irOverridingUtil.buildFakeOverridesForClass(irClass, false)
|
||||
|
||||
val overriddenMap = mutableMapOf<IrSymbol, IrSymbol>()
|
||||
|
||||
@@ -170,27 +151,6 @@ class FakeOverrideRebuilder(
|
||||
}
|
||||
}
|
||||
|
||||
private class LocalFakeOverridesStorage : FileLocalAwareLinker {
|
||||
val funStorage = mutableMapOf<Pair<IrDeclaration, IdSignature>, IrSimpleFunctionSymbolImpl>()
|
||||
val propertyStorage = mutableMapOf<Pair<IrDeclaration, IdSignature>, IrPropertySymbol>()
|
||||
override fun tryReferencingSimpleFunctionByLocalSignature(
|
||||
parent: IrDeclaration,
|
||||
idSignature: IdSignature,
|
||||
): IrSimpleFunctionSymbol? {
|
||||
if (idSignature.isPubliclyVisible) return null
|
||||
return funStorage.getOrPut(parent to idSignature) {
|
||||
IrSimpleFunctionSymbolImpl()
|
||||
}
|
||||
}
|
||||
|
||||
override fun tryReferencingPropertyByLocalSignature(parent: IrDeclaration, idSignature: IdSignature): IrPropertySymbol? {
|
||||
if (idSignature.isPubliclyVisible) return null
|
||||
return propertyStorage.getOrPut(parent to idSignature) {
|
||||
IrPropertySymbolImpl()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class RemoveFakeOverridesVisitor(
|
||||
val removedOverrides: MutableMap<IrClassSymbol, List<IrSymbol>>,
|
||||
val symbolTable: SymbolTable
|
||||
|
||||
+3
-4
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.overrides.IrOverridingUtil
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrTypeSystemContext
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
@@ -26,9 +27,7 @@ object IrActualizer {
|
||||
typeSystemContext: IrTypeSystemContext,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
symbolTable: SymbolTable,
|
||||
mangler: KotlinMangler.IrMangler,
|
||||
// TODO: drop this argument in favor of using [IrModuleDescriptor::shouldSeeInternalsOf] in FakeOverrideBuilder KT-61384
|
||||
friendModules: Map<String, List<String>>,
|
||||
irOverridingUtil: IrOverridingUtil,
|
||||
useIrFakeOverrideBuilder: Boolean,
|
||||
expectActualTracker: ExpectActualTracker?
|
||||
): IrActualizedResult {
|
||||
@@ -80,7 +79,7 @@ object IrActualizer {
|
||||
|
||||
if (useIrFakeOverrideBuilder) {
|
||||
// 8. Rebuild fake overrides from stretch, as they could become invalid during actualization
|
||||
FakeOverrideRebuilder(symbolTable, mangler, typeSystemContext, mainFragment, friendModules).rebuildFakeOverrides()
|
||||
FakeOverrideRebuilder(symbolTable, irOverridingUtil).rebuildFakeOverrides(mainFragment)
|
||||
}
|
||||
|
||||
return IrActualizedResult(removedExpectDeclarations)
|
||||
|
||||
Reference in New Issue
Block a user