[FIR] Remove incorrect FirClassSymbol<*>.superConeTypes utility

Replace all usages with member `FirClassSymbol.resolvedSuperTypes`
This commit is contained in:
Dmitriy Novozhilov
2022-08-24 10:59:02 +03:00
committed by teamcity
parent 6ef3d1e573
commit 194741b96b
7 changed files with 12 additions and 25 deletions
@@ -48,7 +48,7 @@ internal class KtFirExpressionTypeProvider(
val containingClass =
(fir.dispatchReceiver as? FirThisReceiverExpression)?.calleeReference?.boundSymbol as? FirClassSymbol<*>
if (fir.calleeReference is FirSuperReference && fir.typeRef is FirErrorTypeRef && containingClass != null) {
val superTypes = containingClass.superConeTypes
val superTypes = containingClass.resolvedSuperTypes
when (superTypes.size) {
0 -> analysisSession.builtinTypes.ANY
1 -> superTypes.single().asKtType()
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.fir.analysis.checkers.ConeTypeCompatibilityChecker.i
import org.jetbrains.kotlin.fir.analysis.checkers.typeParameterSymbols
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
import org.jetbrains.kotlin.fir.declarations.fullyExpandedClass
import org.jetbrains.kotlin.fir.declarations.utils.superConeTypes
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
import org.jetbrains.kotlin.fir.expressions.FirGetClassCall
@@ -147,9 +146,9 @@ internal class KtFirTypeProvider(
val session = analysisSession.firResolveSession.useSiteFirSession
val symbol = lookupTag.toSymbol(session)
val superTypes = when (symbol) {
is FirAnonymousObjectSymbol -> symbol.superConeTypes
is FirRegularClassSymbol -> symbol.superConeTypes
is FirTypeAliasSymbol -> symbol.fullyExpandedClass(session)?.superConeTypes ?: return emptySequence()
is FirAnonymousObjectSymbol -> symbol.resolvedSuperTypes
is FirRegularClassSymbol -> symbol.resolvedSuperTypes
is FirTypeAliasSymbol -> symbol.fullyExpandedClass(session)?.resolvedSuperTypes ?: return emptySequence()
is FirTypeParameterSymbol -> symbol.resolvedBounds.map { it.type }
else -> return emptySequence()
}
@@ -440,7 +440,7 @@ object ConeTypeCompatibilityChecker {
val isInterface: Boolean get() = firClass.isInterface
val superClasses: Set<FirClassWithSuperClasses> by lazy {
firClass.superConeTypes.mapNotNull { it.lookupTag.toFirClassWithSuperClasses(ctx) }.toSet()
firClass.resolvedSuperTypes.mapNotNull { (it as? ConeClassLikeType)?.lookupTag?.toFirClassWithSuperClasses(ctx) }.toSet()
}
@OptIn(ExperimentalStdlibApi::class)
@@ -6,19 +6,17 @@
package org.jetbrains.kotlin.fir.analysis.checkers.expression
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.diagnostics.reportOn
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.diagnostics.reportOn
import org.jetbrains.kotlin.fir.analysis.getChild
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
import org.jetbrains.kotlin.fir.declarations.FirFunction
import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction
import org.jetbrains.kotlin.fir.declarations.getAnnotationByClassId
import org.jetbrains.kotlin.fir.declarations.utils.isSuspend
import org.jetbrains.kotlin.fir.declarations.utils.superConeTypes
import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference
@@ -31,11 +29,8 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.CallableId
import org.jetbrains.kotlin.name.StandardClassIds
import org.jetbrains.kotlin.psi
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
import org.jetbrains.kotlin.utils.addToStdlib.lastIsInstanceOrNull
@@ -197,7 +192,7 @@ object FirSuspendCallChecker : FirQualifiedAccessExpressionChecker() {
if (regularClassSymbol.getAnnotationByClassId(StandardClassIds.Annotations.RestrictsSuspension) != null) {
return true
}
return regularClassSymbol.superConeTypes.any { it.isRestrictSuspensionReceiver(session) }
return regularClassSymbol.resolvedSuperTypes.any { it.isRestrictSuspensionReceiver(session) }
}
is ConeTypeParameterType -> {
return lookupTag.typeParameterSymbol.resolvedBounds.any { it.coneType.isRestrictSuspensionReceiver(session) }
@@ -248,4 +243,4 @@ object FirSuspendCallChecker : FirQualifiedAccessExpressionChecker() {
private enum class SuspendCallArgumentKind {
FUN, LAMBDA
}
}
@@ -149,8 +149,8 @@ object FirExpectActualResolver {
// Subtract kotlin.Any from supertypes because it's implicitly added if no explicit supertype is specified,
// and not added if an explicit supertype _is_ specified
val expectSupertypes = expectClassSymbol.superConeTypes.filterNot { it.classId == actualSession.builtinTypes.anyType.id }
val actualSupertypes = actualClass.superConeTypes.filterNot { it.classId == actualSession.builtinTypes.anyType.id }
val expectSupertypes = expectClassSymbol.resolvedSuperTypes.filterNot { it.classId == actualSession.builtinTypes.anyType.id }
val actualSupertypes = actualClass.resolvedSuperTypes.filterNot { it.classId == actualSession.builtinTypes.anyType.id }
if (
expectSupertypes.map(substitutor::substituteOrSelf).any { expectSupertype ->
actualSupertypes.none { actualSupertype ->
@@ -24,12 +24,6 @@ val FirClassLikeDeclaration.classId
val FirClass.classId: ClassId get() = symbol.classId
val FirClassSymbol<*>.superConeTypes: List<ConeClassLikeType>
get() = when (this) {
is FirRegularClassSymbol -> fir.superConeTypes
is FirAnonymousObjectSymbol -> fir.superConeTypes
}
val FirClass.superConeTypes: List<ConeClassLikeType> get() = superTypeRefs.mapNotNull { it.coneTypeSafe() }
val FirClass.anonymousInitializers: List<FirAnonymousInitializer>
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
import org.jetbrains.kotlin.fir.declarations.builder.*
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl
import org.jetbrains.kotlin.fir.declarations.origin
import org.jetbrains.kotlin.fir.declarations.utils.superConeTypes
import org.jetbrains.kotlin.fir.extensions.FirDeclarationGenerationExtension
import org.jetbrains.kotlin.fir.extensions.FirDeclarationPredicateRegistrar
import org.jetbrains.kotlin.fir.extensions.MemberGenerationContext
@@ -100,7 +99,7 @@ class SerializationFirResolveExtension(session: FirSession) : FirDeclarationGene
SerialEntityNames.LOAD_NAME,
SerialEntityNames.SERIAL_DESC_FIELD_NAME
)
if (classSymbol.superConeTypes.any {
if (classSymbol.resolvedSuperTypes.any {
it.classId == ClassId(
SerializationPackages.internalPackageFqName,
SerialEntityNames.GENERATED_SERIALIZER_CLASS