FIR: replace ConeKotlinType with more concrete type when possible
This commit is contained in:
committed by
TeamCityServer
parent
27d4c745cb
commit
11bbd79c4b
+1
-1
@@ -183,7 +183,7 @@ object FirJavaGenericVarianceViolationTypeChecker : FirFunctionCallChecker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeInferenceContext.isTypeConstructorEqualOrSubClassOf(subType: ConeKotlinType, superType: ConeKotlinType): Boolean {
|
private fun ConeInferenceContext.isTypeConstructorEqualOrSubClassOf(subType: ConeKotlinType, superType: ConeSimpleKotlinType): Boolean {
|
||||||
return isTypeConstructorEqualOrSubClassOf(subType.typeConstructor(), superType.typeConstructor())
|
return isTypeConstructorEqualOrSubClassOf(subType.typeConstructor(), superType.typeConstructor())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -83,8 +83,8 @@ fun checkCasting(
|
|||||||
* (i.e. java.lang.String -> kotlin.String) and ignore mappings that go the other way.
|
* (i.e. java.lang.String -> kotlin.String) and ignore mappings that go the other way.
|
||||||
*/
|
*/
|
||||||
private fun isRelated(
|
private fun isRelated(
|
||||||
aType: ConeKotlinType,
|
aType: ConeSimpleKotlinType,
|
||||||
bType: ConeKotlinType,
|
bType: ConeSimpleKotlinType,
|
||||||
aClassSymbol: FirRegularClassSymbol?,
|
aClassSymbol: FirRegularClassSymbol?,
|
||||||
bClassSymbol: FirRegularClassSymbol?,
|
bClassSymbol: FirRegularClassSymbol?,
|
||||||
context: CheckerContext
|
context: CheckerContext
|
||||||
@@ -97,7 +97,7 @@ private fun isRelated(
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCorrespondingKotlinClass(type: ConeKotlinType): ConeKotlinType {
|
fun getCorrespondingKotlinClass(type: ConeSimpleKotlinType): ConeKotlinType {
|
||||||
return context.session.platformClassMapper.getCorrespondingKotlinClass(type.classId)?.defaultType(listOf()) ?: type
|
return context.session.platformClassMapper.getCorrespondingKotlinClass(type.classId)?.defaultType(listOf()) ?: type
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ private fun isRelated(
|
|||||||
AbstractTypeChecker.isSubtypeOf(typeContext, bNormalizedType, aNormalizedType)
|
AbstractTypeChecker.isSubtypeOf(typeContext, bNormalizedType, aNormalizedType)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isFinal(type: ConeKotlinType, session: FirSession): Boolean {
|
private fun isFinal(type: ConeSimpleKotlinType, session: FirSession): Boolean {
|
||||||
return !type.canHaveSubtypes(session)
|
return !type.canHaveSubtypes(session)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ fun shouldCheckForExactType(expression: FirTypeOperatorCall, context: CheckerCon
|
|||||||
|
|
||||||
fun isRefinementUseless(
|
fun isRefinementUseless(
|
||||||
context: CheckerContext,
|
context: CheckerContext,
|
||||||
candidateType: ConeKotlinType,
|
candidateType: ConeSimpleKotlinType,
|
||||||
targetType: ConeKotlinType,
|
targetType: ConeKotlinType,
|
||||||
shouldCheckForExactType: Boolean,
|
shouldCheckForExactType: Boolean,
|
||||||
arg: FirExpression,
|
arg: FirExpression,
|
||||||
@@ -292,7 +292,7 @@ fun isRefinementUseless(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isExactTypeCast(context: CheckerContext, candidateType: ConeKotlinType, targetType: ConeKotlinType): Boolean {
|
private fun isExactTypeCast(context: CheckerContext, candidateType: ConeSimpleKotlinType, targetType: ConeKotlinType): Boolean {
|
||||||
if (!AbstractTypeChecker.equalTypes(context.session.typeContext, candidateType, targetType, stubTypesEqualToAnything = false))
|
if (!AbstractTypeChecker.equalTypes(context.session.typeContext, candidateType, targetType, stubTypesEqualToAnything = false))
|
||||||
return false
|
return false
|
||||||
// See comments at [isUpcast] why we need to check the existence of @ExtensionFunctionType
|
// See comments at [isUpcast] why we need to check the existence of @ExtensionFunctionType
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ abstract class AbstractDiagnosticCollectorVisitor(
|
|||||||
visitJump(continueExpression)
|
visitJump(continueExpression)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun visitClassAndChildren(klass: FirClass, type: ConeKotlinType) {
|
private fun visitClassAndChildren(klass: FirClass, type: ConeClassLikeType) {
|
||||||
val typeRef = buildResolvedTypeRef {
|
val typeRef = buildResolvedTypeRef {
|
||||||
this.type = type
|
this.type = type
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -139,7 +139,7 @@ internal class KClassValue(value: Value) : ConstantValue<KClassValue.Value>(valu
|
|||||||
is Value.NormalClass -> {
|
is Value.NormalClass -> {
|
||||||
val (classId, arrayDimensions) = value.value
|
val (classId, arrayDimensions) = value.value
|
||||||
val klass = session.symbolProvider.getClassLikeSymbolByClassId(classId)?.fir as? FirRegularClass ?: return null
|
val klass = session.symbolProvider.getClassLikeSymbolByClassId(classId)?.fir as? FirRegularClass ?: return null
|
||||||
var type: ConeKotlinType = klass.defaultType().replaceArgumentsWithStarProjections()
|
var type: ConeClassLikeType = klass.defaultType().replaceArgumentsWithStarProjections()
|
||||||
repeat(arrayDimensions) {
|
repeat(arrayDimensions) {
|
||||||
type = type.createArrayType()
|
type = type.createArrayType()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ class Fir2IrTypeConverter(
|
|||||||
return classIdToSymbolMap[classId] ?: getArrayClassSymbol(classId)
|
return classIdToSymbolMap[classId] ?: getArrayClassSymbol(classId)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun approximateType(type: ConeKotlinType): ConeKotlinType {
|
private fun approximateType(type: ConeSimpleKotlinType): ConeKotlinType {
|
||||||
if (type is ConeClassLikeType && type.typeArguments.isEmpty()) return type
|
if (type is ConeClassLikeType && type.typeArguments.isEmpty()) return type
|
||||||
val substitutor = object : AbstractConeSubstitutor(session.typeContext) {
|
val substitutor = object : AbstractConeSubstitutor(session.typeContext) {
|
||||||
override fun substituteType(type: ConeKotlinType): ConeKotlinType? {
|
override fun substituteType(type: ConeKotlinType): ConeKotlinType? {
|
||||||
|
|||||||
@@ -61,17 +61,6 @@ fun collectSymbolsForType(type: ConeKotlinType, useSiteSession: FirSession): Lis
|
|||||||
return lookupTags.mapNotNull { it.toSymbol(useSiteSession) as? FirClassSymbol<*> }
|
return lookupTags.mapNotNull { it.toSymbol(useSiteSession) as? FirClassSymbol<*> }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun lookupSuperTypes(
|
|
||||||
type: ConeKotlinType,
|
|
||||||
lookupInterfaces: Boolean,
|
|
||||||
deep: Boolean,
|
|
||||||
useSiteSession: FirSession,
|
|
||||||
substituteTypes: Boolean,
|
|
||||||
supertypeSupplier: SupertypeSupplier = SupertypeSupplier.Default,
|
|
||||||
): List<ConeClassLikeType> {
|
|
||||||
return lookupSuperTypes(collectSymbolsForType(type, useSiteSession), lookupInterfaces, deep, useSiteSession, substituteTypes, supertypeSupplier)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun lookupSuperTypes(
|
fun lookupSuperTypes(
|
||||||
symbols: List<FirClassifierSymbol<*>>,
|
symbols: List<FirClassifierSymbol<*>>,
|
||||||
lookupInterfaces: Boolean,
|
lookupInterfaces: Boolean,
|
||||||
|
|||||||
@@ -22,11 +22,8 @@ import org.jetbrains.kotlin.fir.scopes.FirTypeScope
|
|||||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
|
||||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||||
import org.jetbrains.kotlin.fir.types.coneType
|
|
||||||
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
|
||||||
import org.jetbrains.kotlin.types.SmartcastStability
|
import org.jetbrains.kotlin.types.SmartcastStability
|
||||||
|
|
||||||
interface Receiver
|
interface Receiver
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ class FirDelegatedPropertyInferenceSession(
|
|||||||
private val currentConstraintSystem = components.session.inferenceComponents.createConstraintSystem()
|
private val currentConstraintSystem = components.session.inferenceComponents.createConstraintSystem()
|
||||||
override val currentConstraintStorage: ConstraintStorage get() = currentConstraintSystem.currentStorage()
|
override val currentConstraintStorage: ConstraintStorage get() = currentConstraintSystem.currentStorage()
|
||||||
|
|
||||||
private val unitType: ConeKotlinType = components.session.builtinTypes.unitType.type
|
private val unitType: ConeClassLikeType = components.session.builtinTypes.unitType.type
|
||||||
private lateinit var resultingConstraintSystem: NewConstraintSystem
|
private lateinit var resultingConstraintSystem: NewConstraintSystem
|
||||||
|
|
||||||
private fun ConeKotlinType.containsStubType(): Boolean {
|
private fun ConeKotlinType.containsStubType(): Boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user