diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/ConeLookupTags.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/ConeLookupTags.kt new file mode 100644 index 00000000000..93290c475ff --- /dev/null +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/ConeLookupTags.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. 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.symbols + +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.Name + +interface ConeClassifierLookupTag + +interface ConeClassifierLookupTagWithFixedSymbol { + val symbol: ConeClassifierSymbol +} + +interface ConeTypeParameterLookupTag : ConeClassifierLookupTag { + val name: Name + +} +interface ConeClassLikeLookupTag : ConeClassifierLookupTag { + val classId: ClassId +} + +interface ConeTypeAliasLookupTag : ConeClassLikeLookupTag + +interface ConeClassLookupTag : ConeClassLikeLookupTag + +class ConeClassLikeLookupTagImpl(override val classId: ClassId) : ConeClassLikeLookupTag diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/ConeSymbols.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/ConeSymbols.kt index 55dca33fdd7..6c1fd9d3b97 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/ConeSymbols.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/ConeSymbols.kt @@ -6,16 +6,21 @@ package org.jetbrains.kotlin.fir.symbols import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.Name interface ConeSymbol -interface ConeTypeParameterSymbol : ConeSymbol { - val name: Name +interface ConeClassifierSymbol : ConeSymbol { + fun toLookupTag(): ConeClassifierLookupTag } -interface ConeClassLikeSymbol : ConeSymbol { +interface ConeTypeParameterSymbol : ConeClassifierSymbol, ConeTypeParameterLookupTag { + override fun toLookupTag(): ConeTypeParameterLookupTag = this +} + +interface ConeClassLikeSymbol : ConeClassifierSymbol { val classId: ClassId + + override fun toLookupTag(): ConeClassLikeLookupTag } interface ConeTypeAliasSymbol : ConeClassLikeSymbol diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt index 99ab4040d34..a78c0b0fa38 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt @@ -5,9 +5,7 @@ package org.jetbrains.kotlin.fir.types -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol -import org.jetbrains.kotlin.fir.symbols.ConeSymbol -import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol +import org.jetbrains.kotlin.fir.symbols.* sealed class ConeKotlinTypeProjection { abstract val kind: ProjectionKind @@ -79,7 +77,7 @@ class ConeKotlinErrorType(val reason: String) : ConeKotlinType() { } class ConeClassErrorType(val reason: String) : ConeClassLikeType() { - override val symbol: ConeClassLikeSymbol + override val lookupTag: ConeClassLikeLookupTag get() = error("!") override val typeArguments: Array @@ -93,28 +91,28 @@ class ConeClassErrorType(val reason: String) : ConeClassLikeType() { } } -sealed class ConeSymbolBasedType : ConeKotlinType() { - abstract val symbol: ConeSymbol +sealed class ConeLookupTagBasedType : ConeKotlinType() { + abstract val lookupTag: ConeClassifierLookupTag } -abstract class ConeClassLikeType : ConeSymbolBasedType() { - abstract override val symbol: ConeClassLikeSymbol +abstract class ConeClassLikeType : ConeLookupTagBasedType() { + abstract override val lookupTag: ConeClassLikeLookupTag } abstract class ConeAbbreviatedType : ConeClassLikeType() { - abstract val abbreviationSymbol: ConeClassLikeSymbol + abstract val abbreviationLookupTag: ConeClassLikeLookupTag abstract val directExpansion: ConeClassLikeType } -abstract class ConeTypeParameterType : ConeSymbolBasedType() { - abstract override val symbol: ConeTypeParameterSymbol +abstract class ConeTypeParameterType : ConeLookupTagBasedType() { + abstract override val lookupTag: ConeTypeParameterLookupTag } abstract class ConeFunctionType : ConeClassLikeType() { - abstract override val symbol: ConeClassLikeSymbol + abstract override val lookupTag: ConeClassLikeLookupTag abstract val receiverType: ConeKotlinType? abstract val parameterTypes: List abstract val returnType: ConeKotlinType diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/ConeFunctionTypeImpl.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/ConeFunctionTypeImpl.kt index 69382410b14..57b69dcff28 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/ConeFunctionTypeImpl.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/ConeFunctionTypeImpl.kt @@ -5,7 +5,7 @@ package org.jetbrains.kotlin.fir.types.impl -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.types.ConeFunctionType import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.ConeKotlinTypeProjection @@ -15,11 +15,11 @@ class ConeFunctionTypeImpl( override val receiverType: ConeKotlinType?, override val parameterTypes: List, override val returnType: ConeKotlinType, - override val symbol: ConeClassLikeSymbol, + override val lookupTag: ConeClassLikeLookupTag, isNullable: Boolean ) : ConeFunctionType() { override val typeArguments: Array get() = EMPTY_ARRAY override val nullability: ConeNullability = ConeNullability.create(isNullable) -} \ No newline at end of file +} diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt index 8cb063d341d..26b2f75f981 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt @@ -5,12 +5,12 @@ package org.jetbrains.kotlin.fir.types.impl -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol -import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag +import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag import org.jetbrains.kotlin.fir.types.* open class ConeClassTypeImpl( - override val symbol: ConeClassLikeSymbol, + override val lookupTag: ConeClassLikeLookupTag, override val typeArguments: Array, isNullable: Boolean ) : ConeClassLikeType() { @@ -18,23 +18,23 @@ open class ConeClassTypeImpl( } class ConeAbbreviatedTypeImpl( - override val abbreviationSymbol: ConeClassLikeSymbol, + override val abbreviationLookupTag: ConeClassLikeLookupTag, override val typeArguments: Array, override val directExpansion: ConeClassLikeType, isNullable: Boolean ) : ConeAbbreviatedType() { - override val symbol: ConeClassLikeSymbol - get() = abbreviationSymbol + override val lookupTag: ConeClassLikeLookupTag + get() = abbreviationLookupTag override val nullability: ConeNullability = ConeNullability.create(isNullable) } class ConeTypeParameterTypeImpl( - override val symbol: ConeTypeParameterSymbol, + override val lookupTag: ConeTypeParameterLookupTag, isNullable: Boolean ) : ConeTypeParameterType() { override val typeArguments: Array get() = EMPTY_ARRAY override val nullability: ConeNullability = ConeNullability.create(isNullable) -} \ No newline at end of file +} diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt index 8e84583464e..6f6cf3b1144 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt @@ -19,10 +19,7 @@ import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl import org.jetbrains.kotlin.fir.resolve.AbstractFirSymbolProvider import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.service -import org.jetbrains.kotlin.fir.symbols.CallableId -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassSymbol +import org.jetbrains.kotlin.fir.symbols.* import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol @@ -53,7 +50,7 @@ class JavaSymbolProvider( annotationTypeRef = FirResolvedTypeRefImpl( session = session, psi = null, - type = ConeClassTypeImpl(FirClassSymbol(classId!!), emptyArray(), isNullable = false), + type = ConeClassTypeImpl(FirClassSymbol(classId!!).toLookupTag(), emptyArray(), isNullable = false), isMarkedNullable = true, annotations = emptyList() ) @@ -146,9 +143,8 @@ class JavaSymbolProvider( private fun JavaClassifierType.toFirResolvedTypeRef(): FirResolvedTypeRef { val coneType = when (val classifier = classifier) { is JavaClass -> { - val symbol = session.service().getClassLikeSymbolByFqName(classifier.classId!!) as? ConeClassSymbol - if (symbol == null) ConeKotlinErrorType("Symbol not found, for `${classifier.classId}`") - else flexibleType { isNullable -> + val symbol = ConeClassLikeLookupTagImpl(classifier.classId!!) + flexibleType { isNullable -> ConeClassTypeImpl(symbol, typeArguments.map { it.toConeProjection() }.toTypedArray(), isNullable) } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirModuleBasedSession.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirModuleBasedSession.kt index 2de600ee7aa..e7edbae8b70 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirModuleBasedSession.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirModuleBasedSession.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.fir.resolve.FirProvider import org.jetbrains.kotlin.fir.resolve.FirQualifierResolver -import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.resolve.FirTypeResolver import org.jetbrains.kotlin.fir.resolve.impl.* @@ -17,6 +16,6 @@ abstract class FirModuleBasedSession(override val moduleInfo: ModuleInfo) : FirS val firProvider = FirProviderImpl(this) registerComponent(FirProvider::class, firProvider) registerComponent(FirQualifierResolver::class, FirQualifierResolverImpl(this)) - registerComponent(FirTypeResolver::class, FirTypeResolverImpl()) + registerComponent(FirTypeResolver::class, FirTypeResolverImpl(this)) } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirTypeDeserializer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirTypeDeserializer.kt index 2a95475e46c..56261a86772 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirTypeDeserializer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirTypeDeserializer.kt @@ -6,11 +6,8 @@ package org.jetbrains.kotlin.fir.deserialization import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider +import org.jetbrains.kotlin.fir.symbols.* import org.jetbrains.kotlin.fir.resolve.toTypeProjection -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol -import org.jetbrains.kotlin.fir.symbols.ConeSymbol -import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol -import org.jetbrains.kotlin.fir.symbols.LibraryTypeParameterSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol import org.jetbrains.kotlin.fir.types.* @@ -32,10 +29,10 @@ class FirTypeDeserializer( val parent: FirTypeDeserializer? ) { - private fun computeClassifier(fqNameIndex: Int): ConeSymbol? { + private fun computeClassifier(fqNameIndex: Int): ConeClassLikeLookupTag? { try { val id = nameResolver.getClassId(fqNameIndex) - return symbolProvider.getClassLikeSymbolByFqName(id) + return ConeClassLikeLookupTagImpl(id) } catch (e: Throwable) { throw RuntimeException("Looking up for ${nameResolver.getClassId(fqNameIndex)}", e) } @@ -54,21 +51,21 @@ class FirTypeDeserializer( } - private fun typeParameterSymbol(typeParameterId: Int): ConeTypeParameterSymbol? = + private fun typeParameterSymbol(typeParameterId: Int): ConeTypeParameterLookupTag? = typeParameterDescriptors[typeParameterId] ?: parent?.typeParameterSymbol(typeParameterId) private val typeParameterDescriptors = if (typeParameterProtos.isEmpty()) { - mapOf() + mapOf() } else { - val result = LinkedHashMap() + val result = LinkedHashMap() for ((index, proto) in typeParameterProtos.withIndex()) { result[proto.id] = LibraryTypeParameterSymbol(nameResolver.getName(proto.name)) } result } - val ownTypeParameters: List + val ownTypeParameters: List get() = typeParameterDescriptors.values.toList() @@ -82,7 +79,7 @@ class FirTypeDeserializer( fun classLikeType(proto: ProtoBuf.Type): ConeClassLikeType? { - val constructor = typeSymbol(proto) as? ConeClassLikeSymbol ?: return null + val constructor = typeSymbol(proto) as? ConeClassLikeLookupTag ?: return null // if (ErrorUtils.isError(constructor.declarationDescriptor)) { // return ErrorUtils.createErrorTypeWithCustomConstructor(constructor.toString(), constructor) // } @@ -90,9 +87,7 @@ class FirTypeDeserializer( fun ProtoBuf.Type.collectAllArguments(): List = argumentList + outerType(typeTable)?.collectAllArguments().orEmpty() - val arguments = proto.collectAllArguments().mapIndexed { index, proto -> - typeArgument(constructor.typeParameters().getOrNull(index), proto) - }.toTypedArray() + val arguments = proto.collectAllArguments().map(this::typeArgument).toTypedArray() val simpleType = if (Flags.SUSPEND_TYPE.get(proto.flags)) { //createSuspendFunctionType(annotations, constructor, arguments, proto.nullable) @@ -103,11 +98,11 @@ class FirTypeDeserializer( val abbreviatedTypeProto = proto.abbreviatedType(typeTable) ?: return simpleType - return ConeAbbreviatedTypeImpl(typeSymbol(abbreviatedTypeProto) as ConeClassLikeSymbol, arguments, simpleType, isNullable = false) + return ConeAbbreviatedTypeImpl(typeSymbol(abbreviatedTypeProto) as ConeClassLikeLookupTag, arguments, simpleType, isNullable = false) } - private fun typeSymbol(proto: ProtoBuf.Type): ConeSymbol? { + private fun typeSymbol(proto: ProtoBuf.Type): ConeClassifierLookupTag? { return when { proto.hasClassName() -> computeClassifier(proto.className) @@ -124,7 +119,7 @@ class FirTypeDeserializer( } - private fun typeArgument(parameter: ConeTypeParameterSymbol?, typeArgumentProto: ProtoBuf.Type.Argument): ConeKotlinTypeProjection { + private fun typeArgument(typeArgumentProto: ProtoBuf.Type.Argument): ConeKotlinTypeProjection { if (typeArgumentProto.projection == ProtoBuf.Type.Argument.Projection.STAR) { return StarProjection } @@ -136,4 +131,4 @@ class FirTypeDeserializer( return coneType.toTypeProjection(variance) } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirProvider.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirProvider.kt index 7ece672164a..d21e528ead5 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirProvider.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirProvider.kt @@ -8,12 +8,10 @@ package org.jetbrains.kotlin.fir.resolve import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration -import org.jetbrains.kotlin.fir.declarations.FirNamedDeclaration import org.jetbrains.kotlin.fir.service import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol -import org.jetbrains.kotlin.fir.symbols.ConeSymbol import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName @@ -31,11 +29,9 @@ interface FirProvider : FirSymbolProvider { fun getFirClassifierContainerFile(fqName: ClassId): FirFile - fun getFirClassifierBySymbol(symbol: ConeSymbol): FirNamedDeclaration? - companion object { fun getInstance(session: FirSession): FirProvider = session.service() } fun getFirFilesByPackage(fqName: FqName): List -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirQualifierResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirQualifierResolver.kt index c60b05e2adf..5459bb10214 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirQualifierResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirQualifierResolver.kt @@ -7,16 +7,14 @@ package org.jetbrains.kotlin.fir.resolve import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.service -import org.jetbrains.kotlin.fir.symbols.ConeSymbol -import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.fir.types.FirQualifierPart import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName interface FirQualifierResolver { - fun resolveSymbolWithPrefix(parts: List, prefix: ClassId): ConeSymbol? + fun resolveSymbolWithPrefix(parts: List, prefix: ClassId): ConeClassifierSymbol? - fun resolveSymbol(parts: List): ConeSymbol? + fun resolveSymbol(parts: List): ConeClassifierSymbol? companion object { fun getInstance(session: FirSession): FirQualifierResolver = session.service() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirSymbolProvider.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirSymbolProvider.kt index 0d5e473b6d3..78773772890 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirSymbolProvider.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirSymbolProvider.kt @@ -7,9 +7,7 @@ package org.jetbrains.kotlin.fir.resolve import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.service -import org.jetbrains.kotlin.fir.symbols.CallableId -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.* import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName @@ -17,6 +15,14 @@ interface FirSymbolProvider { fun getClassLikeSymbolByFqName(classId: ClassId): ConeClassLikeSymbol? + fun getSymbolByLookupTag(lookupTag: ConeClassifierLookupTag): ConeClassifierSymbol? { + return when (lookupTag) { + is ConeClassLikeLookupTag -> getClassLikeSymbolByFqName(lookupTag.classId) + is ConeClassifierLookupTagWithFixedSymbol -> lookupTag.symbol + else -> error("Unknown lookupTag type: ${lookupTag::class}") + } + } + fun getCallableSymbols(callableId: CallableId): List fun getPackage(fqName: FqName): FqName? // TODO: Replace to symbol sometime @@ -24,4 +30,4 @@ interface FirSymbolProvider { companion object { fun getInstance(session: FirSession) = session.service() } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirTypeResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirTypeResolver.kt index ad86c0486c1..845f2d6c2c3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirTypeResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirTypeResolver.kt @@ -9,19 +9,19 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.scopes.FirPosition import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.service -import org.jetbrains.kotlin.fir.symbols.ConeSymbol -import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirUserTypeRef interface FirTypeResolver { fun resolveType(typeRef: FirTypeRef, scope: FirScope, position: FirPosition): ConeKotlinType - fun resolveToSymbol(typeRef: FirTypeRef, scope: FirScope, position: FirPosition): ConeSymbol? + fun resolveToSymbol(typeRef: FirTypeRef, scope: FirScope, position: FirPosition): ConeClassifierSymbol? companion object { fun getInstance(session: FirSession): FirTypeResolver = session.service() } - fun resolveUserType(typeRef: FirUserTypeRef, symbol: ConeSymbol?, scope: FirScope): ConeKotlinType -} \ No newline at end of file + fun resolveUserType(typeRef: FirUserTypeRef, symbol: ConeClassifierSymbol?, scope: FirScope): ConeKotlinType +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt index 9fe71bc9a57..1d845038fe4 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt @@ -5,10 +5,11 @@ package org.jetbrains.kotlin.fir.resolve +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.fir.declarations.expandedConeType -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.ConeClassSymbol -import org.jetbrains.kotlin.fir.symbols.ConeSymbol import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol import org.jetbrains.kotlin.fir.types.* @@ -29,17 +30,20 @@ inline fun MutableMap.getOrPut(key: K, defaultValue: (K) -> } } -fun ConeSymbol.constructType(typeArguments: Array, isNullable: Boolean): ConeKotlinType { +fun ConeClassLikeLookupTag.toSymbol(useSiteSession: FirSession): ConeClassifierSymbol? = + useSiteSession.getService(FirSymbolProvider::class).getSymbolByLookupTag(this) + +fun ConeClassifierSymbol.constructType(typeArguments: Array, isNullable: Boolean): ConeKotlinType { return when (this) { is ConeTypeParameterSymbol -> { ConeTypeParameterTypeImpl(this, isNullable) } is ConeClassSymbol -> { - ConeClassTypeImpl(this, typeArguments, isNullable) + ConeClassTypeImpl(this.toLookupTag(), typeArguments, isNullable) } is FirTypeAliasSymbol -> { ConeAbbreviatedTypeImpl( - abbreviationSymbol = this as ConeClassLikeSymbol, + abbreviationLookupTag = this.toLookupTag(), typeArguments = typeArguments, directExpansion = fir.expandedConeType ?: ConeClassErrorType("Unresolved expansion"), isNullable = isNullable @@ -49,7 +53,7 @@ fun ConeSymbol.constructType(typeArguments: Array, isN } } -fun ConeSymbol.constructType(parts: List, isNullable: Boolean): ConeKotlinType = +fun ConeClassifierSymbol.constructType(parts: List, isNullable: Boolean): ConeKotlinType = constructType(parts.toTypeProjections(), isNullable) fun ConeKotlinType.toTypeProjection(variance: Variance): ConeKotlinTypeProjection = diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirProviderImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirProviderImpl.kt index 4035c91cb7f..7fd53f46f95 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirProviderImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirProviderImpl.kt @@ -15,15 +15,6 @@ import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName class FirProviderImpl(val session: FirSession) : FirProvider { - - override fun getFirClassifierBySymbol(symbol: ConeSymbol): FirNamedDeclaration? { - return when (symbol) { - is FirBasedSymbol<*> -> symbol.fir as? FirNamedDeclaration - is ConeClassLikeSymbol -> getFirClassifierByFqName(symbol.classId) - else -> error("!") - } - } - override fun getClassLikeSymbolByFqName(classId: ClassId): ConeClassLikeSymbol? { return (getFirClassifierByFqName(classId) as? FirSymbolOwner<*>)?.symbol as? ConeClassLikeSymbol } @@ -84,7 +75,7 @@ class FirProviderImpl(val session: FirSession) : FirProvider { } private val fileMap = mutableMapOf>() - private val classifierMap = mutableMapOf() + private val classifierMap = mutableMapOf() private val classifierContainerFileMap = mutableMapOf() private val callableMap = mutableMapOf>() @@ -92,8 +83,8 @@ class FirProviderImpl(val session: FirSession) : FirProvider { return fileMap[fqName].orEmpty() } - override fun getFirClassifierByFqName(fqName: ClassId): FirMemberDeclaration? { + override fun getFirClassifierByFqName(fqName: ClassId): FirClassLikeDeclaration? { return classifierMap[fqName] } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirQualifierResolverImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirQualifierResolverImpl.kt index 264ae6cfca9..cc0d2badd8a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirQualifierResolverImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirQualifierResolverImpl.kt @@ -8,14 +8,14 @@ package org.jetbrains.kotlin.fir.resolve.impl import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.resolve.FirQualifierResolver import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider -import org.jetbrains.kotlin.fir.symbols.ConeSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.fir.types.FirQualifierPart import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName class FirQualifierResolverImpl(val session: FirSession) : FirQualifierResolver { - override fun resolveSymbolWithPrefix(parts: List, prefix: ClassId): ConeSymbol? { + override fun resolveSymbolWithPrefix(parts: List, prefix: ClassId): ConeClassifierSymbol? { val symbolProvider = FirSymbolProvider.getInstance(session) val fqName = ClassId( @@ -23,10 +23,10 @@ class FirQualifierResolverImpl(val session: FirSession) : FirQualifierResolver { parts.drop(1).fold(prefix.relativeClassName) { prefix, suffix -> prefix.child(suffix.name) }, false ) - return symbolProvider.getClassLikeSymbolByFqName(fqName) ?: return null + return symbolProvider.getClassLikeSymbolByFqName(fqName) } - override fun resolveSymbol(parts: List): ConeSymbol? { + override fun resolveSymbol(parts: List): ConeClassifierSymbol? { val firProvider = FirSymbolProvider.getInstance(session) if (parts.isNotEmpty()) { @@ -49,4 +49,4 @@ class FirQualifierResolverImpl(val session: FirSession) : FirQualifierResolver { private fun List.toFqNameUnsafe() = toFqName().toUnsafe() private fun List.toFqName() = fold(FqName.ROOT) { a, b -> a.child(b.name) } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirTypeResolverImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirTypeResolverImpl.kt index 71905fa92c7..73f61be5db2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirTypeResolverImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirTypeResolverImpl.kt @@ -14,24 +14,28 @@ import org.jetbrains.kotlin.fir.resolve.FirTypeResolver import org.jetbrains.kotlin.fir.resolve.constructType import org.jetbrains.kotlin.fir.scopes.FirPosition import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.service -import org.jetbrains.kotlin.fir.symbols.* +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol +import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.* import org.jetbrains.kotlin.name.ClassId -class FirTypeResolverImpl : FirTypeResolver { +class FirTypeResolverImpl(session: FirSession) : FirTypeResolver { + private val symbolProvider by lazy { + session.getService(FirSymbolProvider::class) + } private data class ClassIdInSession(val session: FirSession, val id: ClassId) private val implicitBuiltinTypeSymbols = mutableMapOf() - + // TODO: get rid of session used here, and may be also of the cache above (see KT-30275) private fun resolveBuiltInQualified(id: ClassId, session: FirSession): ConeClassLikeSymbol { val nameInSession = ClassIdInSession(session, id) return implicitBuiltinTypeSymbols.getOrPut(nameInSession) { - session.service().getClassLikeSymbolByFqName(id)!! + symbolProvider.getClassLikeSymbolByFqName(id) as ConeClassLikeSymbol } } @@ -39,14 +43,14 @@ class FirTypeResolverImpl : FirTypeResolver { typeRef: FirTypeRef, scope: FirScope, position: FirPosition - ): ConeSymbol? { + ): ConeClassifierSymbol? { return when (typeRef) { - is FirResolvedTypeRef -> typeRef.coneTypeSafe()?.symbol + is FirResolvedTypeRef -> typeRef.coneTypeSafe()?.lookupTag?.let(symbolProvider::getSymbolByLookupTag) is FirUserTypeRef -> { val qualifierResolver = FirQualifierResolver.getInstance(typeRef.session) - var resolvedSymbol: ConeSymbol? = null + var resolvedSymbol: ConeClassifierSymbol? = null scope.processClassifiersByName(typeRef.qualifier.first().name, position) { symbol -> resolvedSymbol = when (symbol) { is ConeClassLikeSymbol -> { @@ -73,11 +77,9 @@ class FirTypeResolverImpl : FirTypeResolver { } else -> null } - - } - override fun resolveUserType(typeRef: FirUserTypeRef, symbol: ConeSymbol?, scope: FirScope): ConeKotlinType { + override fun resolveUserType(typeRef: FirUserTypeRef, symbol: ConeClassifierSymbol?, scope: FirScope): ConeKotlinType { symbol ?: return ConeKotlinErrorType("Symbol not found, for `${typeRef.render()}`") return symbol.constructType(typeRef.qualifier, typeRef.isMarkedNullable) } @@ -100,7 +102,7 @@ class FirTypeResolverImpl : FirTypeResolver { (typeRef.receiverTypeRef as FirResolvedTypeRef?)?.type, typeRef.valueParameters.map { it.returnTypeRef.coneTypeUnsafe() }, typeRef.returnTypeRef.coneTypeUnsafe(), - resolveBuiltInQualified(KotlinBuiltIns.getFunctionClassId(typeRef.parametersCount), typeRef.session), + resolveBuiltInQualified(KotlinBuiltIns.getFunctionClassId(typeRef.parametersCount), typeRef.session).toLookupTag(), typeRef.isMarkedNullable ) } @@ -113,4 +115,4 @@ class FirTypeResolverImpl : FirTypeResolver { else -> error("!") } } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirAbstractTreeTransformerWithSuperTypes.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirAbstractTreeTransformerWithSuperTypes.kt index 35de203b82e..362fe45a27c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirAbstractTreeTransformerWithSuperTypes.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirAbstractTreeTransformerWithSuperTypes.kt @@ -6,11 +6,13 @@ package org.jetbrains.kotlin.fir.resolve.transformers import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.expandedConeType import org.jetbrains.kotlin.fir.declarations.superConeTypes +import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.scopes.impl.FirCompositeScope -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol import org.jetbrains.kotlin.fir.types.ConeAbbreviatedType @@ -34,11 +36,12 @@ abstract class FirAbstractTreeTransformerWithSuperTypes(reversedScopePriority: B protected fun lookupSuperTypes( klass: FirRegularClass, lookupInterfaces: Boolean, - deep: Boolean + deep: Boolean, + useSiteSession: FirSession ): List { return mutableListOf().also { - if (lookupInterfaces) klass.symbol.collectSuperTypes(it, deep) - else klass.symbol.collectSuperClasses(it) + if (lookupInterfaces) klass.symbol.collectSuperTypes(it, deep, useSiteSession) + else klass.symbol.collectSuperClasses(it, useSiteSession) } } @@ -49,27 +52,35 @@ abstract class FirAbstractTreeTransformerWithSuperTypes(reversedScopePriority: B } } - private tailrec fun ConeClassLikeSymbol.collectSuperClasses(list: MutableList) { + private tailrec fun ConeClassifierSymbol.collectSuperClasses( + list: MutableList, + useSiteSession: FirSession + ) { when (this) { is FirClassSymbol -> { val superClassType = fir.superConeTypes .map { it.computePartialExpansion() } .firstOrNull { - it !is ConeClassErrorType && (it?.symbol as? FirClassSymbol)?.fir?.classKind == ClassKind.CLASS + it !is ConeClassErrorType && + (it?.lookupTag?.toSymbol(useSiteSession) as? FirClassSymbol)?.fir?.classKind == ClassKind.CLASS } ?: return list += superClassType - superClassType.symbol.collectSuperClasses(list) + superClassType.lookupTag.toSymbol(useSiteSession)?.collectSuperClasses(list, useSiteSession) } is FirTypeAliasSymbol -> { val expansion = fir.expandedConeType?.computePartialExpansion() ?: return - expansion.symbol.collectSuperClasses(list) + expansion.lookupTag.toSymbol(useSiteSession)?.collectSuperClasses(list, useSiteSession) } else -> error("?!id:1") } } - private fun ConeClassLikeSymbol.collectSuperTypes(list: MutableList, deep: Boolean) { + private fun ConeClassifierSymbol.collectSuperTypes( + list: MutableList, + deep: Boolean, + useSiteSession: FirSession + ) { when (this) { is FirClassSymbol -> { val superClassTypes = @@ -78,15 +89,15 @@ abstract class FirAbstractTreeTransformerWithSuperTypes(reversedScopePriority: B if (deep) superClassTypes.forEach { if (it !is ConeClassErrorType) { - it.symbol.collectSuperTypes(list, deep) + it.lookupTag.toSymbol(useSiteSession)?.collectSuperTypes(list, deep, useSiteSession) } } } is FirTypeAliasSymbol -> { val expansion = fir.expandedConeType?.computePartialExpansion() ?: return - expansion.symbol.collectSuperTypes(list, deep) + expansion.lookupTag.toSymbol(useSiteSession)?.collectSuperTypes(list, deep, useSiteSession) } else -> error("?!id:1") } } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirAccessResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirAccessResolveTransformer.kt index 293c5966873..cfa7f99ce10 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirAccessResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirAccessResolveTransformer.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.references.FirErrorNamedReference import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl +import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NEXT @@ -55,10 +56,10 @@ class FirAccessResolveTransformer : FirAbstractTreeTransformerWithSuperTypes(rev private fun FirRegularClass.buildUseSiteScope(useSiteSession: FirSession = session): FirClassUseSiteScope { val superTypeScope = FirCompositeScope(mutableListOf()) val declaredScope = FirClassDeclaredMemberScope(this, useSiteSession) - lookupSuperTypes(this, lookupInterfaces = true, deep = false) + lookupSuperTypes(this, lookupInterfaces = true, deep = false, useSiteSession = useSiteSession) .mapNotNullTo(superTypeScope.scopes) { useSiteSuperType -> if (useSiteSuperType is ConeClassErrorType) return@mapNotNullTo null - val symbol = useSiteSuperType.symbol + val symbol = useSiteSuperType.lookupTag.toSymbol(useSiteSession) if (symbol is FirClassSymbol) { val scope = symbol.fir.buildUseSiteScope(useSiteSession) useSiteSuperType.buildSubstitutionScope(useSiteSession, scope, symbol.fir) ?: scope @@ -160,4 +161,4 @@ class FirAccessResolveTransformer : FirAbstractTreeTransformerWithSuperTypes(rev } } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt index 69185f2f363..d695b9ea87b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt @@ -14,9 +14,11 @@ import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.resolve.FirTypeResolver import org.jetbrains.kotlin.fir.scopes.FirPosition import org.jetbrains.kotlin.fir.scopes.impl.* -import org.jetbrains.kotlin.fir.symbols.* -import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol +import org.jetbrains.kotlin.fir.service +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol +import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.transformSingle import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl @@ -29,8 +31,11 @@ import org.jetbrains.kotlin.fir.visitors.compose open class FirTypeResolveTransformer( private val traversedClassifiers: Set = setOf() ) : FirAbstractTreeTransformerWithSuperTypes(reversedScopePriority = true) { + private lateinit var firProvider: FirProvider + override fun transformFile(file: FirFile, data: Nothing?): CompositeTransformResult { val session = file.session + firProvider = session.getService(FirProvider::class) return withScopeCleanup { towerScope.scopes += listOf( // from low priority to high priority @@ -63,11 +68,13 @@ open class FirTypeResolveTransformer( } } return withScopeCleanup { - val firProvider = FirProvider.getInstance(regularClass.session) + val session = regularClass.session + val firProvider = FirProvider.getInstance(session) val classId = regularClass.symbol.classId - lookupSuperTypes(regularClass, lookupInterfaces = false, deep = true).asReversed().mapTo(towerScope.scopes) { - FirNestedClassifierScope(it.symbol.classId, FirSymbolProvider.getInstance(regularClass.session)) - } + lookupSuperTypes(regularClass, lookupInterfaces = false, deep = true, useSiteSession = session) + .asReversed().mapTo(towerScope.scopes) { + FirNestedClassifierScope(it.lookupTag.classId, FirSymbolProvider.getInstance(session)) + } val companionObjects = regularClass.declarations.filterIsInstance().filter { it.isCompanion } for (companionObject in companionObjects) { towerScope.scopes += FirNestedClassifierScope(companionObject.symbol.classId, firProvider) @@ -173,40 +180,29 @@ open class FirTypeResolveTransformer( } - private fun walkSymbols(symbol: ConeSymbol) { - if (symbol is ConeClassLikeSymbol) { - if (symbol is FirBasedSymbol<*>) { - val classId = symbol.classId + private fun walkSymbols(symbol: ConeClassifierSymbol) { + if (symbol !is ConeClassLikeSymbol || symbol !is FirBasedSymbol<*>) return + val classId = symbol.classId + val classes = generateSequence(classId) { it.outerClassId }.toList().asReversed() - if (symbol is ConeTypeAliasSymbol) { - val fir = symbol.fir as FirTypeAlias - if (fir.expandedTypeRef is FirResolvedTypeRef) return - } else if (symbol is ConeClassSymbol) { - val fir = symbol.fir as FirClass - if (fir.superTypeRefs.all { it is FirResolvedTypeRef }) return - } - val firProvider = FirProvider.getInstance(symbol.fir.session) - val classes = generateSequence(classId) { it.outerClassId }.toList().asReversed() - - val file = firProvider.getFirClassifierContainerFile(classes.first()) - - val firElementsToVisit = classes.asSequence().map { - firProvider.getFirClassifierByFqName(it)!! - } - - val transformer = SuperTypeResolveTransformer( - firElementsToVisit.iterator(), traversedClassifiers - ) - file.transformSingle(transformer, null) - - } else { - if (symbol is FirTypeAliasSymbol) { - symbol.fir.expandedConeType?.let { if (it !is ConeClassErrorType) walkSymbols(it.symbol) } - } else if (symbol is FirClassSymbol) { - symbol.fir.superConeTypes.forEach { if (it !is ConeClassErrorType) walkSymbols(it.symbol) } - } - } + val fir = symbol.fir + if (fir is FirTypeAlias) { + if (fir.expandedTypeRef is FirResolvedTypeRef) return + } else if (fir is FirClass) { + if (fir.superTypeRefs.all { it is FirResolvedTypeRef }) return } + + val firProvider = fir.session.service() + val file = firProvider.getFirClassifierContainerFile(classes.first()) + + val firElementsToVisit = classes.asSequence().map { + firProvider.getFirClassifierByFqName(it)!! + } + + val transformer = SuperTypeResolveTransformer( + firElementsToVisit.iterator(), traversedClassifiers + ) + file.transformSingle(transformer, null) } override fun transformTypeRef(typeRef: FirTypeRef, data: Nothing?): CompositeTransformResult { @@ -229,4 +225,4 @@ open class FirTypeResolveTransformer( return myTransformer.transformType(typeRef, typeResolver.resolveUserType(typeRef, symbol, towerScope)) } } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt index 14889b76abf..c57c5b073b3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt @@ -6,16 +6,16 @@ package org.jetbrains.kotlin.fir.scopes import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NEXT +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.fir.symbols.ConeFunctionSymbol import org.jetbrains.kotlin.fir.symbols.ConePropertySymbol -import org.jetbrains.kotlin.fir.symbols.ConeSymbol import org.jetbrains.kotlin.name.Name interface FirScope { fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeSymbol) -> Boolean + processor: (ConeClassifierSymbol) -> Boolean ): Boolean = true fun processFunctionsByName( @@ -46,4 +46,4 @@ enum class ProcessorAction { } fun next() = this == NEXT -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/FirTypeParameterScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/FirTypeParameterScope.kt index 61bc9068bd9..3471054a85b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/FirTypeParameterScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/FirTypeParameterScope.kt @@ -6,7 +6,7 @@ package org.jetbrains.kotlin.fir.scopes import org.jetbrains.kotlin.fir.declarations.FirTypeParameter -import org.jetbrains.kotlin.fir.symbols.ConeSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.name.Name interface FirTypeParameterScope : FirScope { @@ -15,10 +15,10 @@ interface FirTypeParameterScope : FirScope { override fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeSymbol) -> Boolean + processor: (ConeClassifierSymbol) -> Boolean ): Boolean { val matchedTypeParameters = typeParameters[name] ?: return true return matchedTypeParameters.all { processor(it.symbol) } } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractSimpleImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractSimpleImportingScope.kt index 1577a267ac3..dbd3bd6ec54 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractSimpleImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractSimpleImportingScope.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedImportImpl import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.scopes.FirPosition import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.symbols.ConeSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.name.Name abstract class FirAbstractSimpleImportingScope(val session: FirSession) : FirScope { @@ -20,7 +20,7 @@ abstract class FirAbstractSimpleImportingScope(val session: FirSession) : FirSco override fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeSymbol) -> Boolean + processor: (ConeClassifierSymbol) -> Boolean ): Boolean { val imports = simpleImports[name] ?: return true if (imports.isEmpty()) return true @@ -34,4 +34,4 @@ abstract class FirAbstractSimpleImportingScope(val session: FirSession) : FirSco return true } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractStarImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractStarImportingScope.kt index dc5fa52f05f..b64cc270904 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractStarImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractStarImportingScope.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirResolvedImport import org.jetbrains.kotlin.fir.scopes.FirPosition -import org.jetbrains.kotlin.fir.symbols.ConeSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name @@ -21,7 +21,7 @@ abstract class FirAbstractStarImportingScope( override fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeSymbol) -> Boolean + processor: (ConeClassifierSymbol) -> Boolean ): Boolean { for (import in starImports) { val relativeClassName = import.relativeClassName @@ -38,4 +38,4 @@ abstract class FirAbstractStarImportingScope( return true } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt index f385c19963b..7f8ea48d85b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt @@ -63,9 +63,13 @@ class FirClassSubstitutionScope( return when (this) { is ConeKotlinErrorType -> error("Trying to substitute arguments for error type") is ConeTypeParameterType -> error("Trying to substitute arguments for type parameter") - is ConeClassTypeImpl -> ConeClassTypeImpl(symbol, newArguments as Array, nullability.isNullable) + is ConeClassTypeImpl -> ConeClassTypeImpl( + lookupTag, + newArguments as Array, + nullability.isNullable + ) is ConeAbbreviatedTypeImpl -> ConeAbbreviatedTypeImpl( - abbreviationSymbol, + abbreviationLookupTag, newArguments as Array, directExpansion.substitute() as? ConeClassLikeType ?: directExpansion, nullability.isNullable @@ -148,4 +152,4 @@ fun FirTypeRef.withReplacedConeType(newType: ConeKotlinType?): FirResolvedTypeRe annotations ) -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirCompositeScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirCompositeScope.kt index b92020c800b..d308f999ad7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirCompositeScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirCompositeScope.kt @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NEXT import org.jetbrains.kotlin.fir.scopes.ProcessorAction.STOP import org.jetbrains.kotlin.fir.symbols.ConeFunctionSymbol import org.jetbrains.kotlin.fir.symbols.ConePropertySymbol -import org.jetbrains.kotlin.fir.symbols.ConeSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.name.Name class FirCompositeScope( @@ -23,7 +23,7 @@ class FirCompositeScope( override fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeSymbol) -> Boolean + processor: (ConeClassifierSymbol) -> Boolean ): Boolean { val scopes = if (reversedPriority) scopes.asReversed() else scopes for (scope in scopes) { @@ -57,4 +57,4 @@ class FirCompositeScope( return processComposite(FirScope::processPropertiesByName, name, processor) } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirNestedClassifierScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirNestedClassifierScope.kt index db875042584..d9497f96c1a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirNestedClassifierScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirNestedClassifierScope.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.scopes.FirPosition import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.symbols.ConeSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name @@ -20,7 +20,7 @@ class FirNestedClassifierScope( override fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeSymbol) -> Boolean + processor: (ConeClassifierSymbol) -> Boolean ): Boolean { val child = classId.createNestedClassId(name) val symbol = symbolProvider.getClassLikeSymbolByFqName(child) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirSelfImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirSelfImportingScope.kt index 1b5cc55b7d5..f23420214a8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirSelfImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirSelfImportingScope.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.scopes.FirPosition import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.symbols.ConeSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -19,13 +19,13 @@ class FirSelfImportingScope(val fqName: FqName, val session: FirSession) : FirSc private val symbolProvider = FirSymbolProvider.getInstance(session) - private val cache = ContainerUtil.newConcurrentMap() + private val cache = ContainerUtil.newConcurrentMap() private val absentKeys = ContainerUtil.newConcurrentSet() override fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeSymbol) -> Boolean + processor: (ConeClassifierSymbol) -> Boolean ): Boolean { @@ -47,4 +47,4 @@ class FirSelfImportingScope(val fqName: FqName, val session: FirSession) : FirSc true } } -} \ No newline at end of file +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index ae7d6db906e..f529b37c089 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license * that can be found in the license/LICENSE.txt file. */ @@ -10,9 +10,12 @@ import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.* +import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition +import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub +import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression +import org.jetbrains.kotlin.fir.expressions.impl.FirWhenSubjectExpression import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol -import org.jetbrains.kotlin.fir.symbols.ConeSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol @@ -608,7 +611,7 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { visitTypeRefWithNullability(functionTypeRef) } - private fun ConeSymbol.asString(): String { + private fun ConeClassifierSymbol.asString(): String { return when (this) { is ConeClassLikeSymbol -> classId.asString() is FirTypeParameterSymbol -> fir.name.asString() @@ -622,7 +625,7 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { is ConeClassErrorType -> "class error: $reason" is ConeClassLikeType -> { val sb = StringBuilder() - sb.append(symbol.classId.asString()) + sb.append(lookupTag.classId.asString()) if (typeArguments.isNotEmpty()) { sb.append(typeArguments.joinToString(prefix = "<", postfix = ">") { when (it) { @@ -639,7 +642,7 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { sb.toString() } is ConeTypeParameterType -> { - symbol.asString() + lookupTag.name.asString() } is ConeFunctionType -> { buildString { @@ -864,4 +867,4 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { override fun visitErrorExpression(errorExpression: FirErrorExpression) { print("ERROR_EXPR(${errorExpression.reason})") } -} \ No newline at end of file +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirClassLikeDeclaration.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirClassLikeDeclaration.kt new file mode 100644 index 00000000000..b25a1a19a84 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirClassLikeDeclaration.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. 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.declarations + +import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol + +interface FirClassLikeDeclaration : FirMemberDeclaration { + val symbol: ConeClassifierSymbol +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirRegularClass.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirRegularClass.kt index 3dd6682163b..f5049864cb4 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirRegularClass.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirRegularClass.kt @@ -14,7 +14,7 @@ import org.jetbrains.kotlin.fir.visitors.FirVisitor // May be all containers should be properties and not base classes // About descriptors: introduce something like FirDescriptor which is FirUnresolved at the beginning and FirSymbol(descriptor) at the end @BaseTransformedType -interface FirRegularClass : FirClass, @VisitedSupertype FirMemberDeclaration, FirSymbolOwner { +interface FirRegularClass : FirClass, @VisitedSupertype FirClassLikeDeclaration, FirSymbolOwner { val isInner: Boolean get() = status.isInner val isCompanion: Boolean get() = status.isCompanion @@ -29,7 +29,7 @@ interface FirRegularClass : FirClass, @VisitedSupertype FirMemberDeclaration, Fi visitor.visitRegularClass(this, data) override fun acceptChildren(visitor: FirVisitor, data: D) { - super.acceptChildren(visitor, data) + super.acceptChildren(visitor, data) super.acceptChildren(visitor, data) } -} \ No newline at end of file +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirTypeAlias.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirTypeAlias.kt index e8807cfc9db..f6b0e2713cc 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirTypeAlias.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirTypeAlias.kt @@ -6,14 +6,17 @@ package org.jetbrains.kotlin.fir.declarations import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol import org.jetbrains.kotlin.fir.types.ConeClassLikeType import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.coneTypeSafe import org.jetbrains.kotlin.fir.visitors.FirVisitor -interface FirTypeAlias : FirMemberDeclaration, FirSymbolOwner { +interface FirTypeAlias : FirClassLikeDeclaration, FirSymbolOwner { val expandedTypeRef: FirTypeRef + override val symbol: FirTypeAliasSymbol + override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTypeAlias(this, data) @@ -24,4 +27,4 @@ interface FirTypeAlias : FirMemberDeclaration, FirSymbolOwner { } -val FirTypeAlias.expandedConeType: ConeClassLikeType? get() = expandedTypeRef.coneTypeSafe() \ No newline at end of file +val FirTypeAlias.expandedConeType: ConeClassLikeType? get() = expandedTypeRef.coneTypeSafe() diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassSymbol.kt index 01596b48e5c..153304864de 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassSymbol.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassSymbol.kt @@ -7,7 +7,11 @@ package org.jetbrains.kotlin.fir.symbols.impl import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.ConeClassSymbol import org.jetbrains.kotlin.name.ClassId -class FirClassSymbol(override val classId: ClassId) : ConeClassSymbol, AbstractFirBasedSymbol() \ No newline at end of file +class FirClassSymbol(override val classId: ClassId) : ConeClassSymbol, AbstractFirBasedSymbol() { + override fun toLookupTag(): ConeClassLikeLookupTag = ConeClassLikeLookupTagImpl(classId) +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirTypeAliasSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirTypeAliasSymbol.kt index e805b0d4014..b7fb4c8d0fb 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirTypeAliasSymbol.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirTypeAliasSymbol.kt @@ -7,7 +7,17 @@ package org.jetbrains.kotlin.fir.symbols.impl import org.jetbrains.kotlin.fir.declarations.FirTypeAlias import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag +import org.jetbrains.kotlin.fir.symbols.ConeTypeAliasLookupTag import org.jetbrains.kotlin.fir.symbols.ConeTypeAliasSymbol import org.jetbrains.kotlin.name.ClassId -class FirTypeAliasSymbol(override val classId: ClassId) : ConeTypeAliasSymbol, AbstractFirBasedSymbol() \ No newline at end of file +class FirTypeAliasSymbol( + override val classId: ClassId +) : ConeTypeAliasSymbol, AbstractFirBasedSymbol() { + override fun toLookupTag(): ConeClassLikeLookupTag = TypeAliasLookupTagImpl(classId) +} + +class TypeAliasLookupTagImpl( + override val classId: ClassId +) : ConeTypeAliasLookupTag diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirTypeParameterSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirTypeParameterSymbol.kt index 87db2602340..2ffbb38cf4f 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirTypeParameterSymbol.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirTypeParameterSymbol.kt @@ -6,11 +6,17 @@ package org.jetbrains.kotlin.fir.symbols.impl import org.jetbrains.kotlin.fir.declarations.FirTypeParameter -import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol -import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol +import org.jetbrains.kotlin.fir.symbols.* import org.jetbrains.kotlin.name.Name -class FirTypeParameterSymbol : AbstractFirBasedSymbol(), ConeTypeParameterSymbol { +class FirTypeParameterSymbol : AbstractFirBasedSymbol(), ConeTypeParameterSymbol, ConeTypeParameterLookupTag, + ConeClassifierLookupTagWithFixedSymbol { + override val name: Name get() = fir.name -} \ No newline at end of file + + override val symbol: ConeClassifierSymbol + get() = this + + override fun toLookupTag(): ConeTypeParameterLookupTag = this +} diff --git a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirTransformerGenerated.kt b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirTransformerGenerated.kt index f72d212c5d9..39fcfa44b89 100644 --- a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirTransformerGenerated.kt +++ b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirTransformerGenerated.kt @@ -72,8 +72,12 @@ abstract class FirTransformer : FirVisitor { + return transformMemberDeclaration(classLikeDeclaration, data) + } + open fun transformRegularClass(regularClass: FirRegularClass, data: D): CompositeTransformResult { - return transformMemberDeclaration(regularClass, data) + return transformClassLikeDeclaration(regularClass, data) } open fun transformEnumEntry(enumEntry: FirEnumEntry, data: D): CompositeTransformResult { @@ -81,7 +85,7 @@ abstract class FirTransformer : FirVisitor { - return transformMemberDeclaration(typeAlias, data) + return transformClassLikeDeclaration(typeAlias, data) } open fun transformTypeParameter(typeParameter: FirTypeParameter, data: D): CompositeTransformResult { @@ -420,6 +424,10 @@ abstract class FirTransformer : FirVisitor { + return transformClassLikeDeclaration(classLikeDeclaration, data) + } + final override fun visitClassReferenceExpression(classReferenceExpression: FirClassReferenceExpression, data: D): CompositeTransformResult { return transformClassReferenceExpression(classReferenceExpression, data) } diff --git a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorGenerated.kt b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorGenerated.kt index 2199e64f554..b20d4d0f821 100644 --- a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorGenerated.kt +++ b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorGenerated.kt @@ -72,8 +72,12 @@ abstract class FirVisitor { return visitNamedDeclaration(memberDeclaration, data) } + open fun visitClassLikeDeclaration(classLikeDeclaration: FirClassLikeDeclaration, data: D): R { + return visitMemberDeclaration(classLikeDeclaration, data) + } + open fun visitRegularClass(regularClass: FirRegularClass, data: D): R { - return visitMemberDeclaration(regularClass, data) + return visitClassLikeDeclaration(regularClass, data) } open fun visitEnumEntry(enumEntry: FirEnumEntry, data: D): R { @@ -81,7 +85,7 @@ abstract class FirVisitor { } open fun visitTypeAlias(typeAlias: FirTypeAlias, data: D): R { - return visitMemberDeclaration(typeAlias, data) + return visitClassLikeDeclaration(typeAlias, data) } open fun visitTypeParameter(typeParameter: FirTypeParameter, data: D): R { diff --git a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorVoidGenerated.kt b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorVoidGenerated.kt index fae50b79e8c..f8ce55706e4 100644 --- a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorVoidGenerated.kt +++ b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorVoidGenerated.kt @@ -72,8 +72,12 @@ abstract class FirVisitorVoid : FirVisitor() { visitNamedDeclaration(memberDeclaration, null) } + open fun visitClassLikeDeclaration(classLikeDeclaration: FirClassLikeDeclaration) { + visitMemberDeclaration(classLikeDeclaration, null) + } + open fun visitRegularClass(regularClass: FirRegularClass) { - visitMemberDeclaration(regularClass, null) + visitClassLikeDeclaration(regularClass, null) } open fun visitEnumEntry(enumEntry: FirEnumEntry) { @@ -81,7 +85,7 @@ abstract class FirVisitorVoid : FirVisitor() { } open fun visitTypeAlias(typeAlias: FirTypeAlias) { - visitMemberDeclaration(typeAlias, null) + visitClassLikeDeclaration(typeAlias, null) } open fun visitTypeParameter(typeParameter: FirTypeParameter) { @@ -420,6 +424,10 @@ abstract class FirVisitorVoid : FirVisitor() { visitClass(klass) } + final override fun visitClassLikeDeclaration(classLikeDeclaration: FirClassLikeDeclaration, data: Nothing?) { + visitClassLikeDeclaration(classLikeDeclaration) + } + final override fun visitClassReferenceExpression(classReferenceExpression: FirClassReferenceExpression, data: Nothing?) { visitClassReferenceExpression(classReferenceExpression) } diff --git a/idea/testData/fir/multiModule/mppSuperTypes/jvm/jvm.kt b/idea/testData/fir/multiModule/mppSuperTypes/jvm/jvm.kt index c85f7e4cad7..c4d28b4a0e6 100644 --- a/idea/testData/fir/multiModule/mppSuperTypes/jvm/jvm.kt +++ b/idea/testData/fir/multiModule/mppSuperTypes/jvm/jvm.kt @@ -13,7 +13,6 @@ actual open class A : X(), Y { class C : B() { fun test() { foo() - // This and next cannot be resolved yet due to lack of search symbols / projections bar() baz() } diff --git a/idea/testData/fir/multiModule/mppSuperTypes/jvm/jvm.txt b/idea/testData/fir/multiModule/mppSuperTypes/jvm/jvm.txt index 0fb76c0ec5e..d2775ee3c15 100644 --- a/idea/testData/fir/multiModule/mppSuperTypes/jvm/jvm.txt +++ b/idea/testData/fir/multiModule/mppSuperTypes/jvm/jvm.txt @@ -23,8 +23,8 @@ FILE: jvm.kt public final function test(): R|kotlin/Unit| { R|/A.foo|() - #() - #() + R|/X.bar|() + R|/Y.baz|() } }