From f17e1314f627c1618873660d2828ccf8a3aa9119 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Fri, 18 Nov 2022 19:54:36 +0100 Subject: [PATCH] [FIR2IR] Implement tables merging in Fir2Ir classes and SymbolTable - Pass dependent (usually common code) components to further FIR2IR converters - Don't reinitialize builtin --- .../kotlin/fir/pipeline/convertToIr.kt | 1 + .../fir/backend/Fir2IrClassifierStorage.kt | 35 +++++--- .../kotlin/fir/backend/Fir2IrConverter.kt | 31 ++++---- .../fir/backend/Fir2IrDeclarationStorage.kt | 51 ++++++++---- .../kotlin/fir/backend/Fir2IrLocalStorage.kt | 6 +- .../generators/DelegatedMemberGenerator.kt | 9 +-- .../generators/FakeOverrideGenerator.kt | 17 ++-- .../kotlin/fir/lazy/Fir2IrLazyProperty.kt | 22 +++--- .../signaturer/FirBasedSignatureComposer.kt | 11 ++- .../FirBlackBoxCodegenTestGenerated.java | 66 ++++++++++++++++ .../jetbrains/kotlin/ir/util/SymbolTable.kt | 79 ++++++++++++++----- .../multiModule/enumEntryNameCall.kt | 14 ++++ .../codegen/BlackBoxCodegenTestGenerated.java | 24 ++++++ .../IrBlackBoxCodegenTestGenerated.java | 66 ++++++++++++++++ .../frontend/fir/Fir2IrJsResultsConverter.kt | 3 +- .../frontend/fir/Fir2IrResultsConverter.kt | 9 ++- .../kotlin/codegen/GenerationUtils.kt | 2 +- .../jetbrains/kotlin/fir/FirAnalyzerFacade.kt | 8 +- .../LightAnalysisModeTestGenerated.java | 20 +++++ .../jetbrains/kotlin/backend/konan/Fir2Ir.kt | 3 +- 20 files changed, 376 insertions(+), 101 deletions(-) create mode 100644 compiler/testData/codegen/box/multiplatform/multiModule/enumEntryNameCall.kt diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/pipeline/convertToIr.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/pipeline/convertToIr.kt index 04f99d1ab7c..00e4f82c885 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/pipeline/convertToIr.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/pipeline/convertToIr.kt @@ -84,6 +84,7 @@ private fun ModuleCompilerAnalyzedOutput.convertToIr( irGeneratorExtensions, kotlinBuiltIns = DefaultBuiltIns.Instance, // TODO: consider passing externally generateSignatures = true, + dependentComponents = dependentComponents ) } else { return Fir2IrConverter.createModuleFragmentWithoutSignatures( diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrClassifierStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrClassifierStorage.kt index 21d49a28e75..5e05bda0f1a 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrClassifierStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrClassifierStorage.kt @@ -6,8 +6,8 @@ package org.jetbrains.kotlin.fir.backend import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.fir.containingClassLookupTag import org.jetbrains.kotlin.fir.containingClassForLocalAttr +import org.jetbrains.kotlin.fir.containingClassLookupTag import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.utils.* import org.jetbrains.kotlin.fir.expressions.FirAnonymousObjectExpression @@ -39,32 +39,47 @@ import org.jetbrains.kotlin.utils.addToStdlib.runIf import org.jetbrains.kotlin.utils.addToStdlib.runUnless class Fir2IrClassifierStorage( - private val components: Fir2IrComponents + private val components: Fir2IrComponents, + private val dependentStorages: List ) : Fir2IrComponents by components { private val firProvider = session.firProvider - private val classCache = mutableMapOf() + private val classCache: MutableMap = merge { it.classCache } - private val localClassesCreatedOnTheFly = mutableMapOf() + private val localClassesCreatedOnTheFly: MutableMap = mutableMapOf() private var processMembersOfClassesOnTheFlyImmediately = false - private val typeAliasCache = mutableMapOf() + private val typeAliasCache: MutableMap = mutableMapOf() - private val typeParameterCache = mutableMapOf() + private val typeParameterCache: MutableMap = merge { it.typeParameterCache } - private val typeParameterCacheForSetter = mutableMapOf() + private val typeParameterCacheForSetter: MutableMap = mutableMapOf() - private val enumEntryCache = mutableMapOf() + private val enumEntryCache: MutableMap = merge { it.enumEntryCache } - private val fieldsForContextReceivers = mutableMapOf>() + private val fieldsForContextReceivers: MutableMap> = mutableMapOf() - private val localStorage = Fir2IrLocalStorage() + private val localStorage: Fir2IrLocalStorage = Fir2IrLocalStorage( + dependentStorages.map { it.localStorage }.fold(mutableMapOf()) { result, storage -> + result.putAll(storage.getLocalClassCache()) + result + }) + + private fun merge(mapFunc: (Fir2IrClassifierStorage) -> MutableMap): MutableMap { + return dependentStorages.map { mapFunc(it) }.fold(mutableMapOf()) { result, map -> + result.putAll(map) + result + } + } private fun FirTypeRef.toIrType(typeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT): IrType = with(typeConverter) { toIrType(typeContext) } fun preCacheBuiltinClasses() { + // dependentStorages are only actual for MPP scenario + // There is no need to precache them twice since the same library session is used and FIR and IR elements are the same + if (dependentStorages.isNotEmpty()) return for ((classId, irBuiltinSymbol) in typeConverter.classIdToSymbolMap) { val firClass = ConeClassLikeLookupTagImpl(classId).toSymbol(session)!!.fir as FirRegularClass val irClass = irBuiltinSymbol.owner diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt index 2761e18ddc1..224b51ccdbd 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt @@ -438,7 +438,8 @@ class Fir2IrConverter( specialSymbolProvider: Fir2IrSpecialSymbolProvider, irGenerationExtensions: Collection, generateSignatures: Boolean, - kotlinBuiltIns: KotlinBuiltIns + kotlinBuiltIns: KotlinBuiltIns, + dependentComponents: List ): Fir2IrResult { if (!generateSignatures) { return createModuleFragmentWithoutSignatures( @@ -448,14 +449,14 @@ class Fir2IrConverter( kotlinBuiltIns ) } - val signatureComposer = FirBasedSignatureComposer(mangler) + val signatureComposer = FirBasedSignatureComposer(mangler, dependentComposers = dependentComponents.map { it.signatureComposer as FirBasedSignatureComposer }) val wrappedSignaturer = WrappedDescriptorSignatureComposer(signaturer, signatureComposer) - val symbolTable = SymbolTable(wrappedSignaturer, irFactory) + val symbolTable = SymbolTable(wrappedSignaturer, irFactory, dependentTables = dependentComponents.map { it.symbolTable }) return createModuleFragmentWithSymbolTable( session, scopeSession, firFiles, languageVersionSettings, fir2IrExtensions, irMangler, irFactory, visibilityConverter, specialSymbolProvider, irGenerationExtensions, signatureComposer, - symbolTable, generateSignatures = true, kotlinBuiltIns = kotlinBuiltIns + symbolTable, generateSignatures = true, kotlinBuiltIns = kotlinBuiltIns, dependentComponents = dependentComponents ) } @@ -473,14 +474,14 @@ class Fir2IrConverter( irGenerationExtensions: Collection, kotlinBuiltIns: KotlinBuiltIns ): Fir2IrResult { - val signatureComposer = FirBasedSignatureComposer(mangler) + val signatureComposer = FirBasedSignatureComposer(mangler, dependentComposers = dependentComponents.map { it.signatureComposer as FirBasedSignatureComposer }) val signaturer = DescriptorSignatureComposerStub() - val symbolTable = SymbolTable(signaturer, irFactory) + val symbolTable = SymbolTable(signaturer, irFactory, dependentTables = dependentComponents.map { it.symbolTable }) return createModuleFragmentWithSymbolTable( session, scopeSession, firFiles, languageVersionSettings, fir2IrExtensions, irMangler, irFactory, visibilityConverter, specialSymbolProvider, irGenerationExtensions, signatureComposer, - symbolTable, generateSignatures = false, kotlinBuiltIns = kotlinBuiltIns + symbolTable, generateSignatures = false, kotlinBuiltIns = kotlinBuiltIns, dependentComponents = emptyList() ) } @@ -498,7 +499,8 @@ class Fir2IrConverter( signatureComposer: FirBasedSignatureComposer, symbolTable: SymbolTable, generateSignatures: Boolean, - kotlinBuiltIns: KotlinBuiltIns + kotlinBuiltIns: KotlinBuiltIns, + dependentComponents: List ): Fir2IrResult { val moduleDescriptor = FirModuleDescriptor(session, kotlinBuiltIns) val components = Fir2IrComponentsStorage( @@ -508,19 +510,18 @@ class Fir2IrConverter( components.converter = converter - val classifierStorage = Fir2IrClassifierStorage(components) + val classifierStorage = Fir2IrClassifierStorage(components, dependentComponents.map { it.classifierStorage }) components.classifierStorage = classifierStorage components.delegatedMemberGenerator = DelegatedMemberGenerator(components) - val declarationStorage = Fir2IrDeclarationStorage(components, moduleDescriptor) + val declarationStorage = Fir2IrDeclarationStorage(components, moduleDescriptor, dependentComponents.map { it.declarationStorage }) components.declarationStorage = declarationStorage components.visibilityConverter = visibilityConverter val typeConverter = Fir2IrTypeConverter(components) components.typeConverter = typeConverter - val irBuiltIns = - IrBuiltInsOverFir( - components, languageVersionSettings, moduleDescriptor, irMangler, - languageVersionSettings.getFlag(AnalysisFlags.builtInsFromSources) || kotlinBuiltIns !== DefaultBuiltIns.Instance - ) + val irBuiltIns = dependentComponents.lastOrNull()?.irBuiltIns ?: IrBuiltInsOverFir( + components, languageVersionSettings, moduleDescriptor, irMangler, + languageVersionSettings.getFlag(AnalysisFlags.builtInsFromSources) || kotlinBuiltIns !== DefaultBuiltIns.Instance + ) components.irBuiltIns = irBuiltIns val conversionScope = Fir2IrConversionScope() val fir2irVisitor = Fir2IrVisitor(components, conversionScope) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 384bbfb081a..8bff936d0cd 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -64,26 +64,27 @@ import java.util.concurrent.ConcurrentHashMap @OptIn(ObsoleteDescriptorBasedAPI::class) class Fir2IrDeclarationStorage( private val components: Fir2IrComponents, - private val moduleDescriptor: FirModuleDescriptor + private val moduleDescriptor: FirModuleDescriptor, + dependentStorages: List ) : Fir2IrComponents by components { private val firProvider = session.firProvider - private val fragmentCache = ConcurrentHashMap() + private val fragmentCache: ConcurrentHashMap = ConcurrentHashMap() - private val builtInsFragmentCache = ConcurrentHashMap() + private val builtInsFragmentCache: ConcurrentHashMap = ConcurrentHashMap() - private val fileCache = ConcurrentHashMap() + private val fileCache: ConcurrentHashMap = ConcurrentHashMap() - private val scriptCache = ConcurrentHashMap() + private val scriptCache: ConcurrentHashMap = ConcurrentHashMap() - private val functionCache = ConcurrentHashMap() + private val functionCache: ConcurrentHashMap = merge(dependentStorages) { it.functionCache } - private val constructorCache = ConcurrentHashMap() + private val constructorCache: ConcurrentHashMap = ConcurrentHashMap() - private val initializerCache = ConcurrentHashMap() + private val initializerCache: ConcurrentHashMap = ConcurrentHashMap() - private val propertyCache = ConcurrentHashMap() + private val propertyCache: ConcurrentHashMap = merge(dependentStorages) { it.propertyCache } // interface A { /* $1 */ fun foo() } // interface B : A { @@ -96,24 +97,40 @@ class Fir2IrDeclarationStorage( // We've got FIR declarations only for $1 and $3, but we've got a fake override for $2 in IR // and just to simplify things we create a synthetic FIR for $2, while it can't be referenced from other FIR nodes. // - // But when we binding overrides for $3, we want it had $2 ad it's overridden, + // But when we're binding overrides for $3, we want it had $2 ad it's overridden, // so remember that in class B there's a fake override $2 for real $1. // - // Thus we may obtain it by fakeOverridesInClass[ir(B)][fir(A::foo)] -> fir(B::foo) - private val fakeOverridesInClass = mutableMapOf>() + // Thus, we may obtain it by fakeOverridesInClass[ir(B)][fir(A::foo)] -> fir(B::foo) + private val fakeOverridesInClass: MutableMap> = + dependentStorages.map { it.fakeOverridesInClass }.fold(mutableMapOf()) { result, map -> + // Note: merge is necessary here, because sometimes (see testFakeOverridesInPlatformModule) + // we have to match fake override in platform class with overridden fake overrides in common class + result.putAll(map) + result + } // For pure fields (from Java) only - private val fieldToPropertyCache = ConcurrentHashMap, IrProperty>() + private val fieldToPropertyCache: ConcurrentHashMap, IrProperty> = ConcurrentHashMap() - private val delegatedReverseCache = ConcurrentHashMap() + private val delegatedReverseCache: ConcurrentHashMap = ConcurrentHashMap() - private val fieldCache = ConcurrentHashMap() + private val fieldCache: ConcurrentHashMap = ConcurrentHashMap() private data class FieldStaticOverrideKey(val lookupTag: ConeClassLikeLookupTag, val name: Name) - private val fieldStaticOverrideCache = ConcurrentHashMap() + private val fieldStaticOverrideCache: ConcurrentHashMap = ConcurrentHashMap() - private val localStorage by threadLocal { Fir2IrLocalStorage() } + private val localStorage: Fir2IrLocalStorage by threadLocal { Fir2IrLocalStorage() } + + private fun merge( + dependentStorages: List, + mapFunc: (Fir2IrDeclarationStorage) -> ConcurrentHashMap + ): ConcurrentHashMap { + return dependentStorages.map { mapFunc(it) }.fold(ConcurrentHashMap()) { result, map -> + result.putAll(map) + result + } + } private fun areCompatible(firFunction: FirFunction, irFunction: IrFunction): Boolean { if (firFunction is FirSimpleFunction && irFunction is IrSimpleFunction) { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrLocalStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrLocalStorage.kt index 93eef2aca44..b80cb2e6756 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrLocalStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrLocalStorage.kt @@ -8,11 +8,13 @@ package org.jetbrains.kotlin.fir.backend import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.ir.declarations.* -class Fir2IrLocalStorage { +class Fir2IrLocalStorage(existingClassCache: MutableMap? = null) { private val cacheStack = mutableListOf() - private val localClassCache = mutableMapOf() + private val localClassCache = existingClassCache ?: mutableMapOf() + + fun getLocalClassCache() = localClassCache fun enterCallable() { cacheStack += Fir2IrScopeCache() diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt index b6b3e75d5c1..db3bac28c71 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt @@ -42,12 +42,9 @@ import org.jetbrains.kotlin.name.Name * methods and properties in the super-interface, and creates corresponding members in the subclass. * TODO: generic super interface types and generic delegated members. */ -class DelegatedMemberGenerator( - private val components: Fir2IrComponents -) : Fir2IrComponents by components { - - private val baseFunctionSymbols = mutableMapOf>() - private val basePropertySymbols = mutableMapOf>() +class DelegatedMemberGenerator(private val components: Fir2IrComponents) : Fir2IrComponents by components { + private val baseFunctionSymbols: MutableMap> = mutableMapOf() + private val basePropertySymbols: MutableMap> = mutableMapOf() private data class DeclarationBodyInfo( val declaration: IrDeclaration, diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt index efa56ea5c7a..52297e4004b 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt @@ -6,10 +6,7 @@ package org.jetbrains.kotlin.fir.backend.generators import org.jetbrains.kotlin.fir.* -import org.jetbrains.kotlin.fir.backend.Fir2IrComponents -import org.jetbrains.kotlin.fir.backend.Fir2IrConversionScope -import org.jetbrains.kotlin.fir.backend.Fir2IrDeclarationStorage -import org.jetbrains.kotlin.fir.backend.unwrapSubstitutionAndIntersectionOverrides +import org.jetbrains.kotlin.fir.backend.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.utils.* import org.jetbrains.kotlin.fir.resolve.defaultType @@ -18,10 +15,7 @@ import org.jetbrains.kotlin.fir.scopes.* import org.jetbrains.kotlin.fir.scopes.impl.FirFakeOverrideGenerator import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirFieldSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.symbols.impl.isStatic import org.jetbrains.kotlin.fir.types.coneType import org.jetbrains.kotlin.ir.declarations.* @@ -38,10 +32,9 @@ class FakeOverrideGenerator( private val components: Fir2IrComponents, private val conversionScope: Fir2IrConversionScope ) : Fir2IrComponents by components { - - private val baseFunctionSymbols = mutableMapOf>() - private val basePropertySymbols = mutableMapOf>() - private val baseStaticFieldSymbols = mutableMapOf>() + private val baseFunctionSymbols: MutableMap> = mutableMapOf() + private val basePropertySymbols: MutableMap> = mutableMapOf() + private val baseStaticFieldSymbols: MutableMap> = mutableMapOf() private fun IrSimpleFunction.withFunction(f: IrSimpleFunction.() -> Unit): IrSimpleFunction { return conversionScope.withFunction(this, f) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyProperty.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyProperty.kt index 8e8915c02a6..8439af5bcf6 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyProperty.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyProperty.kt @@ -8,32 +8,28 @@ package org.jetbrains.kotlin.fir.lazy import org.jetbrains.kotlin.descriptors.DescriptorVisibility import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.PropertyDescriptor -import org.jetbrains.kotlin.fir.backend.ConversionTypeContext -import org.jetbrains.kotlin.fir.backend.ConversionTypeOrigin -import org.jetbrains.kotlin.fir.backend.Fir2IrComponents -import org.jetbrains.kotlin.fir.backend.toIrConst +import org.jetbrains.kotlin.fir.backend.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter +import org.jetbrains.kotlin.fir.declarations.utils.* import org.jetbrains.kotlin.fir.expressions.FirConstExpression +import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.symbols.Fir2IrPropertySymbol import org.jetbrains.kotlin.fir.symbols.Fir2IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -import org.jetbrains.kotlin.ir.types.IrErrorType -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.util.isInterface -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource -import org.jetbrains.kotlin.fir.backend.* -import org.jetbrains.kotlin.fir.declarations.utils.* -import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol +import org.jetbrains.kotlin.ir.types.IrErrorType +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.util.isComposite +import org.jetbrains.kotlin.ir.util.isInterface +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.NameUtils +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource class Fir2IrLazyProperty( components: Fir2IrComponents, @@ -166,6 +162,7 @@ class Fir2IrLazyProperty( containingClass?.symbol?.toLookupTag(), forceTopLevelPrivate = symbol.signature.isComposite() )!! + symbolTable.referenceSimpleFunctionIfAny(signature)?.let { if (it.isBound) return@lazyVar it.owner } symbolTable.declareSimpleFunction(signature, symbolFactory = { Fir2IrSimpleFunctionSymbol(signature) }) { symbol -> Fir2IrLazyPropertyAccessor( components, startOffset, endOffset, @@ -200,6 +197,7 @@ class Fir2IrLazyProperty( containingClass?.symbol?.toLookupTag(), forceTopLevelPrivate = symbol.signature.isComposite() )!! + symbolTable.referenceSimpleFunctionIfAny(signature)?.let { if (it.isBound) return@lazyVar it.owner } symbolTable.declareSimpleFunction(signature, symbolFactory = { Fir2IrSimpleFunctionSymbol(signature) }) { symbol -> Fir2IrLazyPropertyAccessor( components, startOffset, endOffset, diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/signaturer/FirBasedSignatureComposer.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/signaturer/FirBasedSignatureComposer.kt index a714c30077c..af9328bd543 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/signaturer/FirBasedSignatureComposer.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/signaturer/FirBasedSignatureComposer.kt @@ -23,7 +23,10 @@ import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName // @NoMutableState -- we'll restore this annotation once we get rid of withFileSignature(). -class FirBasedSignatureComposer(override val mangler: FirMangler) : Fir2IrSignatureComposer { +class FirBasedSignatureComposer( + override val mangler: FirMangler, + dependentComposers: List = emptyList() +) : Fir2IrSignatureComposer { private var fileSignature: IdSignature.FileSignature? = null override fun withFileSignature(sig: IdSignature.FileSignature, body: () -> Unit) { @@ -34,7 +37,11 @@ class FirBasedSignatureComposer(override val mangler: FirMangler) : Fir2IrSignat private data class FirDeclarationWithParentId(val declaration: FirDeclaration, val classId: ClassId?) - private val signatureCache = mutableMapOf() + private val signatureCache: MutableMap = + dependentComposers.map { it.signatureCache }.fold(mutableMapOf()) { result, map -> + result.putAll(map) + result + } inner class SignatureBuilder : FirVisitor() { var hashId: Long? = null diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 30be9b4fd86..f990b280fcc 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -32695,6 +32695,72 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT public void testAllFilesPresentInMultiModule() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/multiModule"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + + @Test + @TestMetadata("correctParentForTypeParameter.kt") + public void testCorrectParentForTypeParameter() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/correctParentForTypeParameter.kt"); + } + + @Test + @TestMetadata("enumEntryNameCall.kt") + public void testEnumEntryNameCall() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/enumEntryNameCall.kt"); + } + + @Test + @TestMetadata("expectActualCallableReference.kt") + public void testExpectActualCallableReference() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualCallableReference.kt"); + } + + @Test + @TestMetadata("expectActualDifferentPackages.kt") + public void testExpectActualDifferentPackages() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualDifferentPackages.kt"); + } + + @Test + @TestMetadata("expectActualFakeOverrides.kt") + public void testExpectActualFakeOverrides() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualFakeOverrides.kt"); + } + + @Test + @TestMetadata("expectActualMultiCommon.kt") + public void testExpectActualMultiCommon() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualMultiCommon.kt"); + } + + @Test + @TestMetadata("expectActualOverloads.kt") + public void testExpectActualOverloads() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualOverloads.kt"); + } + + @Test + @TestMetadata("expectActualSimple.kt") + public void testExpectActualSimple() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualSimple.kt"); + } + + @Test + @TestMetadata("expectActualTypealias.kt") + public void testExpectActualTypealias() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualTypealias.kt"); + } + + @Test + @TestMetadata("kt-51753-1.kt") + public void testKt_51753_1() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/kt-51753-1.kt"); + } + + @Test + @TestMetadata("kt-51753-2.kt") + public void testKt_51753_2() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/kt-51753-2.kt"); + } } } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt index 3d41b2b844b..9f6d057c8dd 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt @@ -84,7 +84,8 @@ interface ReferenceSymbolTable { open class SymbolTable( val signaturer: IdSignatureComposer, val irFactory: IrFactory, - val nameProvider: NameProvider = NameProvider.DEFAULT + val nameProvider: NameProvider = NameProvider.DEFAULT, + val dependentTables: List = emptyList(), ) : ReferenceSymbolTable { val lock = IrLock() @@ -212,10 +213,10 @@ open class SymbolTable( } } - private open inner class FlatSymbolTable> : - SymbolTableBase(lock) { - val descriptorToSymbol = hashMapOf() - val idSigToSymbol = hashMapOf() + private open inner class FlatSymbolTable>( + val descriptorToSymbol: HashMap = hashMapOf(), + val idSigToSymbol: HashMap = hashMapOf() + ) : SymbolTableBase(lock) { override fun signature(descriptor: D): IdSignature? = signaturer.composeSignature(descriptor) @@ -244,11 +245,17 @@ open class SymbolTable( } } - private inner class EnumEntrySymbolTable : FlatSymbolTable() { + private inner class EnumEntrySymbolTable( + descriptorToSymbol: HashMap = hashMapOf(), + idSigToSymbol: HashMap = hashMapOf() + ) : FlatSymbolTable(descriptorToSymbol, idSigToSymbol) { override fun signature(descriptor: ClassDescriptor): IdSignature? = signaturer.composeEnumEntrySignature(descriptor) } - private inner class FieldSymbolTable : FlatSymbolTable() { + private inner class FieldSymbolTable( + descriptorToSymbol: HashMap = hashMapOf(), + idSigToSymbol: HashMap = hashMapOf() + ) : FlatSymbolTable(descriptorToSymbol, idSigToSymbol) { override fun signature(descriptor: PropertyDescriptor): IdSignature? = signaturer.composeFieldSignature(descriptor) } @@ -365,18 +372,32 @@ open class SymbolTable( currentScope?.dump() ?: "" } - private val externalPackageFragmentTable = - FlatSymbolTable() - private val scriptSymbolTable = FlatSymbolTable() - private val classSymbolTable = FlatSymbolTable() - private val constructorSymbolTable = FlatSymbolTable() - private val enumEntrySymbolTable = EnumEntrySymbolTable() - private val fieldSymbolTable = FieldSymbolTable() - private val simpleFunctionSymbolTable = FlatSymbolTable() - private val propertySymbolTable = FlatSymbolTable() - private val typeAliasSymbolTable = FlatSymbolTable() + private val externalPackageFragmentTable: FlatSymbolTable = + mergeFlatTables(dependentTables) { it.externalPackageFragmentTable } + private val scriptSymbolTable: FlatSymbolTable = + mergeFlatTables(dependentTables) { it.scriptSymbolTable } + private val classSymbolTable: FlatSymbolTable = + mergeFlatTables(dependentTables) { it.classSymbolTable } + private val constructorSymbolTable: FlatSymbolTable = + mergeFlatTables(dependentTables) { it.constructorSymbolTable } + private val enumEntrySymbolTable: EnumEntrySymbolTable = run { + val (descriptorToSymbol, idSigToSymbol) = mergeTables(dependentTables) { it.enumEntrySymbolTable } + EnumEntrySymbolTable(descriptorToSymbol, idSigToSymbol) + } + private val fieldSymbolTable: FieldSymbolTable = run { + val (descriptorToSymbol, idSigToSymbol) = mergeTables(dependentTables) { it.fieldSymbolTable } + FieldSymbolTable(descriptorToSymbol, idSigToSymbol) + } + private val simpleFunctionSymbolTable: FlatSymbolTable = + mergeFlatTables(dependentTables) { it.simpleFunctionSymbolTable } + private val propertySymbolTable: FlatSymbolTable = + mergeFlatTables(dependentTables) { it.propertySymbolTable } + private val typeAliasSymbolTable: FlatSymbolTable = + mergeFlatTables(dependentTables) { it.typeAliasSymbolTable } + + private val globalTypeParameterSymbolTable: FlatSymbolTable = + mergeFlatTables(dependentTables) { it.globalTypeParameterSymbolTable } - private val globalTypeParameterSymbolTable = FlatSymbolTable() private val scopedTypeParameterSymbolTable by threadLocal { ScopedSymbolTable() } @@ -393,6 +414,28 @@ open class SymbolTable( listOf(valueParameterSymbolTable, variableSymbolTable, scopedTypeParameterSymbolTable, localDelegatedPropertySymbolTable) } + private fun > mergeFlatTables( + dependentTables: List, + mapFunc: (SymbolTable) -> FlatSymbolTable + ): FlatSymbolTable { + val (descriptorToSymbol, idSigToSymbol) = mergeTables(dependentTables, mapFunc) + return FlatSymbolTable(descriptorToSymbol, idSigToSymbol) + } + + private fun > mergeTables( + dependentTables: List, + mapFunc: (SymbolTable) -> FlatSymbolTable + ): Pair, HashMap> { + val descriptorToSymbol = hashMapOf() + val idSigToSymbol = hashMapOf() + for (dependentTable in dependentTables) { + val flatSymbolTable = mapFunc(dependentTable) + descriptorToSymbol.putAll(flatSymbolTable.descriptorToSymbol) + idSigToSymbol.putAll(flatSymbolTable.idSigToSymbol) + } + return Pair(descriptorToSymbol, idSigToSymbol) + } + @ObsoleteDescriptorBasedAPI fun referenceExternalPackageFragment(descriptor: PackageFragmentDescriptor) = externalPackageFragmentTable.referenced(descriptor) { IrExternalPackageFragmentSymbolImpl(descriptor) } diff --git a/compiler/testData/codegen/box/multiplatform/multiModule/enumEntryNameCall.kt b/compiler/testData/codegen/box/multiplatform/multiModule/enumEntryNameCall.kt new file mode 100644 index 00000000000..556d44f55d0 --- /dev/null +++ b/compiler/testData/codegen/box/multiplatform/multiModule/enumEntryNameCall.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: JVM +// !LANGUAGE: +MultiPlatformProjects + +// MODULE: common +// TARGET_PLATFORM: Common +// FILE: common.kt + +enum class Base { OK } + +// MODULE: jvm()()(common) +// TARGET_PLATFORM: JVM +// FILE: main.kt + +fun box() = Base.OK.name \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 2f99ba9a73e..ec208690982 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -31693,6 +31693,30 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testAllFilesPresentInMultiModule() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/multiModule"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + + @Test + @TestMetadata("correctParentForTypeParameter.kt") + public void testCorrectParentForTypeParameter() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/correctParentForTypeParameter.kt"); + } + + @Test + @TestMetadata("enumEntryNameCall.kt") + public void testEnumEntryNameCall() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/enumEntryNameCall.kt"); + } + + @Test + @TestMetadata("expectActualMultiCommon.kt") + public void testExpectActualMultiCommon() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualMultiCommon.kt"); + } + + @Test + @TestMetadata("expectActualSimple.kt") + public void testExpectActualSimple() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualSimple.kt"); + } } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 5dc5c4cb637..1e68bca99ee 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -32695,6 +32695,72 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testAllFilesPresentInMultiModule() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/multiModule"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + + @Test + @TestMetadata("correctParentForTypeParameter.kt") + public void testCorrectParentForTypeParameter() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/correctParentForTypeParameter.kt"); + } + + @Test + @TestMetadata("enumEntryNameCall.kt") + public void testEnumEntryNameCall() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/enumEntryNameCall.kt"); + } + + @Test + @TestMetadata("expectActualCallableReference.kt") + public void testExpectActualCallableReference() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualCallableReference.kt"); + } + + @Test + @TestMetadata("expectActualDifferentPackages.kt") + public void testExpectActualDifferentPackages() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualDifferentPackages.kt"); + } + + @Test + @TestMetadata("expectActualFakeOverrides.kt") + public void testExpectActualFakeOverrides() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualFakeOverrides.kt"); + } + + @Test + @TestMetadata("expectActualMultiCommon.kt") + public void testExpectActualMultiCommon() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualMultiCommon.kt"); + } + + @Test + @TestMetadata("expectActualOverloads.kt") + public void testExpectActualOverloads() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualOverloads.kt"); + } + + @Test + @TestMetadata("expectActualSimple.kt") + public void testExpectActualSimple() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualSimple.kt"); + } + + @Test + @TestMetadata("expectActualTypealias.kt") + public void testExpectActualTypealias() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualTypealias.kt"); + } + + @Test + @TestMetadata("kt-51753-1.kt") + public void testKt_51753_1() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/kt-51753-1.kt"); + } + + @Test + @TestMetadata("kt-51753-2.kt") + public void testKt_51753_2() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/kt-51753-2.kt"); + } } } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/Fir2IrJsResultsConverter.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/Fir2IrJsResultsConverter.kt index c077e402524..7ccd87d56d8 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/Fir2IrJsResultsConverter.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/Fir2IrJsResultsConverter.kt @@ -126,7 +126,8 @@ fun AbstractFirAnalyzerFacade.convertToJsIr( Fir2IrJvmSpecialAnnotationSymbolProvider(), // TODO: replace with appropriate (probably empty) implementation irGeneratorExtensions, generateSignatures = false, - kotlinBuiltIns = builtIns ?: DefaultBuiltIns.Instance // TODO: consider passing externally + kotlinBuiltIns = builtIns ?: DefaultBuiltIns.Instance, // TODO: consider passing externally, + dependentComponents = emptyList() ).also { (it.irModuleFragment.descriptor as? FirModuleDescriptor)?.let { it.allDependencyModules = dependencies } } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/Fir2IrResultsConverter.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/Fir2IrResultsConverter.kt index 5752103f187..765509de807 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/Fir2IrResultsConverter.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/Fir2IrResultsConverter.kt @@ -68,7 +68,14 @@ class Fir2IrResultsConverter( lateinit var mainIrPart: JvmIrCodegenFactory.JvmIrBackendInput for ((index, firOutputPart) in inputArtifact.partsForDependsOnModules.withIndex()) { - val (irModuleFragment, components, pluginContext) = firOutputPart.firAnalyzerFacade.convertToIr(fir2IrExtensions) + val dependentComponents = mutableListOf() + if (isMppSupported) { + for (dependency in firOutputPart.module.dependsOnDependencies) { + dependentComponents.add(componentsMap[dependency.moduleName]!!) + } + } + + val (irModuleFragment, components, pluginContext) = firOutputPart.firAnalyzerFacade.convertToIr(fir2IrExtensions, dependentComponents) componentsMap[firOutputPart.module.name] = components val irPart = JvmIrCodegenFactory.JvmIrBackendInput( diff --git a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/GenerationUtils.kt b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/GenerationUtils.kt index 3568f7425db..f05e1c7fe68 100644 --- a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/GenerationUtils.kt +++ b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/GenerationUtils.kt @@ -123,7 +123,7 @@ object GenerationUtils { generateSignatures = false ) val fir2IrExtensions = JvmFir2IrExtensions(configuration, JvmIrDeserializerImpl(), JvmIrMangler) - val (moduleFragment, components, pluginContext) = firAnalyzerFacade.convertToIr(fir2IrExtensions) + val (moduleFragment, components, pluginContext) = firAnalyzerFacade.convertToIr(fir2IrExtensions, dependentComponents = emptyList()) val dummyBindingContext = NoScopeRecordCliBindingTrace().bindingContext val codegenFactory = JvmIrCodegenFactory( diff --git a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/fir/FirAnalyzerFacade.kt b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/fir/FirAnalyzerFacade.kt index 2ec812c4376..957722634f8 100644 --- a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/fir/FirAnalyzerFacade.kt +++ b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/fir/FirAnalyzerFacade.kt @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.diagnostics.DiagnosticReporterFactory import org.jetbrains.kotlin.diagnostics.KtDiagnostic import org.jetbrains.kotlin.fir.analysis.collectors.FirDiagnosticsCollector +import org.jetbrains.kotlin.fir.backend.Fir2IrComponents import org.jetbrains.kotlin.fir.backend.Fir2IrConverter import org.jetbrains.kotlin.fir.backend.Fir2IrExtensions import org.jetbrains.kotlin.fir.backend.Fir2IrResult @@ -37,7 +38,7 @@ abstract class AbstractFirAnalyzerFacade { abstract fun runResolution(): List - abstract fun convertToIr(fir2IrExtensions: Fir2IrExtensions): Fir2IrResult + abstract fun convertToIr(fir2IrExtensions: Fir2IrExtensions, dependentComponents: List): Fir2IrResult } class FirAnalyzerFacade( @@ -103,7 +104,7 @@ class FirAnalyzerFacade( return collectedDiagnostics!! } - override fun convertToIr(fir2IrExtensions: Fir2IrExtensions): Fir2IrResult { + override fun convertToIr(fir2IrExtensions: Fir2IrExtensions, dependentComponents: List): Fir2IrResult { if (_scopeSession == null) runResolution() val mangler = JvmDescriptorMangler(null) val signaturer = JvmIdSignatureDescriptor(mangler) @@ -117,7 +118,8 @@ class FirAnalyzerFacade( Fir2IrJvmSpecialAnnotationSymbolProvider(), irGeneratorExtensions, generateSignatures, - kotlinBuiltIns = DefaultBuiltIns.Instance // TODO: consider passing externally + kotlinBuiltIns = DefaultBuiltIns.Instance, // TODO: consider passing externally, + dependentComponents = dependentComponents ) } } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index b087c454fb5..e412ad2e1ab 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -26977,6 +26977,26 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes public void testAllFilesPresentInMultiModule() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/multiModule"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + + @TestMetadata("correctParentForTypeParameter.kt") + public void testCorrectParentForTypeParameter() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/correctParentForTypeParameter.kt"); + } + + @TestMetadata("enumEntryNameCall.kt") + public void testEnumEntryNameCall() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/enumEntryNameCall.kt"); + } + + @TestMetadata("expectActualMultiCommon.kt") + public void testExpectActualMultiCommon() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualMultiCommon.kt"); + } + + @TestMetadata("expectActualSimple.kt") + public void testExpectActualSimple() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualSimple.kt"); + } } } diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Fir2Ir.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Fir2Ir.kt index c42f80f5253..ef35379e049 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Fir2Ir.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Fir2Ir.kt @@ -78,7 +78,8 @@ internal fun PhaseContext.fir2Ir( Fir2IrJvmSpecialAnnotationSymbolProvider(), // TODO: replace with appropriate (probably empty) implementation IrGenerationExtension.getInstances(config.project), generateSignatures = false, - kotlinBuiltIns = builtInsModule ?: DefaultBuiltIns.Instance // TODO: consider passing externally + kotlinBuiltIns = builtInsModule ?: DefaultBuiltIns.Instance, // TODO: consider passing externally + dependentComponents = emptyList() ).also { (it.irModuleFragment.descriptor as? FirModuleDescriptor)?.let { it.allDependencyModules = librariesDescriptors } }