diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/session/FirSessionFactory.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/session/FirSessionFactory.kt index 99242c2afff..f2555edce33 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/session/FirSessionFactory.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/session/FirSessionFactory.kt @@ -19,10 +19,7 @@ import org.jetbrains.kotlin.fir.checkers.registerJvmCheckers import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.deserialization.ModuleDataProvider import org.jetbrains.kotlin.fir.deserialization.SingleModuleDataProvider -import org.jetbrains.kotlin.fir.extensions.BunchOfRegisteredExtensions -import org.jetbrains.kotlin.fir.extensions.FirExtensionDeclarationsSymbolProvider -import org.jetbrains.kotlin.fir.extensions.extensionService -import org.jetbrains.kotlin.fir.extensions.registerExtensions +import org.jetbrains.kotlin.fir.extensions.* import org.jetbrains.kotlin.fir.java.FirCliSession import org.jetbrains.kotlin.fir.java.FirProjectSessionProvider import org.jetbrains.kotlin.fir.java.JavaSymbolProvider @@ -167,7 +164,7 @@ object FirSessionFactory { }.configure() val dependenciesSymbolProvider = FirDependenciesSymbolProviderImpl(this) - val generatedSymbolsProvider = FirExtensionDeclarationsSymbolProvider.create(this) + val generatedSymbolsProvider = FirSwitchableExtensionDeclarationsSymbolProvider.create(this) register( FirSymbolProvider::class, FirCompositeSymbolProvider( @@ -182,7 +179,7 @@ object FirSessionFactory { ) ) - generatedSymbolsProvider?.let { register(FirExtensionDeclarationsSymbolProvider::class, it) } + generatedSymbolsProvider?.let { register(FirSwitchableExtensionDeclarationsSymbolProvider::class, it) } register( FirDependenciesSymbolProvider::class, diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index 8b3a48491bf..57e6fe5decc 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.backend.generators.FakeOverrideGenerator import org.jetbrains.kotlin.fir.builder.buildPackageDirective +import org.jetbrains.kotlin.fir.caches.getValue import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.builder.buildFile import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty @@ -23,8 +24,10 @@ import org.jetbrains.kotlin.fir.declarations.utils.isInline import org.jetbrains.kotlin.fir.declarations.utils.isJava import org.jetbrains.kotlin.fir.declarations.utils.visibility import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.extensions.FirExtensionApiInternals import org.jetbrains.kotlin.fir.extensions.declarationGenerators import org.jetbrains.kotlin.fir.extensions.extensionService +import org.jetbrains.kotlin.fir.extensions.generatedDeclarationsSymbolProvider import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.references.FirErrorNamedReference import org.jetbrains.kotlin.fir.references.FirReference @@ -610,11 +613,12 @@ fun FirRegularClass.getIrSymbolsForSealedSubclasses(components: Fir2IrComponents }.filterIsInstance() } +@OptIn(FirExtensionApiInternals::class) fun FirSession.createFilesWithGeneratedDeclarations(): List { - val symbolProvider = symbolProvider + val symbolProvider = generatedDeclarationsSymbolProvider ?: return emptyList() val declarationGenerators = extensionService.declarationGenerators - val topLevelClasses = declarationGenerators.flatMap { it.getTopLevelClassIds() }.groupBy { it.packageFqName } - val topLevelCallables = declarationGenerators.flatMap { it.getTopLevelCallableIds() }.groupBy { it.packageName } + val topLevelClasses = declarationGenerators.flatMap { it.topLevelClassIdsCache.getValue() }.groupBy { it.packageFqName } + val topLevelCallables = declarationGenerators.flatMap { it.topLevelCallableIdsCache.getValue() }.groupBy { it.packageName } return buildList { for (packageFqName in (topLevelClasses.keys + topLevelCallables.keys)) { diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/extensions/FirDeclarationGenerationExtension.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/extensions/FirDeclarationGenerationExtension.kt index 2fe3636d6e1..2c038e27d94 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/extensions/FirDeclarationGenerationExtension.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/extensions/FirDeclarationGenerationExtension.kt @@ -6,6 +6,9 @@ package org.jetbrains.kotlin.fir.extensions import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.caches.FirCache +import org.jetbrains.kotlin.fir.caches.FirLazyValue +import org.jetbrains.kotlin.fir.caches.firCachesFactory import org.jetbrains.kotlin.fir.declarations.FirClass import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.CallableId @@ -28,9 +31,6 @@ abstract class FirDeclarationGenerationExtension(session: FirSession) : FirPredi final override val extensionType: KClass = FirDeclarationGenerationExtension::class - abstract fun needToGenerateAdditionalMembersInClass(klass: FirClass): Boolean - abstract fun needToGenerateNestedClassifiersInClass(klass: FirClass): Boolean - /* * Can be called on SUPERTYPES stage * @@ -41,18 +41,43 @@ abstract class FirDeclarationGenerationExtension(session: FirSession) : FirPredi // Can be called on STATUS stage open fun generateFunctions(callableId: CallableId, owner: FirClassSymbol<*>?): List = emptyList() open fun generateProperties(callableId: CallableId, owner: FirClassSymbol<*>?): List = emptyList() - open fun generateConstructors(callableId: CallableId): List = emptyList() + open fun generateConstructors(owner: FirClassSymbol<*>): List = emptyList() // Can be called on IMPORTS stage open fun hasPackage(packageFqName: FqName): Boolean = false - // Can be called after BODY_RESOLVE stage (checkers and fir2ir) + /* + * Can be called after SUPERTYPES stage + * + * `generate...` methods will be called only if `get...Names/ClassIds/CallableIds` returned corresponding + * declaration name + * + * If you want to generate constructor for some class, then you need to return `SpecialNames.INIT` in + * set of callable names for this class + */ open fun getCallableNamesForClass(classSymbol: FirClassSymbol<*>): Set = emptySet() open fun getNestedClassifiersNames(classSymbol: FirClassSymbol<*>): Set = emptySet() open fun getTopLevelCallableIds(): Set = emptySet() open fun getTopLevelClassIds(): Set = emptySet() fun interface Factory : FirExtension.Factory + + // ----------------------------------- internal utils ----------------------------------- + + @FirExtensionApiInternals + val nestedClassifierNamesCache: FirCache, Set, Nothing?> = + session.firCachesFactory.createCache { symbol, _ -> + getNestedClassifiersNames(symbol) + } + + @FirExtensionApiInternals + val topLevelClassIdsCache: FirLazyValue, Nothing?> = + session.firCachesFactory.createLazyValue { getTopLevelClassIds() } + + @FirExtensionApiInternals + val topLevelCallableIdsCache: FirLazyValue, Nothing?> = + session.firCachesFactory.createLazyValue { getTopLevelCallableIds() } + } val FirExtensionService.declarationGenerators: List by FirExtensionService.registeredExtensions() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/extensions/FirExtensionDeclarationsSymbolProvider.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/extensions/FirExtensionDeclarationsSymbolProvider.kt similarity index 66% rename from compiler/fir/resolve/src/org/jetbrains/kotlin/fir/extensions/FirExtensionDeclarationsSymbolProvider.kt rename to compiler/fir/providers/src/org/jetbrains/kotlin/fir/extensions/FirExtensionDeclarationsSymbolProvider.kt index 97e3a671dda..c419f653129 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/extensions/FirExtensionDeclarationsSymbolProvider.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/extensions/FirExtensionDeclarationsSymbolProvider.kt @@ -7,21 +7,21 @@ package org.jetbrains.kotlin.fir.extensions import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSessionComponent -import org.jetbrains.kotlin.fir.caches.FirCache -import org.jetbrains.kotlin.fir.caches.FirCachesFactory -import org.jetbrains.kotlin.fir.caches.firCachesFactory -import org.jetbrains.kotlin.fir.caches.getValue +import org.jetbrains.kotlin.fir.caches.* import org.jetbrains.kotlin.fir.declarations.validate import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProviderInternals import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider +import org.jetbrains.kotlin.fir.scopes.impl.groupExtensionsByName import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.CallableId import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.utils.addToStdlib.flatGroupBy +@OptIn(FirExtensionApiInternals::class) class FirExtensionDeclarationsSymbolProvider private constructor( session: FirSession, cachesFactory: FirCachesFactory, @@ -53,10 +53,37 @@ class FirExtensionDeclarationsSymbolProvider private constructor( hasPackage(packageFqName) } + private val extensionsByTopLevelClassId: FirLazyValue>, Nothing?> = + session.firCachesFactory.createLazyValue { + extensions.flatGroupBy { it.topLevelClassIdsCache.getValue() } + } + + private val extensionsByNestedClassifierClassId: FirCache>, Nothing?> = + session.firCachesFactory.createCache cache@{ outerClassId, _ -> + val outerClassSymbol = session.symbolProvider.getClassLikeSymbolByClassId(outerClassId) as? FirClassSymbol<*> + ?: return@cache emptyMap() + session.groupExtensionsByName( + outerClassSymbol.fir, + nameExtractor = { nestedClassifierNamesCache.getValue(outerClassSymbol) }, + nameTransformer = { outerClassId.createNestedClassId(it) } + ) + } + + private val extensionsByTopLevelCallableId: FirLazyValue>, Nothing?> = + session.firCachesFactory.createLazyValue { + extensions.flatGroupBy { it.topLevelCallableIdsCache.getValue() } + } + // ------------------------------------------ generators ------------------------------------------ private fun generateClassLikeDeclaration(classId: ClassId): FirClassLikeSymbol<*>? { - val generatedClasses = extensions.mapNotNull { it.generateClassLikeDeclaration(classId) }.onEach { it.fir.validate() } + val matchedExtensions = when { + classId.isNestedClass -> extensionsByNestedClassifierClassId.getValue(classId.outerClassId!!)[classId] + else -> extensionsByTopLevelClassId.getValue()[classId] + } ?: return null + val generatedClasses = matchedExtensions + .mapNotNull { it.generateClassLikeDeclaration(classId) } + .onEach { it.fir.validate() } return when (generatedClasses.size) { 0 -> null 1 -> generatedClasses.first() @@ -65,11 +92,15 @@ class FirExtensionDeclarationsSymbolProvider private constructor( } private fun generateTopLevelFunctions(callableId: CallableId): List { - return extensions.flatMap { it.generateFunctions(callableId, owner = null) }.onEach { it.fir.validate() } + return extensionsByTopLevelCallableId.getValue()[callableId].orEmpty() + .flatMap { it.generateFunctions(callableId, owner = null) } + .onEach { it.fir.validate() } } private fun generateTopLevelProperties(callableId: CallableId): List { - return extensions.flatMap { it.generateProperties(callableId, owner = null) }.onEach { it.fir.validate() } + return extensionsByTopLevelCallableId.getValue()[callableId].orEmpty() + .flatMap { it.generateProperties(callableId, owner = null) } + .onEach { it.fir.validate() } } private fun hasPackage(packageFqName: FqName): Boolean { @@ -103,5 +134,3 @@ class FirExtensionDeclarationsSymbolProvider private constructor( return fqName.takeIf { packageCache.getValue(fqName, null) } } } - -val FirSession.generatedDeclarationsSymbolProvider: FirExtensionDeclarationsSymbolProvider? by FirSession.nullableSessionComponentAccessor() diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/extensions/FirSwitchableExtensionDeclarationsSymbolProvider.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/extensions/FirSwitchableExtensionDeclarationsSymbolProvider.kt new file mode 100644 index 00000000000..9c7f7be8966 --- /dev/null +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/extensions/FirSwitchableExtensionDeclarationsSymbolProvider.kt @@ -0,0 +1,76 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.extensions + +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider +import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProviderInternals +import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name + +/* + * This provider is needed because we need to have ability to disable FirExtensionDeclarationsSymbolProvider during + * phase of annotations for plugins resolution. At this stage predicateBasedProvider is not indexed, so it will return + * empty results for all requests + * + * This is also legal, because plugins can not generate annotation classes which can influence other plugins or this plugin itself + */ +class FirSwitchableExtensionDeclarationsSymbolProvider private constructor( + private val delegate: FirSymbolProvider +) : FirSymbolProvider(delegate.session) { + companion object { + fun create(session: FirSession): FirSwitchableExtensionDeclarationsSymbolProvider? { + return FirExtensionDeclarationsSymbolProvider.create(session)?.let { FirSwitchableExtensionDeclarationsSymbolProvider(it) } + } + } + + private var disabled: Boolean = false + + override fun getClassLikeSymbolByClassId(classId: ClassId): FirClassLikeSymbol<*>? { + if (disabled) return null + return delegate.getClassLikeSymbolByClassId(classId) + } + + @FirSymbolProviderInternals + override fun getTopLevelCallableSymbolsTo(destination: MutableList>, packageFqName: FqName, name: Name) { + if (disabled) return + delegate.getTopLevelCallableSymbolsTo(destination, packageFqName, name) + } + + @FirSymbolProviderInternals + override fun getTopLevelFunctionSymbolsTo(destination: MutableList, packageFqName: FqName, name: Name) { + if (disabled) return + delegate.getTopLevelFunctionSymbolsTo(destination, packageFqName, name) + } + + @FirSymbolProviderInternals + override fun getTopLevelPropertySymbolsTo(destination: MutableList, packageFqName: FqName, name: Name) { + if (disabled) return + delegate.getTopLevelPropertySymbolsTo(destination, packageFqName, name) + } + + override fun getPackage(fqName: FqName): FqName? { + if (disabled) return null + return delegate.getPackage(fqName) + } + + @FirSymbolProviderInternals + fun disable() { + disabled = true + } + + @FirSymbolProviderInternals + fun enable() { + disabled = false + } +} + +val FirSession.generatedDeclarationsSymbolProvider: FirSwitchableExtensionDeclarationsSymbolProvider? by FirSession.nullableSessionComponentAccessor() diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirDeclaredMemberScopeProvider.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirDeclaredMemberScopeProvider.kt index 15af3c97190..67b1007e5fd 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirDeclaredMemberScopeProvider.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirDeclaredMemberScopeProvider.kt @@ -12,11 +12,10 @@ import org.jetbrains.kotlin.fir.caches.FirCache import org.jetbrains.kotlin.fir.caches.firCachesFactory import org.jetbrains.kotlin.fir.caches.getValue import org.jetbrains.kotlin.fir.declarations.FirClass -import org.jetbrains.kotlin.fir.extensions.declarationGenerators -import org.jetbrains.kotlin.fir.extensions.extensionService import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider import org.jetbrains.kotlin.fir.scopes.FirContainingNamesAwareScope import org.jetbrains.kotlin.fir.scopes.FirNameAwareCompositeScope +import org.jetbrains.kotlin.fir.scopes.FirTypeScope import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name @@ -31,8 +30,6 @@ class FirDeclaredMemberScopeProvider(val useSiteSession: FirSession) : FirSessio private val nestedClassifierCache: FirCache = useSiteSession.firCachesFactory.createCache { klass, _ -> createNestedClassifierScope(klass) } - private val extensions by lazy(LazyThreadSafetyMode.PUBLICATION) { useSiteSession.extensionService.declarationGenerators } - fun declaredMemberScope( klass: FirClass, useLazyNestedClassifierScope: Boolean, @@ -56,7 +53,7 @@ class FirDeclaredMemberScopeProvider(val useSiteSession: FirSession) : FirSessio ): FirContainingNamesAwareScope { return when { klass.origin.generated -> { - FirGeneratedClassDeclaredMemberScope(useSiteSession, klass, needNestedClassifierScope = true) + FirGeneratedClassDeclaredMemberScope.create(useSiteSession, klass, needNestedClassifierScope = true) ?: FirTypeScope.Empty } else -> { val baseScope = FirClassDeclaredMemberScopeImpl( @@ -66,10 +63,9 @@ class FirDeclaredMemberScopeProvider(val useSiteSession: FirSession) : FirSessio existingNames, symbolProvider ) - if (extensions.any { it.needToGenerateAdditionalMembersInClass(klass) }) { - FirNameAwareCompositeScope( - listOf(baseScope, FirGeneratedClassDeclaredMemberScope(useSiteSession, klass, needNestedClassifierScope = false)) - ) + val generatedScope = FirGeneratedClassDeclaredMemberScope.create(useSiteSession, klass, needNestedClassifierScope = false) + if (generatedScope != null) { + FirNameAwareCompositeScope(listOf(baseScope, generatedScope)) } else { baseScope } @@ -83,19 +79,20 @@ class FirDeclaredMemberScopeProvider(val useSiteSession: FirSession) : FirSessio private fun createNestedClassifierScope(klass: FirClass): FirNestedClassifierScope? { return if (klass.origin.generated) { - FirGeneratedClassNestedClassifierScope(klass, useSiteSession) + FirGeneratedClassNestedClassifierScope.create(useSiteSession, klass) } else { val baseScope = FirNestedClassifierScopeImpl(klass, useSiteSession) - if (extensions.any { it.needToGenerateNestedClassifiersInClass(klass) }) { + val generatedScope = FirGeneratedClassNestedClassifierScope.create(useSiteSession, klass) + if (generatedScope != null) { FirCompositeNestedClassifierScope( - listOf(baseScope, FirGeneratedClassNestedClassifierScope(klass, useSiteSession)), + listOf(baseScope, generatedScope), klass, useSiteSession ) } else { baseScope } - }.takeUnless { it.isEmpty() } + }?.takeUnless { it.isEmpty() } } } diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirGeneratedClassDeclaredMemberScope.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirGeneratedClassDeclaredMemberScope.kt index af679cc935b..105773f87ca 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirGeneratedClassDeclaredMemberScope.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirGeneratedClassDeclaredMemberScope.kt @@ -10,25 +10,44 @@ import org.jetbrains.kotlin.fir.caches.FirCache import org.jetbrains.kotlin.fir.caches.FirLazyValue import org.jetbrains.kotlin.fir.caches.firCachesFactory import org.jetbrains.kotlin.fir.caches.getValue -import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.FirClass +import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin +import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.utils.classId -import org.jetbrains.kotlin.fir.extensions.FirDeclarationGenerationExtension -import org.jetbrains.kotlin.fir.extensions.declarationGenerators -import org.jetbrains.kotlin.fir.extensions.extensionService -import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider +import org.jetbrains.kotlin.fir.declarations.validate +import org.jetbrains.kotlin.fir.extensions.* import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.CallableId import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.name.SpecialNames +import org.jetbrains.kotlin.utils.addToStdlib.flatGroupBy import org.jetbrains.kotlin.utils.addToStdlib.runIf -class FirGeneratedClassDeclaredMemberScope( +class FirGeneratedClassDeclaredMemberScope private constructor( val useSiteSession: FirSession, val firClass: FirClass, - needNestedClassifierScope: Boolean + needNestedClassifierScope: Boolean, + val extensionsByCallableName: Map>, + val allCallableNames: Set ) : FirClassDeclaredMemberScope(firClass.classId) { - private val extensions: List = firClass.findGeneratedExtensions(useSiteSession) { - needToGenerateAdditionalMembersInClass(it) + companion object { + fun create(session: FirSession, firClass: FirClass, needNestedClassifierScope: Boolean): FirGeneratedClassDeclaredMemberScope? { + val extensionsByCallableName = session.groupExtensionsByName( + firClass, + nameExtractor = { getCallableNamesForClass(it) }, + nameTransformer = { it } + ) + val allCallableNames = extensionsByCallableName.keys + if (allCallableNames.isEmpty()) return null + return FirGeneratedClassDeclaredMemberScope( + session, + firClass, + needNestedClassifierScope, + extensionsByCallableName, + allCallableNames + ) + } } private val nestedClassifierScope: FirNestedClassifierScope? = runIf(needNestedClassifierScope) { @@ -51,38 +70,32 @@ class FirGeneratedClassDeclaredMemberScope( generateConstructors() } - private val callableNamesCache: FirLazyValue, Nothing?> = firCachesFactory.createLazyValue { - extensions.flatMapTo(mutableSetOf()) { it.getCallableNamesForClass(firClass.symbol) } - } - // ------------------------------------------ generators ------------------------------------------ private fun generateMemberFunctions(name: Name): List { - return extensions + if (name == SpecialNames.INIT) return emptyList() + return extensionsByCallableName[name].orEmpty() .flatMap { it.generateFunctions(CallableId(firClass.classId, name), firClass.symbol) } .onEach { it.fir.validate() } } private fun generateMemberProperties(name: Name): List { - return extensions + if (name == SpecialNames.INIT) return emptyList() + return extensionsByCallableName[name].orEmpty() .flatMap { it.generateProperties(CallableId(firClass.classId, name), firClass.symbol) } .onEach { it.fir.validate() } } private fun generateConstructors(): List { - val classId = firClass.symbol.classId - val callableId = if (classId.isNestedClass) { - CallableId(classId.parentClassId!!, classId.shortClassName) - } else { - CallableId(classId.asSingleFqName().parent(), classId.shortClassName) - } - return extensions.flatMap { it.generateConstructors(callableId) }.onEach { it.fir.validate() } + return extensionsByCallableName[SpecialNames.INIT].orEmpty() + .flatMap { it.generateConstructors(firClass.symbol) } + .onEach { it.fir.validate() } } // ------------------------------------------ scope methods ------------------------------------------ override fun getCallableNames(): Set { - return callableNamesCache.getValue() + return allCallableNames } override fun getClassifierNames(): Set { @@ -114,22 +127,51 @@ class FirGeneratedClassDeclaredMemberScope( } } -class FirGeneratedClassNestedClassifierScope( +internal inline fun FirSession.groupExtensionsByName( klass: FirClass, - useSiteSession: FirSession + nameExtractor: FirDeclarationGenerationExtension.(FirClassSymbol<*>) -> Set, + nameTransformer: (T) -> V +): Map> { + val extensions = getExtensionsForClass(klass) + val symbol = klass.symbol + return extensions.flatGroupBy( + keySelector = { extension -> extension.nameExtractor(symbol) }, + keyTransformer = nameTransformer, + valueTransformer = { it } + ) +} + +internal fun FirSession.getExtensionsForClass(klass: FirClass): List { + val extensions = extensionService.declarationGenerators + return if (klass.origin.generated) { + val pluginKey = (klass.origin as FirDeclarationOrigin.Plugin).key + extensions.filter { it.key == pluginKey } + } else { + extensions + } +} + +class FirGeneratedClassNestedClassifierScope private constructor( + useSiteSession: FirSession, + klass: FirClass, + private val nestedClassifierNames: Set ) : FirNestedClassifierScope(klass, useSiteSession) { - private val extensions = klass.findGeneratedExtensions(useSiteSession) { needToGenerateNestedClassifiersInClass(it) } + companion object { + @OptIn(FirExtensionApiInternals::class) + fun create(useSiteSession: FirSession, klass: FirClass): FirGeneratedClassNestedClassifierScope? { + val extensions = useSiteSession.getExtensionsForClass(klass) + val symbol = klass.symbol + val classifierNames = extensions.flatMapTo(mutableSetOf()) { it.nestedClassifierNamesCache.getValue(symbol) } + if (classifierNames.isEmpty()) return null + return FirGeneratedClassNestedClassifierScope(useSiteSession, klass, classifierNames) + } + } private val nestedClassifierCache: FirCache = useSiteSession.firCachesFactory.createCache { name, _ -> generateNestedClassifier(name) } - private val nestedClassifiersNames: FirLazyValue, Nothing?> = - useSiteSession.firCachesFactory.createLazyValue { - extensions.flatMapTo(mutableSetOf()) { it.getNestedClassifiersNames(klass.symbol) } - } - private fun generateNestedClassifier(name: Name): FirRegularClassSymbol? { if (klass is FirRegularClass) { val companion = klass.companionObjectSymbol @@ -138,8 +180,9 @@ class FirGeneratedClassNestedClassifierScope( } } - if (name !in getClassifierNames()) return null - val generatedClass = useSiteSession.symbolProvider.getClassLikeSymbolByClassId(klass.classId.createNestedClassId(name)) + if (name !in nestedClassifierNames) return null + val generatedClass = useSiteSession.generatedDeclarationsSymbolProvider + ?.getClassLikeSymbolByClassId(klass.classId.createNestedClassId(name)) require(generatedClass is FirRegularClassSymbol?) { "Only regular class are allowed as nested classes" } return generatedClass } @@ -149,26 +192,10 @@ class FirGeneratedClassNestedClassifierScope( } override fun isEmpty(): Boolean { - return getClassifierNames().isEmpty() + return nestedClassifierNames.isEmpty() } override fun getClassifierNames(): Set { - return nestedClassifiersNames.getValue() - } -} - - -private inline fun FirClass.findGeneratedExtensions( - useSiteSession: FirSession, - predicate: FirDeclarationGenerationExtension.(FirClass) -> Boolean -): List { - val origin = origin - val declarationGenerators = useSiteSession.extensionService.declarationGenerators - return if (origin is FirDeclarationOrigin.Plugin) { - declarationGenerators.filter { it.key == origin.key }.also { - require(it.isNotEmpty()) { "Extension for ${origin.key} not found" } - } - } else { - declarationGenerators.filter { it.predicate(this) } + return nestedClassifierNames } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirResolveProcessor.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirResolveProcessor.kt index b24c5a4e1ed..6f3c506613b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirResolveProcessor.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirResolveProcessor.kt @@ -13,7 +13,11 @@ import org.jetbrains.kotlin.fir.visitors.FirTransformer @RequiresOptIn(message = "Should be used just only in resolve processor") annotation class AdapterForResolveProcessor -sealed class FirResolveProcessor(val session: FirSession, val scopeSession: ScopeSession) +sealed class FirResolveProcessor(val session: FirSession, val scopeSession: ScopeSession) { + open fun beforePhase() {} + + open fun afterPhase() {} +} abstract class FirGlobalResolveProcessor(session: FirSession, scopeSession: ScopeSession) : FirResolveProcessor(session, scopeSession) { abstract fun process(files: Collection) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTotalResolveProcessor.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTotalResolveProcessor.kt index 9c303db5d0e..16904d8d289 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTotalResolveProcessor.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTotalResolveProcessor.kt @@ -22,6 +22,7 @@ class FirTotalResolveProcessor(session: FirSession, enablePluginPhases: Boolean fun process(files: List) { for (processor in processors) { + processor.beforePhase() when (processor) { is FirTransformerBasedResolveProcessor -> { for (file in files) { @@ -32,6 +33,7 @@ class FirTotalResolveProcessor(session: FirSession, enablePluginPhases: Boolean processor.process(files) } } + processor.afterPhase() } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirPluginAnnotationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirPluginAnnotationsResolveTransformer.kt index 79b8974e726..e80b34e58f6 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirPluginAnnotationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirPluginAnnotationsResolveTransformer.kt @@ -22,11 +22,25 @@ import org.jetbrains.kotlin.fir.expressions.FirStatement import org.jetbrains.kotlin.fir.extensions.* import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.fqName +import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProviderInternals import org.jetbrains.kotlin.fir.resolve.transformers.* import org.jetbrains.kotlin.name.FqName -class FirPluginAnnotationsResolveProcessor(session: FirSession, scopeSession: ScopeSession) : FirTransformerBasedResolveProcessor(session, scopeSession) { +class FirPluginAnnotationsResolveProcessor( + session: FirSession, + scopeSession: ScopeSession +) : FirTransformerBasedResolveProcessor(session, scopeSession) { override val transformer = FirPluginAnnotationsResolveTransformer(session, scopeSession) + + @OptIn(FirSymbolProviderInternals::class) + override fun beforePhase() { + session.generatedDeclarationsSymbolProvider?.disable() + } + + @OptIn(FirSymbolProviderInternals::class) + override fun afterPhase() { + session.generatedDeclarationsSymbolProvider?.enable() + } } class FirPluginAnnotationsResolveTransformer( diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/extensions/FirExtension.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/extensions/FirExtension.kt index 804ffd3912b..e4e2ef3f01d 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/extensions/FirExtension.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/extensions/FirExtension.kt @@ -45,3 +45,6 @@ abstract class FirDeclarationPredicateRegistrar { abstract fun register(vararg predicates: DeclarationPredicate) abstract fun register(predicates: Collection) } + +@RequiresOptIn +annotation class FirExtensionApiInternals diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirFunctionSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirFunctionSymbol.kt index 13b47c3f44c..1495358983e 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirFunctionSymbol.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirFunctionSymbol.kt @@ -12,9 +12,7 @@ import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.symbols.ensureResolved -import org.jetbrains.kotlin.name.CallableId -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.name.* sealed class FirFunctionSymbol( override val callableId: CallableId @@ -57,6 +55,8 @@ class FirIntersectionOverrideFunctionSymbol( class FirConstructorSymbol( callableId: CallableId ) : FirFunctionSymbol(callableId) { + constructor(classId: ClassId) : this(classId.callableIdForConstructor()) + val isPrimary: Boolean get() = fir.isPrimary diff --git a/core/compiler.common/src/org/jetbrains/kotlin/name/FqNamesUtil.kt b/core/compiler.common/src/org/jetbrains/kotlin/name/FqNamesUtil.kt index 8adaa267b57..e56121cef92 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/name/FqNamesUtil.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/name/FqNamesUtil.kt @@ -75,3 +75,11 @@ fun FqName.findValueForMostSpecificFqname(values: Map): V? { return suitableItems.minByOrNull { (fqName, _) -> fqName.tail(this).asString().length }?.value } + +fun ClassId.callableIdForConstructor(): CallableId { + return if (isNestedClass) { + CallableId(outerClassId!!, shortClassName) + } else { + CallableId(packageFqName, shortClassName) + } +} diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt index e4a1c8f853a..16435e86a5f 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt @@ -208,3 +208,30 @@ inline fun Boolean.ifTrue(body: () -> T?): T? = inline fun Boolean.ifFalse(body: () -> T?): T? = if (!this) body() else null + +inline fun List.flatGroupBy(keySelector: (T) -> Collection): Map> { + return flatGroupBy(keySelector, keyTransformer = { it }, valueTransformer = { it }) +} + +inline fun List.flatGroupBy( + keySelector: (T) -> Collection, + keyTransformer: (U) -> K, + valueTransformer: (T) -> V +): Map> { + val result = mutableMapOf>() + for (element in this) { + val keys = keySelector(element) + val value = valueTransformer(element) + for (key in keys) { + val transformedKey = keyTransformer(key) + // Map.computeIfAbsent is missing in JDK 1.6 + var list = result[transformedKey] + if (list == null) { + list = mutableListOf() + result[transformedKey] = list + } + list += value + } + } + return result +} diff --git a/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/AdditionalMembersGenerator.kt b/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/AdditionalMembersGenerator.kt index f2a6d298fd9..954205bbee7 100644 --- a/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/AdditionalMembersGenerator.kt +++ b/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/AdditionalMembersGenerator.kt @@ -10,7 +10,6 @@ import org.jetbrains.kotlin.descriptors.EffectiveVisibility import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.declarations.FirClass import org.jetbrains.kotlin.fir.declarations.FirPluginKey import org.jetbrains.kotlin.fir.declarations.builder.buildRegularClass import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl @@ -26,6 +25,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.CallableId import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.name.SpecialNames /* * For each class annotated with @C generates @@ -45,6 +45,10 @@ class AdditionalMembersGenerator(session: FirSession) : FirDeclarationGeneration predicateBasedProvider.getSymbolsByPredicate(PREDICATE).filterIsInstance() } + private val nestedClassIds by lazy { + matchedClasses.map { it.classId.createNestedClassId(NESTED_NAME) } + } + override fun generateFunctions(callableId: CallableId, owner: FirClassSymbol<*>?): List { if (callableId.callableName != MATERIALIZE_NAME) return emptyList() val classId = callableId.classId ?: return emptyList() @@ -68,15 +72,17 @@ class AdditionalMembersGenerator(session: FirSession) : FirDeclarationGeneration }.symbol } - override fun generateConstructors(callableId: CallableId): List { - val classId = callableId.classId ?: return emptyList() - if (callableId.callableName != NESTED_NAME) return emptyList() - if (matchedClasses.none { it.classId == classId }) return emptyList() - return listOf(buildConstructor(classId.createNestedClassId(NESTED_NAME), callableId, isInner = false).symbol) + override fun generateConstructors(owner: FirClassSymbol<*>): List { + assert(owner.classId in nestedClassIds) + return listOf(buildConstructor(owner.classId, isInner = false).symbol) } override fun getCallableNamesForClass(classSymbol: FirClassSymbol<*>): Set { - return if (classSymbol in matchedClasses) setOf(MATERIALIZE_NAME) else emptySet() + return when { + classSymbol in matchedClasses -> setOf(MATERIALIZE_NAME) + classSymbol.classId in nestedClassIds -> setOf(SpecialNames.INIT) + else -> emptySet() + } } override fun getNestedClassifiersNames(classSymbol: FirClassSymbol<*>): Set { @@ -92,14 +98,6 @@ class AdditionalMembersGenerator(session: FirSession) : FirDeclarationGeneration override val key: FirPluginKey get() = Key - override fun needToGenerateAdditionalMembersInClass(klass: FirClass): Boolean { - return session.predicateBasedProvider.matches(PREDICATE, klass) - } - - override fun needToGenerateNestedClassifiersInClass(klass: FirClass): Boolean { - return session.predicateBasedProvider.matches(PREDICATE, klass) - } - override fun FirDeclarationPredicateRegistrar.registerPredicates() { register(PREDICATE) } diff --git a/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/CompanionGenerator.kt b/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/CompanionGenerator.kt index c0df7bf9f40..c14141e2297 100644 --- a/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/CompanionGenerator.kt +++ b/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/CompanionGenerator.kt @@ -10,14 +10,10 @@ import org.jetbrains.kotlin.descriptors.EffectiveVisibility import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.declarations.FirClass import org.jetbrains.kotlin.fir.declarations.FirPluginKey -import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.builder.buildRegularClass import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl -import org.jetbrains.kotlin.fir.declarations.utils.classId -import org.jetbrains.kotlin.fir.declarations.utils.isCompanion import org.jetbrains.kotlin.fir.extensions.FirDeclarationGenerationExtension import org.jetbrains.kotlin.fir.extensions.FirDeclarationPredicateRegistrar import org.jetbrains.kotlin.fir.extensions.predicate.has @@ -37,11 +33,11 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.SpecialNames /* - * Generates companion object with fun foo(): Int for each class annotated with @D + * Generates companion object with fun foo(): Int for each class annotated with @E */ class CompanionGenerator(session: FirSession) : FirDeclarationGenerationExtension(session) { companion object { - private val PREDICATE = has("D".fqn()) + private val PREDICATE = has("E".fqn()) private val FOO_NAME = Name.identifier("foo") } @@ -103,16 +99,6 @@ class CompanionGenerator(session: FirSession) : FirDeclarationGenerationExtensio } } - override fun needToGenerateAdditionalMembersInClass(klass: FirClass): Boolean { - if (klass !is FirRegularClass) return false - if (matchedClasses.none { it.classId == klass.classId.outerClassId }) return false - return klass.isCompanion - } - - override fun needToGenerateNestedClassifiersInClass(klass: FirClass): Boolean { - return session.predicateBasedProvider.matches(PREDICATE, klass) - } - override val key: FirPluginKey get() = Key diff --git a/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/ExternalClassGenerator.kt b/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/ExternalClassGenerator.kt index 0a2ee861962..fcdb8df4502 100644 --- a/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/ExternalClassGenerator.kt +++ b/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/ExternalClassGenerator.kt @@ -24,10 +24,7 @@ import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider import org.jetbrains.kotlin.fir.scopes.kotlinScopeProvider import org.jetbrains.kotlin.fir.symbols.SymbolInternals import org.jetbrains.kotlin.fir.symbols.impl.* -import org.jetbrains.kotlin.name.CallableId -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.name.* /* * Generates class /foo.AllOpenGenerated with @@ -83,29 +80,12 @@ class ExternalClassGenerator(session: FirSession) : FirDeclarationGenerationExte return buildClass(classId).symbol } - override fun generateConstructors(callableId: CallableId): List { - val classId = when { - callableId.isGeneratedConstructor -> GENERATED_CLASS_ID - callableId.isNestedConstructor -> GENERATED_CLASS_ID.createNestedClassId(callableId.callableName) - else -> return emptyList() - } - - return listOf(buildConstructor(classId, callableId, isInner = false).symbol) + override fun generateConstructors(owner: FirClassSymbol<*>): List { + val classId = owner.classId + if (classId != GENERATED_CLASS_ID && classId !in classIdsForMatchedClasses) return emptyList() + return listOf(buildConstructor(classId, isInner = false).symbol) } - private val CallableId.isGeneratedConstructor: Boolean - get() { - if (classId != null) return false - if (packageName != FOO_PACKAGE) return false - return callableName == GENERATED_CLASS_ID.shortClassName - } - - private val CallableId.isNestedConstructor: Boolean - get() { - if (classId != GENERATED_CLASS_ID) return false - return classIdsForMatchedClasses.keys.any { it.shortClassName == callableName } - } - private fun generateNestedClass(classId: ClassId, owner: FirClassSymbol<*>): FirClassLikeSymbol<*>? { if (owner.classId != GENERATED_CLASS_ID) return null val matchedClass = classIdsForMatchedClasses[classId] ?: return null @@ -138,10 +118,10 @@ class ExternalClassGenerator(session: FirSession) : FirDeclarationGenerationExte } override fun getCallableNamesForClass(classSymbol: FirClassSymbol<*>): Set { - return if (classSymbol.classId in classIdsForMatchedClasses) { - setOf(MATERIALIZE_NAME) - } else { - emptySet() + return when (classSymbol.classId) { + in classIdsForMatchedClasses -> setOf(MATERIALIZE_NAME, SpecialNames.INIT) + GENERATED_CLASS_ID -> setOf(SpecialNames.INIT) + else -> emptySet() } } @@ -164,14 +144,6 @@ class ExternalClassGenerator(session: FirSession) : FirDeclarationGenerationExte override val key: FirPluginKey get() = Key - override fun needToGenerateAdditionalMembersInClass(klass: FirClass): Boolean { - return false - } - - override fun needToGenerateNestedClassifiersInClass(klass: FirClass): Boolean { - return false - } - override fun FirDeclarationPredicateRegistrar.registerPredicates() { register(PREDICATE) } diff --git a/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/TopLevelDeclarationsGenerator.kt b/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/TopLevelDeclarationsGenerator.kt index 65dbbc4ffd2..2e5ce3122a7 100644 --- a/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/TopLevelDeclarationsGenerator.kt +++ b/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/TopLevelDeclarationsGenerator.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.descriptors.EffectiveVisibility import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.declarations.FirClass import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl @@ -93,14 +92,6 @@ class TopLevelDeclarationsGenerator(session: FirSession) : FirDeclarationGenerat override val key: SomePluginKey get() = SomePluginKey - override fun needToGenerateAdditionalMembersInClass(klass: FirClass): Boolean { - return false - } - - override fun needToGenerateNestedClassifiersInClass(klass: FirClass): Boolean { - return false - } - override fun FirDeclarationPredicateRegistrar.registerPredicates() { register(PREDICATE) } diff --git a/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/generationUtils.kt b/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/generationUtils.kt index 4c60dbb3403..4e16d10c401 100644 --- a/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/generationUtils.kt +++ b/plugins/fir/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/generators/generationUtils.kt @@ -59,7 +59,7 @@ fun FirDeclarationGenerationExtension.buildMaterializeFunction( } @OptIn(SymbolInternals::class) -fun FirDeclarationGenerationExtension.buildConstructor(classId: ClassId, callableId: CallableId, isInner: Boolean): FirConstructor { +fun FirDeclarationGenerationExtension.buildConstructor(classId: ClassId, isInner: Boolean): FirConstructor { val lookupTag = ConeClassLikeLookupTagImpl(classId) return buildPrimaryConstructor { moduleData = session.moduleData @@ -76,9 +76,9 @@ fun FirDeclarationGenerationExtension.buildConstructor(classId: ClassId, callabl Modality.FINAL, EffectiveVisibility.Public ) - symbol = FirConstructorSymbol(callableId) - if (isInner) { - dispatchReceiverType = callableId.classId?.let { + symbol = FirConstructorSymbol(classId) + if (isInner && classId.isNestedClass) { + dispatchReceiverType = classId.parentClassId?.let { val firClass = session.symbolProvider.getClassLikeSymbolByClassId(it)?.fir as? FirClass firClass?.defaultType() } diff --git a/plugins/fir/fir-plugin-prototype/testData/box/generatedClassWithMembersAndNestedClasses.fir.ir.txt b/plugins/fir/fir-plugin-prototype/testData/box/generatedClassWithMembersAndNestedClasses.fir.ir.txt index ef0ad8f1e17..d6f9b8cc3de 100644 --- a/plugins/fir/fir-plugin-prototype/testData/box/generatedClassWithMembersAndNestedClasses.fir.ir.txt +++ b/plugins/fir/fir-plugin-prototype/testData/box/generatedClassWithMembersAndNestedClasses.fir.ir.txt @@ -12,15 +12,15 @@ FILE fqName:bar fileName:/generatedClassWithMembersAndNestedClasses.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in bar.Foo' CONST String type=kotlin.String value="OK" + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any @@ -60,28 +60,28 @@ FILE fqName:foo fileName:__GENERATED DECLARATIONS__.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun materialize (): bar.Foo declared in foo.AllOpenGenerated.NestedFoo' CONSTRUCTOR_CALL 'public constructor () [primary] declared in bar.Foo' type=bar.Foo origin=null + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any diff --git a/plugins/fir/fir-plugin-prototype/testData/diagnostics/memberGen/classWithCompanionObject.fir.txt b/plugins/fir/fir-plugin-prototype/testData/diagnostics/memberGen/classWithCompanionObject.fir.txt index e8756165cee..f71cbfd2280 100644 --- a/plugins/fir/fir-plugin-prototype/testData/diagnostics/memberGen/classWithCompanionObject.fir.txt +++ b/plugins/fir/fir-plugin-prototype/testData/diagnostics/memberGen/classWithCompanionObject.fir.txt @@ -1,5 +1,5 @@ FILE: classWithCompanionObject.kt - @R|org/jetbrains/kotlin/fir/plugin/D|() public final class SomeClass : R|kotlin/Any|, R|foo/MyInterface| { + @R|org/jetbrains/kotlin/fir/plugin/E|() public final class SomeClass : R|kotlin/Any| { public constructor(): R|SomeClass| { super() } diff --git a/plugins/fir/fir-plugin-prototype/testData/diagnostics/memberGen/classWithCompanionObject.kt b/plugins/fir/fir-plugin-prototype/testData/diagnostics/memberGen/classWithCompanionObject.kt index af2a7c72258..3f680a6dd1a 100644 --- a/plugins/fir/fir-plugin-prototype/testData/diagnostics/memberGen/classWithCompanionObject.kt +++ b/plugins/fir/fir-plugin-prototype/testData/diagnostics/memberGen/classWithCompanionObject.kt @@ -1,6 +1,6 @@ -import org.jetbrains.kotlin.fir.plugin.D +import org.jetbrains.kotlin.fir.plugin.E -@D +@E class SomeClass fun takeInt(x: Int) {} diff --git a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.fir.ir.txt b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.fir.ir.txt index 3a2de9031f6..03c073e5f44 100644 --- a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.fir.ir.txt +++ b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/classWithGeneratedMembersAndNestedClass.fir.ir.txt @@ -13,15 +13,15 @@ FILE fqName: fileName:/classWithGeneratedMembersAndNestedClass.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MyNested modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any @@ -31,28 +31,28 @@ FILE fqName: fileName:/classWithGeneratedMembersAndNestedClass.kt CLASS GENERATED[AllOpenMembersGeneratorKey] CLASS name:Nested modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Foo.Nested CONSTRUCTOR GENERATED[AllOpenMembersGeneratorKey] visibility:public <> () returnType:.Foo.Nested [primary] + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any @@ -63,15 +63,15 @@ FILE fqName: fileName:/classWithGeneratedMembersAndNestedClass.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any diff --git a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.fir.ir.txt b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.fir.ir.txt index e6ac8079e59..cba2fbe8b46 100644 --- a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.fir.ir.txt +++ b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/generatedClassWithMembersAndNestedClasses.fir.ir.txt @@ -10,15 +10,15 @@ FILE fqName:bar fileName:/generatedClassWithMembersAndNestedClasses.kt FUN name:foo visibility:public modality:FINAL <> ($this:bar.Foo) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:bar.Foo BLOCK_BODY + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any @@ -34,15 +34,15 @@ FILE fqName:bar fileName:/generatedClassWithMembersAndNestedClasses.kt FUN name:bar visibility:public modality:FINAL <> ($this:bar.Bar) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:bar.Bar BLOCK_BODY + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any @@ -81,15 +81,15 @@ FILE fqName:foo fileName:__GENERATED DECLARATIONS__.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun materialize (): bar.Foo declared in foo.AllOpenGenerated.NestedFoo' CONSTRUCTOR_CALL 'public constructor () [primary] declared in bar.Foo' type=bar.Foo origin=null + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any @@ -105,28 +105,28 @@ FILE fqName:foo fileName:__GENERATED DECLARATIONS__.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun materialize (): bar.Bar declared in foo.AllOpenGenerated.NestedBar' CONSTRUCTOR_CALL 'public constructor () [primary] declared in bar.Bar' type=bar.Bar origin=null + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any diff --git a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.fir.ir.txt b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.fir.ir.txt index 578b94098a2..bd708b0bae0 100644 --- a/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.fir.ir.txt +++ b/plugins/fir/fir-plugin-prototype/testData/fir2ir/memberGen/topLevelCallables.fir.ir.txt @@ -15,15 +15,15 @@ FILE fqName:foo fileName:/topLevelCallables.kt value: GET_VAR ': foo.MySuperClass declared in foo.MySuperClass.test' type=foo.MySuperClass origin=null CALL 'public final fun takeString (s: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=null s: GET_VAR 'val s: kotlin.String [val] declared in foo.MySuperClass.test' type=kotlin.String origin=null + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in kotlin.Any