diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/Callables.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/CallableId.kt similarity index 78% rename from compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/Callables.kt rename to compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/CallableId.kt index 1cf75086e47..b797bc48897 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/Callables.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/CallableId.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.fir.symbols -import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -33,14 +32,4 @@ data class CallableId(val packageName: FqName, val className: FqName?, val calla } } -interface ConeCallableSymbol : ConeSymbol { - val callableId: CallableId -} -interface ConePropertySymbol : ConeVariableSymbol - -interface ConeVariableSymbol : ConeCallableSymbol - -interface ConeFunctionSymbol : ConeCallableSymbol { - val parameters: List -} \ No newline at end of file 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 index d9fa39b8c9c..53576d39fac 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/ConeLookupTags.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/ConeLookupTags.kt @@ -12,16 +12,7 @@ abstract class ConeClassifierLookupTag { abstract val name: Name } -abstract class ConeClassifierLookupTagWithFixedSymbol : ConeClassifierLookupTag() { - abstract val symbol: ConeClassifierSymbol -} -data class ConeTypeParameterLookupTag(val typeParameterSymbol: ConeTypeParameterSymbol) : ConeClassifierLookupTagWithFixedSymbol() { - override val name: Name get() = typeParameterSymbol.name - override val symbol: ConeClassifierSymbol - get() = typeParameterSymbol - -} abstract class ConeClassLikeLookupTag : ConeClassifierLookupTag() { abstract val classId: ClassId @@ -32,23 +23,3 @@ abstract class ConeClassLikeLookupTag : ConeClassifierLookupTag() { abstract class ConeTypeAliasLookupTag : ConeClassLikeLookupTag() -abstract class ConeClassLookupTag : ConeClassLikeLookupTag() - -class ConeClassLikeLookupTagImpl(override val classId: ClassId) : ConeClassLikeLookupTag() { - var boundSymbol: Pair<*, ConeClassifierSymbol?>? = null - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - - other as ConeClassLikeLookupTagImpl - - if (classId != other.classId) return false - - return true - } - - override fun hashCode(): Int { - return classId.hashCode() - } -} 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 deleted file mode 100644 index 39e65881b65..00000000000 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/ConeSymbols.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2010-2018 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.symbols - -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.model.TypeConstructorMarker -import org.jetbrains.kotlin.types.model.TypeParameterMarker - -interface ConeSymbol : TypeConstructorMarker - -interface ConeClassifierSymbol : ConeSymbol, TypeParameterMarker { - fun toLookupTag(): ConeClassifierLookupTag -} - -interface ConeTypeParameterSymbol : ConeClassifierSymbol { - override fun toLookupTag(): ConeTypeParameterLookupTag = ConeTypeParameterLookupTag(this) - val name: Name -} - -interface ConeClassLikeSymbol : ConeClassifierSymbol, TypeConstructorMarker { - val classId: ClassId - - override fun toLookupTag(): ConeClassLikeLookupTag -} - -interface ConeTypeAliasSymbol : ConeClassLikeSymbol - -interface ConeClassSymbol : 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 b493e9a35b9..4faf1358cfc 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 @@ -86,9 +86,11 @@ val ConeKotlinType.isMarkedNullable: Boolean get() = nullability == ConeNullabil typealias ConeKotlinErrorType = ConeClassErrorType +class ConeClassLikeErrorLookupTag(override val classId: ClassId) : ConeClassLikeLookupTag() + class ConeClassErrorType(val reason: String) : ConeClassLikeType() { override val lookupTag: ConeClassLikeLookupTag - get() = ConeClassLikeLookupTagImpl(ClassId.fromString("")) + get() = ConeClassLikeErrorLookupTag(ClassId.fromString("")) override val typeArguments: Array get() = EMPTY_ARRAY @@ -101,7 +103,7 @@ class ConeClassErrorType(val reason: String) : ConeClassLikeType() { } } -sealed class ConeLookupTagBasedType : ConeKotlinType(), SimpleTypeMarker { +abstract class ConeLookupTagBasedType : ConeKotlinType(), SimpleTypeMarker { abstract val lookupTag: ConeClassifierLookupTag } @@ -115,10 +117,6 @@ abstract class ConeAbbreviatedType : ConeClassLikeType() { abstract val abbreviationLookupTag: ConeClassLikeLookupTag } -abstract class ConeTypeParameterType : ConeLookupTagBasedType() { - abstract override val lookupTag: ConeTypeParameterLookupTag -} - data class ConeFlexibleType(val lowerBound: ConeKotlinType, val upperBound: ConeKotlinType) : ConeKotlinType(), FlexibleTypeMarker { diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/TypeRenderer.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/TypeRenderer.kt index f8b278e5528..0b24ffe2de4 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/TypeRenderer.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/TypeRenderer.kt @@ -27,7 +27,7 @@ fun ConeKotlinType.render(): String { } } } - is ConeTypeParameterType -> { + is ConeLookupTagBasedType -> { lookupTag.name.asString() } is ConeFlexibleType -> { 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 1ec5631ee6d..c7323449bf8 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 @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.fir.types.impl import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag -import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag import org.jetbrains.kotlin.fir.types.* open class ConeClassTypeImpl( @@ -49,32 +48,3 @@ class ConeAbbreviatedTypeImpl( override val nullability: ConeNullability = ConeNullability.create(isNullable) } -class ConeTypeParameterTypeImpl( - override val lookupTag: ConeTypeParameterLookupTag, - isNullable: Boolean -) : ConeTypeParameterType() { - override val typeArguments: Array - get() = EMPTY_ARRAY - - override val nullability: ConeNullability = ConeNullability.create(isNullable) - - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - - other as ConeTypeParameterTypeImpl - - if (lookupTag != other.lookupTag) return false - if (nullability != other.nullability) return false - - return true - } - - override fun hashCode(): Int { - var result = lookupTag.hashCode() - result = 31 * result + nullability.hashCode() - return result - } - -} diff --git a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt index b648df0f0fc..183b2934a61 100644 --- a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt +++ b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt @@ -25,6 +25,8 @@ import org.jetbrains.kotlin.fir.resolve.directExpansionType import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolve.withNullability import org.jetbrains.kotlin.fir.symbols.* +import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.FirTypePlaceholderProjection import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid @@ -41,8 +43,8 @@ import java.io.Writer internal interface FirLinkResolver { fun nearPackage(fqName: FqName): String? - fun symbolSignature(symbol: ConeSymbol): String - fun nearSymbolLocation(symbol: ConeSymbol): String? + fun symbolSignature(symbol: FirBasedSymbol<*>): String + fun nearSymbolLocation(symbol: FirBasedSymbol<*>): String? fun classLocation(classId: ClassId): String? @@ -283,7 +285,7 @@ class MultiModuleHtmlFirDump(private val outputRoot: File) { supplementaryGenerator.supplementary(this, originDir) } - override fun symbolSignature(symbol: ConeSymbol): String { + override fun symbolSignature(symbol: FirBasedSymbol<*>): String { val id = index.symbolIds[symbol] ?: error("Not found $symbol") return "id$id" } @@ -300,7 +302,7 @@ class MultiModuleHtmlFirDump(private val outputRoot: File) { return location.relativeTo(originDir).path + "#$classId" } - override fun nearSymbolLocation(symbol: ConeSymbol): String? { + override fun nearSymbolLocation(symbol: FirBasedSymbol<*>): String? { val location = index.symbols[symbol] ?: return null return location.relativeTo(originDir).path + "#${symbolSignature(symbol)}" } @@ -918,18 +920,18 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver } } - private fun ConeSymbol.describe(): String { + private fun FirBasedSymbol<*>.describe(): String { return when (this) { - is ConeClassLikeSymbol -> classId.asString() - is ConeCallableSymbol -> callableId.toString() + is FirClassLikeSymbol<*> -> classId.asString() + is FirCallableSymbol<*> -> callableId.toString() else -> "" } } - private fun FlowContent.symbolRef(symbol: ConeSymbol?, body: FlowContent.() -> Unit) { + private fun FlowContent.symbolRef(symbol: FirBasedSymbol<*>?, body: FlowContent.() -> Unit) { val (link, classes) = when (symbol) { null -> null to setOf() - is ConeClassLikeSymbol -> linkResolver.classLocation(symbol.classId) to setOf("class-fqn") + is FirClassLikeSymbol<*> -> linkResolver.classLocation(symbol.classId) to setOf("class-fqn") else -> linkResolver.nearSymbolLocation(symbol) to setOf("symbol") } declarationRef(link, classes) { @@ -964,7 +966,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver } is FirResolvedCallableReference -> { resolved { - symbolRef(reference.coneSymbol) { + symbolRef(reference.resolvedSymbol) { simpleName(reference.name) } } @@ -1255,7 +1257,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver } } - private fun FlowContent.symbolAnchor(symbol: ConeSymbol, body: FlowContent.() -> Unit) { + private fun FlowContent.symbolAnchor(symbol: AbstractFirBasedSymbol<*>, body: FlowContent.() -> Unit) { span(classes = "declaration") { id = linkResolver.symbolSignature(symbol) body() 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 500c7f6a5df..674cc43d8da 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 @@ -8,8 +8,7 @@ package org.jetbrains.kotlin.fir.backend import com.intellij.psi.PsiCompiledElement import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.resolve.toSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol -import org.jetbrains.kotlin.fir.symbols.ConeSymbol +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.ir.IrElement @@ -84,7 +83,7 @@ fun ConeKotlinTypeProjection.toIrTypeArgument(session: FirSession, declarationSt } } -fun ConeClassifierSymbol.toIrSymbol(session: FirSession, declarationStorage: Fir2IrDeclarationStorage): IrClassifierSymbol { +fun FirClassifierSymbol<*>.toIrSymbol(session: FirSession, declarationStorage: Fir2IrDeclarationStorage): IrClassifierSymbol { return when (this) { is FirTypeParameterSymbol -> { toTypeParameterSymbol(declarationStorage) @@ -103,7 +102,7 @@ fun ConeClassifierSymbol.toIrSymbol(session: FirSession, declarationStorage: Fir fun FirReference.toSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbol? { return when (this) { - is FirResolvedCallableReference -> coneSymbol.toSymbol(declarationStorage) + is FirResolvedCallableReference -> resolvedSymbol.toSymbol(declarationStorage) is FirThisReference -> { when (val boundSymbol = boundSymbol?.toSymbol(declarationStorage)) { is IrClassSymbol -> boundSymbol.owner.thisReceiver?.symbol @@ -115,7 +114,7 @@ fun FirReference.toSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbo } } -private fun ConeSymbol.toSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbol? = when (this) { +private fun AbstractFirBasedSymbol<*>.toSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbol? = when (this) { is FirClassSymbol -> toClassSymbol(declarationStorage) is FirFunctionSymbol<*> -> toFunctionSymbol(declarationStorage) is FirPropertySymbol -> toPropertyOrFieldSymbol(declarationStorage) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index 8686aa6fb19..cd2105bd1ed 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -24,7 +24,6 @@ import org.jetbrains.kotlin.fir.resolve.calls.SyntheticPropertySymbol import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.impl.FirClassSubstitutionScope -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.visitors.FirVisitor @@ -665,7 +664,7 @@ internal class Fir2IrVisitor( private fun FirReference.statementOrigin(): IrStatementOrigin? { return when (this) { is FirPropertyFromParameterCallableReference -> IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER - is FirResolvedCallableReference -> when (coneSymbol) { + is FirResolvedCallableReference -> when (resolvedSymbol) { is FirAccessorSymbol, is SyntheticPropertySymbol -> IrStatementOrigin.GET_PROPERTY else -> null } diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaElementFinder.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaElementFinder.kt index 452935467f7..65bc7213e5e 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaElementFinder.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaElementFinder.kt @@ -225,9 +225,9 @@ private const val ERROR_TYPE_STUB = CommonClassNames.JAVA_LANG_OBJECT private fun ConeKotlinType.mapToCanonicalString(session: FirSession): String { return when (this) { is ConeClassLikeType -> mapToCanonicalString(session) - is ConeTypeParameterType -> lookupTag.name.asString() is ConeTypeVariableType, is ConeFlexibleType, is ConeCapturedType, is ConeDefinitelyNotNullType, is ConeIntersectionType -> error("Unexpected type: $this [${this::class}]") + is ConeLookupTagBasedType -> lookupTag.name.asString() } } diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaElementFinder.kt.183 b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaElementFinder.kt.183 index 99a5961c076..727b2e8955a 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaElementFinder.kt.183 +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaElementFinder.kt.183 @@ -225,9 +225,9 @@ private const val ERROR_TYPE_STUB = CommonClassNames.JAVA_LANG_OBJECT private fun ConeKotlinType.mapToCanonicalString(session: FirSession): String { return when (this) { is ConeClassLikeType -> mapToCanonicalString(session) - is ConeTypeParameterType -> lookupTag.name.asString() is ConeTypeVariableType, is ConeFlexibleType, is ConeCapturedType, is ConeDefinitelyNotNullType, is ConeIntersectionType -> error("Unexpected type: $this [${this::class}]") + is ConeLookupTagBasedType -> lookupTag.name.asString() } } diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt index 8c00bd12fa9..dcf3349fddd 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt @@ -24,8 +24,8 @@ import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.resolve.constructClassType import org.jetbrains.kotlin.fir.resolve.getClassDeclaredCallableSymbols import org.jetbrains.kotlin.fir.service -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt index cb0c73af930..eba54f8cd6d 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt @@ -28,10 +28,7 @@ import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.impl.declaredMemberScope import org.jetbrains.kotlin.fir.service import org.jetbrains.kotlin.fir.symbols.* -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl @@ -173,7 +170,7 @@ class KotlinDeserializedJvmSymbolsProvider( return JvmProtoBufUtil.readClassDataFrom(data, strings) } - private fun ConeClassifierSymbol?.toDefaultResolvedTypeRef(classId: ClassId): FirResolvedTypeRef { + private fun FirClassifierSymbol<*>?.toDefaultResolvedTypeRef(classId: ClassId): FirResolvedTypeRef { return this?.let { FirResolvedTypeRefImpl( null, it.constructType(emptyList(), isNullable = false), diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt index c8028f7815a..3217b4a6d93 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt @@ -25,6 +25,8 @@ import org.jetbrains.kotlin.fir.resolve.constructType import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolve.toTypeProjection import org.jetbrains.kotlin.fir.symbols.* +import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl +import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl @@ -256,7 +258,7 @@ internal fun ConeKotlinType.lexicalCastFrom(session: FirSession, value: String): if (firStaticProperty != null) { FirQualifiedAccessExpressionImpl(null).apply { calleeReference = FirResolvedCallableReferenceImpl( - null, name, firStaticProperty.symbol as ConeCallableSymbol + null, name, firStaticProperty.symbol as FirCallableSymbol<*> ) } } else null diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassEnhancementScope.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassEnhancementScope.kt index d1a70fc014f..b3dc32dcde2 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassEnhancementScope.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassEnhancementScope.kt @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.symbols.CallableId -import org.jetbrains.kotlin.fir.symbols.ConePropertySymbol import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.ir.expressions.IrConstKind @@ -107,7 +106,7 @@ class JavaClassEnhancementScope( ) as FirAccessorSymbol } else -> { - if (original is ConePropertySymbol) return original + if (original is FirPropertySymbol) return original error("Can't make enhancement for $original: `${firElement.render()}`") } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index 8ddb214f013..41779c20665 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -23,12 +23,8 @@ import org.jetbrains.kotlin.fir.resolve.typeForQualifier import org.jetbrains.kotlin.fir.resolve.typeFromCallee import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope -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.fir.symbols.impl.FirBackingFieldSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator @@ -185,11 +181,11 @@ class FirCallResolver( } val referencedSymbol = when (nameReference) { - is FirResolvedCallableReference -> nameReference.coneSymbol + is FirResolvedCallableReference -> nameReference.resolvedSymbol is FirNamedReferenceWithCandidate -> nameReference.candidateSymbol else -> null } - if (referencedSymbol is ConeClassLikeSymbol) { + if (referencedSymbol is FirClassLikeSymbol<*>) { return FirResolvedQualifierImpl(nameReference.psi, referencedSymbol.classId).apply { resultType = typeForQualifier(this) } @@ -249,10 +245,10 @@ class FirCallResolver( } - private fun describeSymbol(symbol: ConeSymbol): String { + private fun describeSymbol(symbol: AbstractFirBasedSymbol<*>): String { return when (symbol) { - is ConeClassLikeSymbol -> symbol.classId.asString() - is ConeCallableSymbol -> symbol.callableId.toString() + is FirClassLikeSymbol<*> -> symbol.classId.asString() + is FirCallableSymbol<*> -> symbol.callableId.toString() else -> "$symbol" } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/AbstractAnnotationDeserializer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/AbstractAnnotationDeserializer.kt index 9f777396db8..c4d1cd98dac 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/AbstractAnnotationDeserializer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/AbstractAnnotationDeserializer.kt @@ -15,7 +15,7 @@ import org.jetbrains.kotlin.fir.references.FirErrorNamedReference import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl import org.jetbrains.kotlin.fir.resolve.constructType import org.jetbrains.kotlin.fir.resolve.toSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTagImpl +import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt index ff329b4d7d8..b9d1ccebdb7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.impl.FirClassImpl import org.jetbrains.kotlin.fir.declarations.impl.FirEnumEntryImpl -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTagImpl +import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl 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 3fe136f4408..23c10cd5722 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 @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl import org.jetbrains.kotlin.fir.declarations.impl.addDefaultBoundIfNecessary import org.jetbrains.kotlin.fir.resolve.toTypeProjection import org.jetbrains.kotlin.fir.symbols.* +import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.* @@ -108,7 +109,7 @@ class FirTypeDeserializer( get() = typeParameterDescriptors.values.toList() - fun FirClassLikeSymbol<*>.typeParameters(): List = fir.typeParameters.map { it.symbol } + fun FirClassLikeSymbol<*>.typeParameters(): List = fir.typeParameters.map { it.symbol } fun simpleType(proto: ProtoBuf.Type): ConeLookupTagBasedType? { 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 299accc8d5b..e03c5f51e9d 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 @@ -9,8 +9,6 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirClassLikeDeclaration import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.service -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.name.ClassId @@ -31,10 +29,10 @@ abstract class FirProvider : FirSymbolProvider() { abstract fun getFirClassifierContainerFile(fqName: ClassId): FirFile - fun getFirClassifierContainerFile(symbol: ConeClassLikeSymbol): FirFile = + fun getFirClassifierContainerFile(symbol: FirClassLikeSymbol<*>): FirFile = getFirClassifierContainerFile(symbol.classId) - abstract fun getFirCallableContainerFile(symbol: ConeCallableSymbol): FirFile? + abstract fun getFirCallableContainerFile(symbol: FirCallableSymbol<*>): FirFile? companion object { fun getInstance(session: FirSession): FirProvider = session.service() 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 dc09d97e5d3..416e3063550 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,14 +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.ConeClassifierSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.types.FirQualifierPart import org.jetbrains.kotlin.name.ClassId interface FirQualifierResolver { - fun resolveSymbolWithPrefix(parts: List, prefix: ClassId): ConeClassifierSymbol? + fun resolveSymbolWithPrefix(parts: List, prefix: ClassId): FirClassifierSymbol<*>? - fun resolveSymbol(parts: List): ConeClassifierSymbol? + fun resolveSymbol(parts: List): FirClassifierSymbol<*>? 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 a95e55be747..2cc924f0983 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,13 +7,14 @@ package org.jetbrains.kotlin.fir.resolve import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSessionComponent -import org.jetbrains.kotlin.fir.declarations.toFirClassLike import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.service import org.jetbrains.kotlin.fir.symbols.* +import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -22,7 +23,7 @@ abstract class FirSymbolProvider : FirSessionComponent { abstract fun getClassLikeSymbolByFqName(classId: ClassId): FirClassLikeSymbol<*>? - fun getSymbolByLookupTag(lookupTag: ConeClassifierLookupTag): ConeClassifierSymbol? { + fun getSymbolByLookupTag(lookupTag: ConeClassifierLookupTag): FirClassifierSymbol<*>? { return when (lookupTag) { is ConeClassLikeLookupTag -> { (lookupTag as? ConeClassLikeLookupTagImpl) @@ -56,17 +57,17 @@ abstract class FirSymbolProvider : FirSessionComponent { abstract fun getPackage(fqName: FqName): FqName? // TODO: Replace to symbol sometime // TODO: should not retrieve session through the FirElement::session - fun getSessionForClass(classId: ClassId): FirSession? = getClassLikeSymbolByFqName(classId)?.toFirClassLike()?.session + fun getSessionForClass(classId: ClassId): FirSession? = getClassLikeSymbolByFqName(classId)?.fir?.session companion object { fun getInstance(session: FirSession) = session.service() } } -fun FirSymbolProvider.getClassDeclaredCallableSymbols(classId: ClassId, name: Name): List { +fun FirSymbolProvider.getClassDeclaredCallableSymbols(classId: ClassId, name: Name): List> { val declaredMemberScope = getClassDeclaredMemberScope(classId) ?: return emptyList() - val result = mutableListOf() - val processor: (ConeCallableSymbol) -> ProcessorAction = { + val result = mutableListOf>() + val processor: (FirCallableSymbol<*>) -> ProcessorAction = { result.add(it) ProcessorAction.NEXT } 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 b8e68fda6e8..50f9c9573e7 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,7 +9,7 @@ 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.ConeClassifierSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirUserTypeRef @@ -17,11 +17,11 @@ 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): ConeClassifierSymbol? + fun resolveToSymbol(typeRef: FirTypeRef, scope: FirScope, position: FirPosition): FirClassifierSymbol<*>? companion object { fun getInstance(session: FirSession): FirTypeResolver = session.service() } - fun resolveUserType(typeRef: FirUserTypeRef, symbol: ConeClassifierSymbol?, scope: FirScope): ConeKotlinType + fun resolveUserType(typeRef: FirUserTypeRef, symbol: FirClassifierSymbol<*>?, 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 4ee9e009e4f..65d6241c829 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 @@ -17,9 +17,7 @@ import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor import org.jetbrains.kotlin.fir.resolve.transformers.resultType import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType import org.jetbrains.kotlin.fir.symbols.* -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.* import org.jetbrains.kotlin.types.Variance @@ -40,7 +38,7 @@ inline fun MutableMap.getOrPut(key: K, defaultValue: (K) -> val FirSession.firSymbolProvider: FirSymbolProvider by componentArrayAccessor() val FirSession.correspondingSupertypesCache: FirCorrespondingSupertypesCache by componentArrayAccessor() -fun ConeClassLikeLookupTag.toSymbol(useSiteSession: FirSession): ConeClassifierSymbol? { +fun ConeClassLikeLookupTag.toSymbol(useSiteSession: FirSession): FirClassifierSymbol<*>? { val firSymbolProvider = useSiteSession.firSymbolProvider return firSymbolProvider.getSymbolByLookupTag(this) } @@ -81,7 +79,7 @@ private fun mapTypeAliasArguments(typeAlias: FirTypeAlias, abbreviatedType: Cone return substitutor.substituteOrSelf(resultingType) } -fun ConeClassifierLookupTag.toSymbol(useSiteSession: FirSession): ConeClassifierSymbol? = +fun ConeClassifierLookupTag.toSymbol(useSiteSession: FirSession): FirClassifierSymbol<*>? = when (this) { is ConeClassLikeLookupTag -> toSymbol(useSiteSession) is ConeTypeParameterLookupTag -> this.symbol @@ -102,12 +100,12 @@ fun ConeClassifierLookupTag.constructType(typeArguments: Array, isNullable: Boolean): ConeLookupTagBasedType { +fun FirClassifierSymbol<*>.constructType(typeArguments: Array, isNullable: Boolean): ConeLookupTagBasedType { return when (this) { - is ConeTypeParameterSymbol -> { + is FirTypeParameterSymbol -> { ConeTypeParameterTypeImpl(this.toLookupTag(), isNullable) } - is ConeClassSymbol -> { + is FirClassSymbol -> { ConeClassTypeImpl(this.toLookupTag(), typeArguments, isNullable) } is FirTypeAliasSymbol -> { @@ -121,7 +119,7 @@ fun ConeClassifierSymbol.constructType(typeArguments: Array, isNullable: Boolean): ConeKotlinType = +fun FirClassifierSymbol<*>.constructType(parts: List, isNullable: Boolean): ConeKotlinType = constructType(parts.toTypeProjections(), isNullable) fun ConeKotlinType.toTypeProjection(variance: Variance): ConeKotlinTypeProjection = @@ -276,7 +274,7 @@ fun BodyResolveComponents.typeFromCallee(access: T): FirReso typeFromSymbol(newCallee.candidateSymbol, makeNullable) } is FirResolvedCallableReference -> { - typeFromSymbol(newCallee.coneSymbol, makeNullable) + typeFromSymbol(newCallee.resolvedSymbol, makeNullable) } is FirThisReference -> { val labelName = newCallee.labelName @@ -287,7 +285,7 @@ fun BodyResolveComponents.typeFromCallee(access: T): FirReso } } -private fun BodyResolveComponents.typeFromSymbol(symbol: ConeSymbol, makeNullable: Boolean): FirResolvedTypeRef { +private fun BodyResolveComponents.typeFromSymbol(symbol: AbstractFirBasedSymbol<*>, makeNullable: Boolean): FirResolvedTypeRef { return when (symbol) { is FirCallableSymbol<*> -> { val returnType = returnTypeCalculator.tryCalculateReturnType(symbol.phasedFir) @@ -299,7 +297,7 @@ private fun BodyResolveComponents.typeFromSymbol(symbol: ConeSymbol, makeNullabl returnType } } - is ConeClassifierSymbol -> { + is FirClassifierSymbol<*> -> { val fir = (symbol as? AbstractFirBasedSymbol<*>)?.phasedFir // TODO: unhack if (fir is FirEnumEntry) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ScopeUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ScopeUtils.kt index 1d08d96604d..92feafda4fa 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ScopeUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ScopeUtils.kt @@ -11,8 +11,8 @@ import org.jetbrains.kotlin.fir.resolve.transformers.firSafeNullable import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.impl.FirClassSubstitutionScope import org.jetbrains.kotlin.fir.scopes.impl.FirCompositeScope -import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl @@ -55,7 +55,7 @@ fun ConeClassLikeType.wrapSubstitutionScopeIfNeed( @Suppress("UNCHECKED_CAST") val substitution = regularClass.typeParameters.zip(this.typeArguments) { typeParameter, typeArgument -> typeParameter.symbol to (typeArgument as? ConeTypedProjection)?.type - }.filter { (_, type) -> type != null }.toMap() as Map + }.filter { (_, type) -> type != null }.toMap() as Map FirClassSubstitutionScope(session, useSiteScope, builder, substitution) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt index e71580b9b05..3714aa13716 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt @@ -14,10 +14,10 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirClassUseSiteScope import org.jetbrains.kotlin.fir.scopes.impl.FirSuperTypeScope import org.jetbrains.kotlin.fir.scopes.impl.declaredMemberScope import org.jetbrains.kotlin.fir.service -import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol -import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.* fun lookupSuperTypes( @@ -32,8 +32,8 @@ fun lookupSuperTypes( } class ScopeSession { - private val scopes = mutableMapOf, FirScope>>() - fun getOrBuild(symbol: ConeClassifierSymbol, key: ScopeSessionKey, build: () -> T): T { + private val scopes = mutableMapOf, MutableMap, FirScope>>() + fun getOrBuild(symbol: FirClassifierSymbol<*>, key: ScopeSessionKey, build: () -> T): T { return scopes.getOrPut(symbol) { mutableMapOf() }.getOrPut(key) { @@ -95,7 +95,7 @@ private fun ConeClassLikeType.wrapSubstitutionScopeIfNeed( @Suppress("UNCHECKED_CAST") val substitution = declaration.typeParameters.zip(this.typeArguments) { typeParameter, typeArgument -> typeParameter.symbol to (typeArgument as? ConeTypedProjection)?.type - }.filter { (_, type) -> type != null }.toMap() as Map + }.filter { (_, type) -> type != null }.toMap() as Map FirClassSubstitutionScope(session, useSiteScope, builder, substitution) } @@ -108,9 +108,9 @@ private tailrec fun ConeClassLikeType.computePartialExpansion(useSiteSession: Fi } } -private fun ConeClassifierSymbol.collectSuperTypes( +private fun FirClassifierSymbol<*>.collectSuperTypes( list: MutableList, - visitedSymbols: MutableSet, + visitedSymbols: MutableSet>, deep: Boolean, lookupInterfaces: Boolean, useSiteSession: FirSession diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateCollector.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateCollector.kt index f005017508d..73ba68c1fae 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateCollector.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateCollector.kt @@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.expressions.impl.FirQualifiedAccessExpressionImpl import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.util.OperatorNameConventions open class CandidateCollector( @@ -85,7 +85,7 @@ class InvokeReceiverCandidateCollector( FirQualifiedAccessExpressionImpl(null, false).apply { calleeReference = FirNamedReferenceWithCandidate( null, - (candidate.symbol as ConeCallableSymbol).callableId.callableName, + (candidate.symbol as FirCallableSymbol<*>).callableId.callableName, candidate ) dispatchReceiver = candidate.dispatchReceiverExpression() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConeInferenceContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConeInferenceContext.kt index fe0a8083d59..3c1537b93b3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConeInferenceContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConeInferenceContext.kt @@ -12,7 +12,11 @@ import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.withArguments import org.jetbrains.kotlin.fir.resolve.withNullability import org.jetbrains.kotlin.fir.service -import org.jetbrains.kotlin.fir.symbols.* +import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol +import org.jetbrains.kotlin.fir.symbols.invoke import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl @@ -56,14 +60,14 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, arguments: List, nullable: Boolean ): SimpleTypeMarker { - require(constructor is ConeClassifierSymbol) + require(constructor is FirClassifierSymbol<*>) return when (constructor) { - is ConeClassLikeSymbol -> ConeClassTypeImpl( + is FirClassLikeSymbol<*> -> ConeClassTypeImpl( constructor.toLookupTag(), (arguments as List).toTypedArray(), nullable ) - is ConeTypeParameterSymbol -> ConeTypeParameterTypeImpl( + is FirTypeParameterSymbol -> ConeTypeParameterTypeImpl( constructor.toLookupTag(), nullable ) @@ -161,7 +165,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, } override fun TypeConstructorMarker.isUnitTypeConstructor(): Boolean { - return this is ConeClassLikeSymbol && this.classId == StandardClassIds.Unit + return this is FirClassLikeSymbol<*> && this.classId == StandardClassIds.Unit } override fun Collection.singleBestRepresentative(): KotlinTypeMarker? { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirNamedReferenceWithCandidate.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirNamedReferenceWithCandidate.kt index a2b650cce94..4b1b4b23dfa 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirNamedReferenceWithCandidate.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirNamedReferenceWithCandidate.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.resolve.calls import com.intellij.psi.PsiElement import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol -import org.jetbrains.kotlin.fir.symbols.ConeSymbol import org.jetbrains.kotlin.name.Name class FirNamedReferenceWithCandidate( diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/InferenceUtil.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/InferenceUtil.kt index 3366f9f2443..737e4a15aac 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/InferenceUtil.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/InferenceUtil.kt @@ -10,7 +10,6 @@ import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTag -import org.jetbrains.kotlin.fir.symbols.ConeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.name.Name @@ -42,7 +41,7 @@ fun ConeTypeContext.hasNullableSuperType(type: ConeKotlinType): Boolean { return false } -class ConeTypeVariableTypeConstructor(val debugName: String) : ConeSymbol, ConeClassifierLookupTag(), TypeVariableTypeConstructorMarker { +class ConeTypeVariableTypeConstructor(val debugName: String) : ConeClassifierLookupTag(), TypeVariableTypeConstructorMarker { override val name: Name get() = Name.identifier(debugName) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt index f8f802251d3..8516a4c3b0a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt @@ -10,10 +10,9 @@ import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.resolve.FirProvider import org.jetbrains.kotlin.fir.service -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.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef @@ -167,10 +166,10 @@ internal object DiscriminateSynthetics : CheckerStage() { } internal object CheckVisibility : CheckerStage() { - private fun ConeSymbol.packageFqName(): FqName { + private fun AbstractFirBasedSymbol<*>.packageFqName(): FqName { return when (this) { - is ConeClassLikeSymbol -> classId.packageFqName - is ConeCallableSymbol -> callableId.packageName + is FirClassLikeSymbol<*> -> classId.packageFqName + is FirCallableSymbol<*> -> callableId.packageName else -> error("No package fq name for ${this}") } } @@ -186,8 +185,8 @@ internal object CheckVisibility : CheckerStage() { if (declaration.session == callInfo.session) { val provider = callInfo.session.service() val candidateFile = when (symbol) { - is ConeCallableSymbol -> provider.getFirCallableContainerFile(symbol) - is ConeClassLikeSymbol -> provider.getFirClassifierContainerFile(symbol.classId) + is FirCallableSymbol<*> -> provider.getFirCallableContainerFile(symbol) + is FirClassLikeSymbol<*> -> provider.getFirClassifierContainerFile(symbol.classId) else -> null } candidateFile == callInfo.containingFile diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt index 15e61a6ac69..a767bde7315 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirNamedFunction import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter @@ -15,13 +14,10 @@ import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.symbols.* -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.Name -interface SyntheticSymbol : ConeSymbol +interface SyntheticSymbol class SyntheticPropertySymbol(callableId: CallableId) : FirPropertySymbol(callableId), SyntheticSymbol @@ -35,7 +31,7 @@ class FirSyntheticPropertiesScope( private val typeCalculator: ReturnTypeCalculator ) : FirScope() { - val synthetic: MutableMap = mutableMapOf() + val synthetic: MutableMap, FirVariableSymbol<*>> = mutableMapOf() private fun checkGetAndCreateSynthetic( diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt index dc231ee7c0c..1d144025888 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt @@ -24,8 +24,6 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope import org.jetbrains.kotlin.fir.scopes.processClassifiersByNameWithAction import org.jetbrains.kotlin.fir.service import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol -import org.jetbrains.kotlin.fir.symbols.ConeSymbol import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -47,7 +45,7 @@ interface TowerScopeLevel { processor: TowerScopeLevelProcessor ): ProcessorAction - interface TowerScopeLevelProcessor { + interface TowerScopeLevelProcessor> { fun consumeCandidate( symbol: T, dispatchReceiverValue: ClassDispatchReceiverValue?, @@ -248,7 +246,7 @@ class QualifiedReceiverTowerLevel(session: FirSession) : SessionBasedTowerLevel( fun FirCallableDeclaration<*>.dispatchReceiverValue(session: FirSession): ClassDispatchReceiverValue? { // TODO: this is not true atCall least for inner class constructors if (this is FirConstructor) return null - val id = (this.symbol as ConeCallableSymbol).callableId.classId ?: return null + val id = this.symbol.callableId.classId ?: return null val symbol = session.service().getClassLikeSymbolByFqName(id) as? FirClassSymbol ?: return null val regularClass = symbol.fir diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt index fd5eabf5157..6ac08c87219 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt @@ -466,10 +466,10 @@ class FirDataFlowAnalyzer(transformer: FirBodyResolveTransformer) : BodyResolveC } private val FirResolvable.resolvedSymbol: FirBasedSymbol<*>? - get() = (calleeReference as? FirResolvedCallableReference)?.coneSymbol as? FirBasedSymbol<*> + get() = (calleeReference as? FirResolvedCallableReference)?.resolvedSymbol private fun FirFunctionCall.isBooleanNot(): Boolean { - val symbol = calleeReference.safeAs()?.coneSymbol as? FirNamedFunctionSymbol ?: return false + val symbol = calleeReference.safeAs()?.resolvedSymbol as? FirNamedFunctionSymbol ?: return false return symbol.callableId == KOTLIN_BOOLEAN_NOT } @@ -700,7 +700,7 @@ class FirDataFlowAnalyzer(transformer: FirBodyResolveTransformer) : BodyResolveC require(explicitReceiver != null) collect(explicitReceiver) } - ((call.calleeReference as? FirResolvedCallableReference)?.coneSymbol)?.let { symbol -> + ((call.calleeReference as? FirResolvedCallableReference)?.resolvedSymbol)?.let { symbol -> if (symbol is FirVariableSymbol<*> || symbol is FirPropertySymbol) { result += getOrCreateRealVariable(symbol as FirBasedSymbol<*>) } 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 333206adfa2..2875de48664 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,7 +15,6 @@ import org.jetbrains.kotlin.fir.resolve.buildDefaultUseSiteScope import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.impl.FirClassDeclaredMemberScope import org.jetbrains.kotlin.fir.symbols.CallableId -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol @@ -29,7 +28,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name class FirProviderImpl(val session: FirSession) : FirProvider() { - override fun getFirCallableContainerFile(symbol: ConeCallableSymbol): FirFile? { + override fun getFirCallableContainerFile(symbol: FirCallableSymbol<*>): FirFile? { return state.callableContainerMap[symbol] } @@ -114,7 +113,7 @@ class FirProviderImpl(val session: FirSession) : FirProvider() { val classifierContainerFileMap = mutableMapOf() val classesInPackage = mutableMapOf>() val callableMap = mutableMapOf>>() - val callableContainerMap = mutableMapOf() + val callableContainerMap = mutableMapOf, FirFile>() fun setFrom(other: State) { fileMap.clear() 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 cf7c1b9e106..25caeb2e904 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.ConeClassifierSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol 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): ConeClassifierSymbol? { + override fun resolveSymbolWithPrefix(parts: List, prefix: ClassId): FirClassifierSymbol<*>? { val symbolProvider = FirSymbolProvider.getInstance(session) val fqName = ClassId( @@ -26,7 +26,7 @@ class FirQualifierResolverImpl(val session: FirSession) : FirQualifierResolver { return symbolProvider.getClassLikeSymbolByFqName(fqName) } - override fun resolveSymbol(parts: List): ConeClassifierSymbol? { + override fun resolveSymbol(parts: List): FirClassifierSymbol<*>? { val firProvider = FirSymbolProvider.getInstance(session) if (parts.isNotEmpty()) { 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 fd7a9535c20..30435f9f9e8 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,10 +14,9 @@ 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.symbols.ConeClassLikeSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol -import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.* import org.jetbrains.kotlin.name.ClassId @@ -44,24 +43,24 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver { typeRef: FirTypeRef, scope: FirScope, position: FirPosition - ): ConeClassifierSymbol? { + ): FirClassifierSymbol<*>? { return when (typeRef) { is FirResolvedTypeRef -> typeRef.coneTypeSafe()?.lookupTag?.let(symbolProvider::getSymbolByLookupTag) is FirUserTypeRef -> { val qualifierResolver = FirQualifierResolver.getInstance(session) - var resolvedSymbol: ConeClassifierSymbol? = null + var resolvedSymbol: FirClassifierSymbol<*>? = null scope.processClassifiersByName(typeRef.qualifier.first().name, position) { symbol -> resolvedSymbol = when (symbol) { - is ConeClassLikeSymbol -> { + is FirClassLikeSymbol<*> -> { if (typeRef.qualifier.size == 1) { symbol } else { qualifierResolver.resolveSymbolWithPrefix(typeRef.qualifier, symbol.classId) } } - is ConeTypeParameterSymbol -> { + is FirTypeParameterSymbol -> { assert(typeRef.qualifier.size == 1) symbol } @@ -80,7 +79,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver { } } - override fun resolveUserType(typeRef: FirUserTypeRef, symbol: ConeClassifierSymbol?, scope: FirScope): ConeKotlinType { + override fun resolveUserType(typeRef: FirUserTypeRef, symbol: FirClassifierSymbol<*>?, scope: FirScope): ConeKotlinType { symbol ?: return ConeKotlinErrorType("Symbol not found, for `${typeRef.render()}`") return symbol.constructType(typeRef.qualifier, typeRef.isMarkedNullable) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/substitution/ConeSubstitutor.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/substitution/ConeSubstitutor.kt index 16b8650be71..75e8ef5b97e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/substitution/ConeSubstitutor.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/substitution/ConeSubstitutor.kt @@ -6,7 +6,7 @@ package org.jetbrains.kotlin.fir.resolve.substitution import org.jetbrains.kotlin.fir.resolve.withNullability -import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.ConeAbbreviatedTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl @@ -70,8 +70,7 @@ abstract class AbstractConeSubstitutor : ConeSubstitutor() { is ConeClassErrorType -> return null is ConeClassType -> this.substituteArguments() is ConeAbbreviatedType -> this.substituteArguments() - is ConeTypeParameterType -> return null - is ConeTypeVariableType -> return null + is ConeLookupTagBasedType -> return null is ConeFlexibleType -> this.substituteBounds() is ConeCapturedType -> return null is ConeDefinitelyNotNullType -> this.substituteOriginal() @@ -146,12 +145,12 @@ abstract class AbstractConeSubstitutor : ConeSubstitutor() { } -fun substitutorByMap(substitution: Map): ConeSubstitutor { +fun substitutorByMap(substitution: Map): ConeSubstitutor { if (substitution.isEmpty()) return ConeSubstitutor.Empty return ConeSubstitutorByMap(substitution) } -class ConeSubstitutorByMap(val substitution: Map) : AbstractConeSubstitutor() { +class ConeSubstitutorByMap(val substitution: Map) : AbstractConeSubstitutor() { override fun substituteType(type: ConeKotlinType): ConeKotlinType? { if (type !is ConeTypeParameterType) return null diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirAbstractPhaseTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirAbstractPhaseTransformer.kt index db0e7d4dd83..17a986883ed 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirAbstractPhaseTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirAbstractPhaseTransformer.kt @@ -9,11 +9,7 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirResolvePhase -import org.jetbrains.kotlin.fir.render -import org.jetbrains.kotlin.fir.resolve.FirProvider import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult import org.jetbrains.kotlin.fir.visitors.FirTransformer diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt index c9fe351c1b0..438076b86b2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt @@ -228,7 +228,7 @@ open class FirBodyResolveTransformer( qualifiedAccessExpression } is FirDelegateFieldReference -> { - val delegateFieldSymbol = callee.coneSymbol + val delegateFieldSymbol = callee.resolvedSymbol qualifiedAccessExpression.resultType = delegateFieldSymbol.delegate.typeRef qualifiedAccessExpression } @@ -1029,10 +1029,7 @@ class FirBodyResolveTransformerAdapter : FirTransformer() { } -inline fun ConeSymbol.firUnsafe(): T { - require(this is FirBasedSymbol<*>) { - "Not a fir based symbol: ${this}" - } +inline fun FirBasedSymbol<*>.firUnsafe(): T { val fir = this.fir require(fir is T) { "Not an expected fir element type = ${T::class}, symbol = ${this}, fir = ${fir.renderWithType()}" @@ -1040,8 +1037,7 @@ inline fun ConeSymbol.firUnsafe(): T { return fir } -inline fun ConeSymbol.firSafeNullable(): T? { - if (this !is FirBasedSymbol<*>) return null +inline fun FirBasedSymbol<*>.firSafeNullable(): T? { return fir as? T } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypeResolverTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypeResolverTransformer.kt index 21ec91996d2..1dbcc91569e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypeResolverTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypeResolverTransformer.kt @@ -163,7 +163,7 @@ class FirSupertypeResolverTransformer : FirAbstractTreeTransformer(phase = FirRe sessionForSupertype .getService(FirSymbolProvider::class) .getClassLikeSymbolByFqName(superTypeClassId) - ?.toFirClassLike() + ?.fir // TODO: this if is a temporary hack for built-in types (because we can't load file for them) if (firClassForSupertype == null || diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/PhaseUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/PhaseUtils.kt index 1f0d0fa7f7c..0132c51d4d2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/PhaseUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/PhaseUtils.kt @@ -10,11 +10,10 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.FirProvider -import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticFunctionSymbol import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner +import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol fun AbstractFirBasedSymbol.phasedFir( session: FirSession, @@ -25,8 +24,8 @@ fun AbstractFirBasedSymbol.phasedFir( if (availablePhase < requiredPhase) { val provider = FirProvider.getInstance(session) val containingFile = when (this) { - is ConeCallableSymbol -> provider.getFirCallableContainerFile(this) - is ConeClassLikeSymbol -> provider.getFirClassifierContainerFile(this) + is FirCallableSymbol<*> -> provider.getFirCallableContainerFile(this) + is FirClassLikeSymbol<*> -> provider.getFirClassifierContainerFile(this) else -> null } ?: throw AssertionError("Cannot get container file by symbol: $this (${result.render()})") containingFile.runResolve(toPhase = requiredPhase, fromPhase = availablePhase) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ReturnTypeCalculator.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ReturnTypeCalculator.kt index 571a4dd2dfe..2fd6a77f3a4 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ReturnTypeCalculator.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ReturnTypeCalculator.kt @@ -14,7 +14,7 @@ import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.FirProvider import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.service -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.FirComputingImplicitTypeRef @@ -56,7 +56,7 @@ class ReturnTypeCalculatorWithJump(val session: FirSession, val scopeSession: Sc require(declaration is FirCallableMemberDeclaration<*>) { "${declaration::class}: ${declaration.render()}" } - val symbol = declaration.symbol as ConeCallableSymbol + val symbol = declaration.symbol as FirCallableSymbol<*> val id = symbol.callableId val provider = session.service() 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 fa44b527791..7229d6b9d7a 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.ConeClassifierSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.name.Name abstract class FirTypeParameterScope : FirScope() { @@ -15,7 +15,7 @@ abstract class FirTypeParameterScope : FirScope() { override fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeClassifierSymbol) -> Boolean + processor: (FirClassifierSymbol<*>) -> Boolean ): Boolean { val matchedTypeParameters = typeParameters[name] ?: return true diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirOverrideScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirOverrideScope.kt index e2299c4e25b..3993516fbcd 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirOverrideScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirOverrideScope.kt @@ -12,7 +12,7 @@ import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.cast abstract class AbstractFirOverrideScope(val session: FirSession) : FirScope() { //base symbol as key - val overrides = mutableMapOf() + val overrides = mutableMapOf, FirCallableSymbol<*>?>() val context: ConeTypeContext = session.typeContext @@ -58,7 +58,7 @@ abstract class AbstractFirOverrideScope(val session: FirSession) : FirScope() { } } - protected fun ConeCallableSymbol.isOverridden(seen: Set): ConeCallableSymbol? { + protected fun FirCallableSymbol<*>.isOverridden(seen: Set>): FirCallableSymbol<*>? { if (overrides.containsKey(this)) return overrides[this] fun similarFunctionsOrBothProperties(declaration: FirCallableDeclaration<*>, self: FirCallableDeclaration<*>): Boolean { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt index fb27d087771..bc7b784d25f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt @@ -15,9 +15,7 @@ import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.processConstructors import org.jetbrains.kotlin.fir.symbols.* -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.addToStdlib.cast @@ -35,7 +33,7 @@ abstract class FirAbstractImportingScope( val symbol = provider.getClassLikeSymbolByFqName(classId) ?: error("No scope/symbol for $classId") if (symbol is FirTypeAliasSymbol) { val expansionSymbol = symbol.fir.expandedConeType?.lookupTag?.toSymbol(session) - if (expansionSymbol is ConeClassLikeSymbol) { + if (expansionSymbol is FirClassLikeSymbol<*>) { return getStaticsScope(expansionSymbol.classId) } } @@ -113,7 +111,7 @@ abstract class FirAbstractImportingScope( return processCallables( name, TowerScopeLevel.Token.Properties - ) { if (it is ConeVariableSymbol) processor(it) else ProcessorAction.NEXT } + ) { if (it is FirVariableSymbol<*>) processor(it) else ProcessorAction.NEXT } } } \ 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 f2ab05d8a71..15f2997a69b 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 @@ -12,8 +12,8 @@ import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.calls.TowerScopeLevel import org.jetbrains.kotlin.fir.scopes.FirPosition import org.jetbrains.kotlin.fir.scopes.ProcessorAction -import org.jetbrains.kotlin.fir.symbols.* import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name @@ -27,7 +27,7 @@ abstract class FirAbstractSimpleImportingScope( override fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeClassifierSymbol) -> Boolean + processor: (FirClassifierSymbol<*>) -> Boolean ): Boolean { val imports = simpleImports[name] ?: return true if (imports.isEmpty()) return true 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 52c655715fe..39d728dedb5 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 @@ -11,8 +11,8 @@ import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.calls.TowerScopeLevel import org.jetbrains.kotlin.fir.scopes.FirPosition import org.jetbrains.kotlin.fir.scopes.ProcessorAction -import org.jetbrains.kotlin.fir.symbols.* import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name @@ -27,7 +27,7 @@ abstract class FirAbstractStarImportingScope( override fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeClassifierSymbol) -> Boolean + processor: (FirClassifierSymbol<*>) -> Boolean ): Boolean { for (import in starImports) { val relativeClassName = import.relativeClassName diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassDeclaredMemberScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassDeclaredMemberScope.kt index 903af32c21c..059307390e8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassDeclaredMemberScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassDeclaredMemberScope.kt @@ -14,10 +14,7 @@ import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NEXT import org.jetbrains.kotlin.fir.scopes.ProcessorAction.STOP import org.jetbrains.kotlin.fir.service -import org.jetbrains.kotlin.fir.symbols.* -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.Name class FirClassDeclaredMemberScopeProvider { @@ -80,14 +77,14 @@ class FirClassDeclaredMemberScope(klass: FirRegularClass) : FirScope() { override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> ProcessorAction): ProcessorAction { val symbols = callablesIndex[name] ?: emptyList() for (symbol in symbols) { - if (symbol is ConeVariableSymbol && !processor(symbol)) { + if (symbol is FirVariableSymbol && !processor(symbol)) { return STOP } } return NEXT } - override fun processClassifiersByName(name: Name, position: FirPosition, processor: (ConeClassifierSymbol) -> Boolean): Boolean { + override fun processClassifiersByName(name: Name, position: FirPosition, processor: (FirClassifierSymbol<*>) -> Boolean): Boolean { val matchedClass = classIndex[name] if (matchedClass != null && !processor(matchedClass)) { return false 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 e5c1ca73679..a9c0a3933b3 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 @@ -14,7 +14,6 @@ import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculatorWithJump import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction -import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef @@ -27,7 +26,7 @@ class FirClassSubstitutionScope( private val session: FirSession, private val useSiteScope: FirScope, scopeSession: ScopeSession, - substitution: Map + substitution: Map ) : FirScope() { private val fakeOverrideFunctions = mutableMapOf, FirFunctionSymbol<*>>() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteScope.kt index 3d867b9a5f6..2831eee05ce 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteScope.kt @@ -11,8 +11,8 @@ import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NEXT import org.jetbrains.kotlin.fir.scopes.ProcessorAction.STOP -import org.jetbrains.kotlin.fir.symbols.* import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.name.Name @@ -23,7 +23,7 @@ class FirClassUseSiteScope( ) : AbstractFirOverrideScope(session) { override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> ProcessorAction): ProcessorAction { - val seen = mutableSetOf() + val seen = mutableSetOf>() if (!declaredMemberScope.processFunctionsByName(name) { seen += it processor(it) @@ -42,7 +42,7 @@ class FirClassUseSiteScope( } override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> ProcessorAction): ProcessorAction { - val seen = mutableSetOf() + val seen = mutableSetOf>() if (!declaredMemberScope.processPropertiesByName(name) { seen += it processor(it) @@ -60,7 +60,7 @@ class FirClassUseSiteScope( } } - override fun processClassifiersByName(name: Name, position: FirPosition, processor: (ConeClassifierSymbol) -> Boolean): Boolean { + override fun processClassifiersByName(name: Name, position: FirPosition, processor: (FirClassifierSymbol<*>) -> Boolean): Boolean { return declaredMemberScope.processClassifiersByName(name, position, processor) } } 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 3d263514aa7..c603494457b 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 @@ -11,8 +11,8 @@ import org.jetbrains.kotlin.fir.scopes.FirTypeParameterScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NEXT import org.jetbrains.kotlin.fir.scopes.ProcessorAction.STOP -import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.name.Name @@ -23,7 +23,7 @@ class FirCompositeScope( override fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeClassifierSymbol) -> Boolean + processor: (FirClassifierSymbol<*>) -> Boolean ): Boolean { val scopes = if (reversedPriority) scopes.asReversed() else scopes for (scope in scopes) { 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 3650804d709..4528908cb5a 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.ConeClassifierSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol 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: (ConeClassifierSymbol) -> Boolean + processor: (FirClassifierSymbol<*>) -> 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 fad60b83b4d..02091e58aeb 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 @@ -9,7 +9,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.ConeClassifierSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -18,12 +18,12 @@ class FirSelfImportingScope(val fqName: FqName, val session: FirSession) : FirSc private val symbolProvider = FirSymbolProvider.getInstance(session) - private val cache = mutableMapOf() + private val cache = mutableMapOf?>() override fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeClassifierSymbol) -> Boolean + processor: (FirClassifierSymbol<*>) -> Boolean ): Boolean { if (name.asString().isEmpty()) return true diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirSuperTypeScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirSuperTypeScope.kt index 7ddf3befd9a..9383010e83c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirSuperTypeScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirSuperTypeScope.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction -import org.jetbrains.kotlin.fir.symbols.ConeFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.name.Name @@ -19,8 +18,8 @@ class FirSuperTypeScope( ) : AbstractFirOverrideScope(session) { override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> ProcessorAction): ProcessorAction { - val accepted = HashSet() - val pending = mutableListOf() + val accepted = HashSet>() + val pending = mutableListOf>() for (scope in scopes) { if (scope.processFunctionsByName(name) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirTopLevelDeclaredMemberScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirTopLevelDeclaredMemberScope.kt index be6868c24b3..5c6412a03f7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirTopLevelDeclaredMemberScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirTopLevelDeclaredMemberScope.kt @@ -12,9 +12,9 @@ import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NEXT import org.jetbrains.kotlin.fir.scopes.ProcessorAction.STOP import org.jetbrains.kotlin.fir.scopes.processConstructors -import org.jetbrains.kotlin.fir.symbols.ConePropertySymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name @@ -51,7 +51,7 @@ class FirTopLevelDeclaredMemberScope( override fun processPropertiesByName(name: Name, processor: (FirCallableSymbol<*>) -> ProcessorAction): ProcessorAction { val symbols = provider.getTopLevelCallableSymbols(packageFqName, name) for (symbol in symbols) { - if (symbol is ConePropertySymbol && !processor(symbol)) { + if (symbol is FirPropertySymbol && !processor(symbol)) { return STOP } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt index 17de841ba9b..9d073e98a46 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt @@ -10,7 +10,6 @@ import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.expandedConeType import org.jetbrains.kotlin.fir.declarations.superConeTypes import org.jetbrains.kotlin.fir.resolve.* @@ -19,13 +18,12 @@ import org.jetbrains.kotlin.fir.resolve.calls.ConeTypeVariableTypeConstructor import org.jetbrains.kotlin.fir.resolve.calls.hasNullableSuperType import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap -import org.jetbrains.kotlin.fir.resolve.transformers.firSafeNullable import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe import org.jetbrains.kotlin.fir.service -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.symbols.impl.FirTypeParameterSymbol +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.symbols.impl.* +import org.jetbrains.kotlin.fir.symbols.invoke import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName @@ -196,7 +194,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun TypeConstructorMarker.parametersCount(): Int { //require(this is ConeSymbol) return when (this) { - is ConeTypeParameterSymbol, + is FirTypeParameterSymbol, is ConeCapturedTypeConstructor, is ErrorTypeConstructor, is ConeTypeVariableTypeConstructor, @@ -210,7 +208,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun TypeConstructorMarker.getParameter(index: Int): TypeParameterMarker { //require(this is ConeSymbol) return when (this) { - is ConeTypeParameterSymbol -> error("?!:11") + is FirTypeParameterSymbol -> error("?!:11") is FirClassSymbol -> fir.typeParameters[index].symbol is FirTypeAliasSymbol -> fir.typeParameters[index].symbol else -> error("?!:12") @@ -274,7 +272,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty is ConeCapturedTypeConstructor, is ConeTypeVariableTypeConstructor, is ConeIntersectionType -> false - is ConeSymbol -> true + is AbstractFirBasedSymbol<*> -> true else -> true } } @@ -343,11 +341,11 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty } override fun TypeConstructorMarker.isAnyConstructor(): Boolean { - return this is ConeClassLikeSymbol && classId == StandardClassIds.Any + return this is FirClassLikeSymbol<*> && classId == StandardClassIds.Any } override fun TypeConstructorMarker.isNothingConstructor(): Boolean { - return this is ConeClassLikeSymbol && classId == StandardClassIds.Nothing + return this is FirClassLikeSymbol<*> && classId == StandardClassIds.Nothing } override fun SimpleTypeMarker.isSingleClassifierType(): Boolean { @@ -425,8 +423,8 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty } private fun TypeConstructorMarker.toFirRegularClass(): FirRegularClass? { - if (this !is ConeClassLikeSymbol) return null - return this.firSafeNullable() + if (this !is FirClassLikeSymbol<*>) return null + return fir as? FirRegularClass } override fun nullableAnyType(): SimpleTypeMarker = TODO("not implemented") @@ -462,8 +460,8 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty } override fun TypeParameterMarker.getRepresentativeUpperBound(): KotlinTypeMarker { - require(this is ConeTypeParameterSymbol) - return this.firSafeNullable()?.bounds?.getOrNull(0)?.let { (it as? FirResolvedTypeRef)?.type } + require(this is FirTypeParameterSymbol) + return this.fir.bounds.getOrNull(0)?.let { (it as? FirResolvedTypeRef)?.type } ?: ConeClassTypeImpl( ConeClassLikeLookupTagImpl(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.any.toSafe())), emptyArray(), true ) @@ -487,7 +485,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty return toFirRegularClass()?.symbol?.toLookupTag()?.classId?.asSingleFqName()?.toUnsafe() } - override fun TypeParameterMarker.getName() = (this as ConeTypeParameterSymbol).name + override fun TypeParameterMarker.getName() = (this as FirTypeParameterSymbol).name override fun TypeParameterMarker.isReified(): Boolean = TODO("not implemented") @@ -514,7 +512,7 @@ class ConeTypeCheckerContext(override val isErrorTypeEqualsToAnything: Boolean, val substitutor = if (declaration != null) { val substitution = declaration.typeParameters.zip(type.typeArguments).associate { (parameter, argument) -> - parameter.symbol as ConeTypeParameterSymbol to ((argument as? ConeTypedProjection)?.type + parameter.symbol to ((argument as? ConeTypedProjection)?.type ?: StandardClassIds.Any(session.firSymbolProvider).constructType(emptyArray(), isNullable = true)) } substitutorByMap(substitution) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/FirCorrespondingSupertypesCache.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/FirCorrespondingSupertypesCache.kt index 8948c82f02d..f5fa26b439b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/FirCorrespondingSupertypesCache.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/FirCorrespondingSupertypesCache.kt @@ -7,11 +7,10 @@ package org.jetbrains.kotlin.fir.types import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSessionComponent -import org.jetbrains.kotlin.fir.declarations.toFirClassLike import org.jetbrains.kotlin.fir.resolve.constructClassType import org.jetbrains.kotlin.fir.resolve.constructType import org.jetbrains.kotlin.fir.resolve.toSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.types.AbstractTypeCheckerContext import org.jetbrains.kotlin.types.model.CaptureStatus import org.jetbrains.kotlin.types.model.SimpleTypeMarker @@ -19,15 +18,15 @@ import org.jetbrains.kotlin.types.model.TypeConstructorMarker class FirCorrespondingSupertypesCache(private val session: FirSession) : FirSessionComponent { private val context = ConeTypeCheckerContext(false, session) - private val cache = HashMap>?>(1000, 0.5f) + private val cache = HashMap, Map, List>?>(1000, 0.5f) fun getCorrespondingSupertypes( type: ConeKotlinType, supertypeConstructor: TypeConstructorMarker ): List? { - if (type !is ConeClassLikeType || supertypeConstructor !is ConeClassLikeSymbol) return null + if (type !is ConeClassLikeType || supertypeConstructor !is FirClassLikeSymbol<*>) return null - val symbol = type.lookupTag.toSymbol(session) as? ConeClassLikeSymbol ?: return null + val symbol = type.lookupTag.toSymbol(session) as? FirClassLikeSymbol<*> ?: return null if (symbol == supertypeConstructor) return listOf(captureType(type)) if (symbol !in cache) { @@ -49,14 +48,14 @@ class FirCorrespondingSupertypesCache(private val session: FirSession) : FirSess private fun computeSupertypesMap( subtype: ConeLookupTagBasedType, - subtypeSymbol: ConeClassLikeSymbol - ): Map>? { - val resultingMap = HashMap>() + subtypeSymbol: FirClassLikeSymbol<*> + ): Map, List>? { + val resultingMap = HashMap, List>() val subtypeClassSymbol = with(context) { - subtype.typeConstructor() as? ConeClassLikeSymbol ?: return null + subtype.typeConstructor() as? FirClassLikeSymbol<*> ?: return null } - val subtypeFirClass = subtypeClassSymbol.toFirClassLike() ?: return null + val subtypeFirClass = subtypeClassSymbol.fir val defaultType = subtypeClassSymbol.toLookupTag().constructClassType( subtypeFirClass.typeParameters.map { @@ -67,7 +66,7 @@ class FirCorrespondingSupertypesCache(private val session: FirSession) : FirSess if (context.anySupertype( defaultType, - { it !is ConeClassLikeType || it.lookupTag.toSymbol(session) !is ConeClassLikeSymbol } + { it !is ConeClassLikeType || it.lookupTag.toSymbol(session) !is FirClassLikeSymbol<*> } ) { supertype -> computeSupertypePolicyAndPutInMap(supertype, subtypeSymbol, resultingMap) } ) { return null @@ -78,10 +77,10 @@ class FirCorrespondingSupertypesCache(private val session: FirSession) : FirSess private fun computeSupertypePolicyAndPutInMap( supertype: SimpleTypeMarker, - subtypeSymbol: ConeClassLikeSymbol, - resultingMap: MutableMap> + subtypeSymbol: FirClassLikeSymbol<*>, + resultingMap: MutableMap, List> ): AbstractTypeCheckerContext.SupertypesPolicy { - val supertypeSymbol = (supertype as ConeClassLikeType).lookupTag.toSymbol(session) as ConeClassLikeSymbol + val supertypeSymbol = (supertype as ConeClassLikeType).lookupTag.toSymbol(session) as FirClassLikeSymbol<*> val captured = context.captureFromArguments(supertype, CaptureStatus.FOR_SUBTYPING) as ConeClassLikeType? ?: supertype if (supertypeSymbol != subtypeSymbol) { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirBackingFieldReference.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirBackingFieldReference.kt index e5cf307f463..c16ef3354a5 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirBackingFieldReference.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirBackingFieldReference.kt @@ -14,7 +14,7 @@ interface FirBackingFieldReference : FirResolvedCallableReference { override val name: Name get() = NAME - override val coneSymbol: FirBackingFieldSymbol + override val resolvedSymbol: FirBackingFieldSymbol override fun accept(visitor: FirVisitor, data: D): R { return visitor.visitBackingFieldReference(this, data) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirDelegateFieldReference.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirDelegateFieldReference.kt index 15b36b0672c..c08d8a564df 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirDelegateFieldReference.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirDelegateFieldReference.kt @@ -14,7 +14,7 @@ interface FirDelegateFieldReference : FirResolvedCallableReference { override val name: Name get() = NAME - override val coneSymbol: FirDelegateFieldSymbol<*> + override val resolvedSymbol: FirDelegateFieldSymbol<*> override fun accept(visitor: FirVisitor, data: D): R = visitor.visitDelegateFieldReference(this, data) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirNamedReference.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirNamedReference.kt index 6401ae6a5c4..0b431edc66d 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirNamedReference.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirNamedReference.kt @@ -5,7 +5,7 @@ package org.jetbrains.kotlin.fir -import org.jetbrains.kotlin.fir.symbols.ConeSymbol +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.visitors.FirVisitor import org.jetbrains.kotlin.name.Name @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.name.Name interface FirNamedReference : FirReference { val name: Name - val candidateSymbol: ConeSymbol? get() = null + val candidateSymbol: AbstractFirBasedSymbol<*>? get() = null override fun accept(visitor: FirVisitor, data: D): R = visitor.visitNamedReference(this, data) 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 2081492e889..fa85c006044 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -13,6 +13,8 @@ import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.impl.* import org.jetbrains.kotlin.fir.references.FirErrorNamedReference import org.jetbrains.kotlin.fir.symbols.* +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.fir.types.* @@ -752,12 +754,12 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { print("*") } - private fun ConeSymbol.render(): String { - if (this is ConeCallableSymbol) - return callableId.toString() - else if (this is ConeClassLikeSymbol) - return classId.toString() - return "?" + private fun AbstractFirBasedSymbol<*>.render(): String { + return when (this) { + is FirCallableSymbol<*> -> callableId.toString() + is FirClassLikeSymbol<*> -> classId.toString() + else -> "?" + } } override fun visitNamedReference(namedReference: FirNamedReference) { @@ -773,24 +775,24 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { override fun visitBackingFieldReference(backingFieldReference: FirBackingFieldReference) { print("F|") - print(backingFieldReference.coneSymbol.callableId) + print(backingFieldReference.resolvedSymbol.callableId) print("|") } override fun visitDelegateFieldReference(delegateFieldReference: FirDelegateFieldReference) { print("D|") - print(delegateFieldReference.coneSymbol.callableId) + print(delegateFieldReference.resolvedSymbol.callableId) print("|") } override fun visitResolvedCallableReference(resolvedCallableReference: FirResolvedCallableReference) { print("R|") - val isFakeOverride = (resolvedCallableReference.coneSymbol as? FirNamedFunctionSymbol)?.isFakeOverride == true + val isFakeOverride = (resolvedCallableReference.resolvedSymbol as? FirNamedFunctionSymbol)?.isFakeOverride == true if (isFakeOverride) { print("FakeOverride<") } - val symbol = resolvedCallableReference.coneSymbol + val symbol = resolvedCallableReference.resolvedSymbol print(symbol.render()) if (isFakeOverride) { when (symbol) { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirResolvedCallableReference.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirResolvedCallableReference.kt index 84baae15e42..d90d4613f40 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirResolvedCallableReference.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirResolvedCallableReference.kt @@ -5,11 +5,11 @@ package org.jetbrains.kotlin.fir -import org.jetbrains.kotlin.fir.symbols.ConeSymbol +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.visitors.FirVisitor interface FirResolvedCallableReference : FirNamedReference { - val coneSymbol: ConeSymbol + val resolvedSymbol: AbstractFirBasedSymbol<*> override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvedCallableReference(this, data) 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 index a58aa7bd65d..69de6b0b990 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirClassLikeDeclaration.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirClassLikeDeclaration.kt @@ -7,11 +7,8 @@ package org.jetbrains.kotlin.fir.declarations import org.jetbrains.kotlin.fir.VisitedSupertype import org.jetbrains.kotlin.fir.expressions.FirStatement -import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol import org.jetbrains.kotlin.fir.visitors.FirVisitor interface FirClassLikeDeclaration> : @@ -33,9 +30,3 @@ interface FirClassLikeDeclaration> : var supertypesComputationStatus: SupertypesComputationStatus } -fun ConeClassifierSymbol.toFirClassLike(): FirClassLikeDeclaration<*>? = - when (this) { - is FirClassSymbol -> this.fir - is FirTypeAliasSymbol -> this.fir - else -> null - } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirExpression.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirExpression.kt index 757d491ea2d..f60f5f2b1e0 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirExpression.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirExpression.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.fir.expressions import com.intellij.psi.PsiElement import org.jetbrains.kotlin.fir.FirResolvedCallableReference import org.jetbrains.kotlin.fir.expressions.impl.FirAnnotatedStatement -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.FirVisitor @@ -33,6 +33,6 @@ fun FirExpression.toResolvedCallableReference(): FirResolvedCallableReference? { } -fun FirExpression.toResolvedCallableSymbol(): ConeCallableSymbol? { - return toResolvedCallableReference()?.coneSymbol as ConeCallableSymbol? +fun FirExpression.toResolvedCallableSymbol(): FirCallableSymbol<*>? { + return toResolvedCallableReference()?.resolvedSymbol as FirCallableSymbol<*>? } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirBackingFieldReferenceImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirBackingFieldReferenceImpl.kt index f31f37d3b63..b464697168c 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirBackingFieldReferenceImpl.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirBackingFieldReferenceImpl.kt @@ -12,5 +12,5 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirBackingFieldSymbol class FirBackingFieldReferenceImpl( psi: PsiElement?, - override val coneSymbol: FirBackingFieldSymbol + override val resolvedSymbol: FirBackingFieldSymbol ) : FirAbstractElement(psi), FirBackingFieldReference \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirDelegateFieldReferenceImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirDelegateFieldReferenceImpl.kt index ffefac60b31..d00c26929ba 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirDelegateFieldReferenceImpl.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirDelegateFieldReferenceImpl.kt @@ -12,5 +12,5 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol class FirDelegateFieldReferenceImpl( psi: PsiElement?, - override val coneSymbol: FirDelegateFieldSymbol<*> + override val resolvedSymbol: FirDelegateFieldSymbol<*> ) : FirAbstractElement(psi), FirDelegateFieldReference \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirPropertyFromParameterCallableReference.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirPropertyFromParameterCallableReference.kt index ffd0b004116..11cb73b83b5 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirPropertyFromParameterCallableReference.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirPropertyFromParameterCallableReference.kt @@ -14,5 +14,5 @@ import org.jetbrains.kotlin.name.Name class FirPropertyFromParameterCallableReference( psi: PsiElement?, override val name: Name, - override val coneSymbol: FirVariableSymbol<*> + override val resolvedSymbol: FirVariableSymbol<*> ) : FirAbstractElement(psi), FirResolvedCallableReference \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirResolvedCallableReferenceImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirResolvedCallableReferenceImpl.kt index 2e34282a32e..6bbf29341c1 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirResolvedCallableReferenceImpl.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirResolvedCallableReferenceImpl.kt @@ -8,11 +8,11 @@ package org.jetbrains.kotlin.fir.references import com.intellij.psi.PsiElement import org.jetbrains.kotlin.fir.FirAbstractElement import org.jetbrains.kotlin.fir.FirResolvedCallableReference -import org.jetbrains.kotlin.fir.symbols.ConeSymbol +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.name.Name class FirResolvedCallableReferenceImpl( psi: PsiElement?, override val name: Name, - override val coneSymbol: ConeSymbol + override val resolvedSymbol: AbstractFirBasedSymbol<*> ) : FirAbstractElement(psi), FirResolvedCallableReference \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt index 1111b94d0e3..bb5ffedae7f 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt @@ -7,8 +7,8 @@ package org.jetbrains.kotlin.fir.scopes import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NEXT import org.jetbrains.kotlin.fir.scopes.ProcessorAction.STOP -import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.name.Name @@ -20,7 +20,7 @@ abstract class FirScope { open fun processClassifiersByName( name: Name, position: FirPosition, - processor: (ConeClassifierSymbol) -> Boolean + processor: (FirClassifierSymbol<*>) -> Boolean ): Boolean = true open fun processFunctionsByName( @@ -39,7 +39,7 @@ abstract class FirScope { inline fun FirScope.processClassifiersByNameWithAction( name: Name, position: FirPosition, - crossinline processor: (ConeClassifierSymbol) -> ProcessorAction + crossinline processor: (FirClassifierSymbol<*>) -> ProcessorAction ): ProcessorAction { val result = processClassifiersByName(name, position) { processor(it).next() diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/ConeClassifierLookupTagWithFixedSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/ConeClassifierLookupTagWithFixedSymbol.kt new file mode 100644 index 00000000000..90cef84f5e6 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/ConeClassifierLookupTagWithFixedSymbol.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2010-2019 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.symbols + +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol + +abstract class ConeClassifierLookupTagWithFixedSymbol : ConeClassifierLookupTag() { + abstract val symbol: FirClassifierSymbol<*> +} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/ConeTypeParameterLookupTag.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/ConeTypeParameterLookupTag.kt new file mode 100644 index 00000000000..7e555e0853f --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/ConeTypeParameterLookupTag.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2010-2019 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.symbols + +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol +import org.jetbrains.kotlin.name.Name + +data class ConeTypeParameterLookupTag(val typeParameterSymbol: FirTypeParameterSymbol) : ConeClassifierLookupTagWithFixedSymbol() { + override val name: Name get() = typeParameterSymbol.name + override val symbol: FirClassifierSymbol<*> + get() = typeParameterSymbol + +} + diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/FirBasedSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/FirBasedSymbol.kt index 773fcc8a117..62f69b1d59a 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/FirBasedSymbol.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/FirBasedSymbol.kt @@ -5,9 +5,10 @@ package org.jetbrains.kotlin.fir.symbols -import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.types.model.TypeConstructorMarker -interface FirBasedSymbol : ConeSymbol where E : FirElement, E : FirSymbolOwner { +interface FirBasedSymbol : TypeConstructorMarker where E : FirDeclaration, E : FirSymbolOwner { val fir: E fun bind(e: E) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/FirSymbolOwner.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/FirSymbolOwner.kt index 8ca684770dc..9fd3bdcb119 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/FirSymbolOwner.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/FirSymbolOwner.kt @@ -5,8 +5,8 @@ package org.jetbrains.kotlin.fir.symbols -import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.declarations.FirDeclaration -interface FirSymbolOwner where E : FirElement, E : FirSymbolOwner { +interface FirSymbolOwner where E : FirDeclaration, E : FirSymbolOwner { val symbol: FirBasedSymbol } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/ConeClassLikeLookupTagImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/ConeClassLikeLookupTagImpl.kt new file mode 100644 index 00000000000..aa50b986d81 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/ConeClassLikeLookupTagImpl.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2019 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.symbols.impl + +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag +import org.jetbrains.kotlin.name.ClassId + +class ConeClassLikeLookupTagImpl(override val classId: ClassId) : ConeClassLikeLookupTag() { + var boundSymbol: Pair<*, FirClassifierSymbol<*>?>? = null + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as ConeClassLikeLookupTagImpl + + if (classId != other.classId) return false + + return true + } + + override fun hashCode(): Int { + return classId.hashCode() + } +} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt index c6a20e35f65..f96c0d2f24b 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirCallableSymbol.kt @@ -7,6 +7,8 @@ package org.jetbrains.kotlin.fir.symbols.impl import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol +import org.jetbrains.kotlin.fir.symbols.CallableId -abstract class FirCallableSymbol> : ConeCallableSymbol, AbstractFirBasedSymbol() +abstract class FirCallableSymbol> : AbstractFirBasedSymbol() { + abstract val callableId: CallableId +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassLikeSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassLikeSymbol.kt index 522a78366b2..e9fe5c5f72d 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassLikeSymbol.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassLikeSymbol.kt @@ -12,19 +12,21 @@ import org.jetbrains.kotlin.fir.symbols.* import org.jetbrains.kotlin.name.ClassId sealed class FirClassLikeSymbol>( - override val classId: ClassId -) : ConeClassLikeSymbol, AbstractFirBasedSymbol() { + val classId: ClassId +) : FirClassifierSymbol() { + abstract override fun toLookupTag(): ConeClassLikeLookupTag + override fun equals(other: Any?): Boolean = other is FirClassLikeSymbol<*> && fir == other.fir override fun hashCode(): Int = fir.hashCode() } -class FirClassSymbol(classId: ClassId) : FirClassLikeSymbol(classId), ConeClassSymbol { +class FirClassSymbol(classId: ClassId) : FirClassLikeSymbol(classId) { override fun toLookupTag(): ConeClassLikeLookupTag = ConeClassLikeLookupTagImpl(classId) } -class FirTypeAliasSymbol(override val classId: ClassId) : FirClassLikeSymbol(classId), ConeTypeAliasSymbol { +class FirTypeAliasSymbol(classId: ClassId) : FirClassLikeSymbol(classId) { override fun toLookupTag(): TypeAliasLookupTagImpl = TypeAliasLookupTagImpl(classId) } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassifierSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassifierSymbol.kt new file mode 100644 index 00000000000..43fc36df8bf --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirClassifierSymbol.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2010-2019 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.symbols.impl + +import org.jetbrains.kotlin.fir.declarations.FirNamedDeclaration +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTag +import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner +import org.jetbrains.kotlin.types.model.TypeParameterMarker + +abstract class FirClassifierSymbol : + AbstractFirBasedSymbol(), TypeParameterMarker where E : FirNamedDeclaration, E : FirSymbolOwner { + abstract fun toLookupTag(): ConeClassifierLookupTag +} \ No newline at end of file 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 feffe2b2510..c2f41c50ebf 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 @@ -8,16 +8,14 @@ package org.jetbrains.kotlin.fir.symbols.impl import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.impl.FirErrorFunction import org.jetbrains.kotlin.fir.symbols.CallableId -import org.jetbrains.kotlin.fir.symbols.ConeFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.ConePropertySymbol import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name sealed class FirFunctionSymbol>( override val callableId: CallableId -) : ConeFunctionSymbol, FirCallableSymbol() { - override val parameters: List +) : FirCallableSymbol() { + open val parameters: List get() = emptyList() } @@ -37,7 +35,7 @@ class FirConstructorSymbol( class FirAccessorSymbol( callableId: CallableId, val accessorId: CallableId -) : ConePropertySymbol, FirFunctionSymbol(callableId) +) : FirFunctionSymbol(callableId) // ------------------------ unnamed ------------------------ 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 deleted file mode 100644 index 5147b31cf7c..00000000000 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirTypeAliasSymbol.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2010-2018 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.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 - 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 0d19e6988cd..f8fa75f86f9 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,12 +6,12 @@ package org.jetbrains.kotlin.fir.symbols.impl import org.jetbrains.kotlin.fir.declarations.FirTypeParameter -import org.jetbrains.kotlin.fir.symbols.* +import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag import org.jetbrains.kotlin.name.Name -class FirTypeParameterSymbol : AbstractFirBasedSymbol(), ConeTypeParameterSymbol { +class FirTypeParameterSymbol : FirClassifierSymbol() { - override val name: Name + val name: Name get() = fir.name private val lookupTag = ConeTypeParameterLookupTag(this) @@ -26,3 +26,4 @@ class FirTypeParameterSymbol : AbstractFirBasedSymbol(), ConeT return fir.hashCode() } } + diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirVariableSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirVariableSymbol.kt index 8df35e7cfc4..64968e22e60 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirVariableSymbol.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirVariableSymbol.kt @@ -10,11 +10,9 @@ import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirVariable import org.jetbrains.kotlin.fir.symbols.CallableId -import org.jetbrains.kotlin.fir.symbols.ConePropertySymbol -import org.jetbrains.kotlin.fir.symbols.ConeVariableSymbol import org.jetbrains.kotlin.name.Name -open class FirVariableSymbol>(override val callableId: CallableId) : ConeVariableSymbol, FirCallableSymbol() { +open class FirVariableSymbol>(override val callableId: CallableId) : FirCallableSymbol() { @Deprecated("TODO: Better solution for local vars?") constructor(name: Name) : this(CallableId(name)) // TODO? @@ -25,7 +23,7 @@ open class FirPropertySymbol( val isFakeOverride: Boolean = false, // Actual for fake override only val overriddenSymbol: FirPropertySymbol? = null -) : ConePropertySymbol, FirVariableSymbol(callableId) +) : FirVariableSymbol(callableId) class FirBackingFieldSymbol(callableId: CallableId) : FirVariableSymbol(callableId) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/ConeTypeParameterType.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/ConeTypeParameterType.kt new file mode 100644 index 00000000000..711a9238049 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/ConeTypeParameterType.kt @@ -0,0 +1,13 @@ +/* + * Copyright 2010-2019 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.types + +import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag + +abstract class ConeTypeParameterType : ConeLookupTagBasedType() { + abstract override val lookupTag: ConeTypeParameterLookupTag +} + diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/ConeTypeParameterTypeImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/ConeTypeParameterTypeImpl.kt new file mode 100644 index 00000000000..9f310b9be28 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/ConeTypeParameterTypeImpl.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2019 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.types.impl + +import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag +import org.jetbrains.kotlin.fir.types.ConeKotlinTypeProjection +import org.jetbrains.kotlin.fir.types.ConeNullability +import org.jetbrains.kotlin.fir.types.ConeTypeParameterType + +class ConeTypeParameterTypeImpl( + override val lookupTag: ConeTypeParameterLookupTag, + isNullable: Boolean +) : ConeTypeParameterType() { + override val typeArguments: Array + get() = EMPTY_ARRAY + + override val nullability: ConeNullability = ConeNullability.create(isNullable) + + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as ConeTypeParameterTypeImpl + + if (lookupTag != other.lookupTag) return false + if (nullability != other.nullability) return false + + return true + } + + override fun hashCode(): Int { + var result = lookupTag.hashCode() + result = 31 * result + nullability.hashCode() + return result + } + +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt index e560c6a2694..42dbcd62063 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt @@ -8,8 +8,8 @@ package org.jetbrains.kotlin.fir.types.impl import com.intellij.psi.PsiElement import org.jetbrains.kotlin.fir.FirAbstractElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.types.ConeClassLikeType import org.jetbrains.kotlin.fir.types.ConeKotlinTypeProjection import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef diff --git a/compiler/visualizer/render-fir/src/org/jetbrains/kotlin/compiler/visualizer/FirVisualizer.kt b/compiler/visualizer/render-fir/src/org/jetbrains/kotlin/compiler/visualizer/FirVisualizer.kt index 4a68ef728bd..c7e70dfbe8e 100644 --- a/compiler/visualizer/render-fir/src/org/jetbrains/kotlin/compiler/visualizer/FirVisualizer.kt +++ b/compiler/visualizer/render-fir/src/org/jetbrains/kotlin/compiler/visualizer/FirVisualizer.kt @@ -20,13 +20,8 @@ import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.resolve.directExpansionType import org.jetbrains.kotlin.fir.resolve.transformers.firSafeNullable import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe -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.fir.symbols.impl.FirConstructorSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.fir.visitors.FirVisitor @@ -372,7 +367,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() { } override fun visitResolvedCallableReference(resolvedCallableReference: FirResolvedCallableReference, data: StringBuilder) { - val symbol = resolvedCallableReference.coneSymbol + val symbol = resolvedCallableReference.resolvedSymbol data.append(renderSymbol(symbol)) } @@ -408,17 +403,17 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() { override fun visitFunctionCall(functionCall: FirFunctionCall, data: StringBuilder) { when (val callee = functionCall.calleeReference) { is FirResolvedCallableReference -> { - if (callee.coneSymbol is FirConstructorSymbol) { - data.append(renderSymbol(callee.coneSymbol)) + if (callee.resolvedSymbol is FirConstructorSymbol) { + data.append(renderSymbol(callee.resolvedSymbol)) visitArguments(functionCall.arguments, data) } else { data.append("fun ") - val firFunction = callee.coneSymbol.firSafeNullable() + val firFunction = callee.resolvedSymbol.firSafeNullable() firFunction?.let { renderListInTriangles(it.typeParameters, data, true) } - data.append(renderSymbol(callee.coneSymbol)) + data.append(renderSymbol(callee.resolvedSymbol)) renderListInTriangles(functionCall.typeArguments, data) - visitValueParameters(callee.coneSymbol.firUnsafe>().valueParameters, data) + visitValueParameters(callee.resolvedSymbol.firUnsafe>().valueParameters, data) data.append(": ") functionCall.typeRef.accept(this, data) } @@ -496,15 +491,15 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() { } } - private fun renderSymbol(symbol: ConeSymbol?): String { + private fun renderSymbol(symbol: AbstractFirBasedSymbol<*>?): String { val data = StringBuilder() var id = when (symbol) { - is ConeCallableSymbol -> { + is FirCallableSymbol<*> -> { val callableId = symbol.callableId val idWithPackage = callableId.toString().replace("." + callableId.callableName.asString(), "") removeCurrentFilePackage(idWithPackage) } - is ConeClassLikeSymbol -> symbol.classId.getWithoutCurrentPackage() + is FirClassLikeSymbol<*> -> symbol.classId.getWithoutCurrentPackage() else -> "" } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/fir/IdeFirProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/fir/IdeFirProvider.kt index 6b2231911c5..de8f783abeb 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/fir/IdeFirProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/fir/IdeFirProvider.kt @@ -15,7 +15,6 @@ import org.jetbrains.kotlin.fir.resolve.FirProvider import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.impl.FirProviderImpl import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.idea.stubindex.* @@ -77,7 +76,7 @@ class IdeFirProvider( return cacheProvider.getFirClassifierContainerFile(fqName) } - override fun getFirCallableContainerFile(symbol: ConeCallableSymbol): FirFile? { + override fun getFirCallableContainerFile(symbol: FirCallableSymbol<*>): FirFile? { return cacheProvider.getFirCallableContainerFile(symbol) }