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