FIR: PrimitiveTypes -> StandardTypes
This commit is contained in:
committed by
TeamCityServer
parent
5a26e79b08
commit
68f14fdd87
+2
-2
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.analysis.jvm.checkers.expression
|
package org.jetbrains.kotlin.fir.analysis.jvm.checkers.expression
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.PrimitiveTypes
|
import org.jetbrains.kotlin.fir.StandardTypes
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker
|
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
||||||
@@ -163,7 +163,7 @@ object FirJavaGenericVarianceViolationTypeChecker : FirFunctionCallChecker() {
|
|||||||
return when (this) {
|
return when (this) {
|
||||||
is ConeKotlinTypeProjectionOut -> if (positive) type else this
|
is ConeKotlinTypeProjectionOut -> if (positive) type else this
|
||||||
is ConeKotlinTypeProjectionIn -> ConeKotlinTypeProjectionIn(type.removeOutProjection(!positive))
|
is ConeKotlinTypeProjectionIn -> ConeKotlinTypeProjectionIn(type.removeOutProjection(!positive))
|
||||||
is ConeStarProjection -> if (positive) PrimitiveTypes.Any else this
|
is ConeStarProjection -> if (positive) StandardTypes.Any else this
|
||||||
// Don't remove nested projections for types at invariant position.
|
// Don't remove nested projections for types at invariant position.
|
||||||
is ConeKotlinTypeConflictingProjection,
|
is ConeKotlinTypeConflictingProjection,
|
||||||
is ConeKotlinType -> this
|
is ConeKotlinType -> this
|
||||||
|
|||||||
@@ -42,17 +42,17 @@ private fun leastCommonPrimitiveNumericType(t1: ConeClassLikeType, t2: ConeClass
|
|||||||
val pt2 = t2.promoteIntegerTypeToIntIfRequired()
|
val pt2 = t2.promoteIntegerTypeToIntIfRequired()
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
pt1.isDouble() || pt2.isDouble() -> PrimitiveTypes.Double
|
pt1.isDouble() || pt2.isDouble() -> StandardTypes.Double
|
||||||
pt1.isFloat() || pt2.isFloat() -> PrimitiveTypes.Float
|
pt1.isFloat() || pt2.isFloat() -> StandardTypes.Float
|
||||||
pt1.isLong() || pt2.isLong() -> PrimitiveTypes.Long
|
pt1.isLong() || pt2.isLong() -> StandardTypes.Long
|
||||||
pt1.isInt() || pt2.isInt() -> PrimitiveTypes.Int
|
pt1.isInt() || pt2.isInt() -> StandardTypes.Int
|
||||||
else -> error("Unexpected types: t1=$t1, t2=$t2")
|
else -> error("Unexpected types: t1=$t1, t2=$t2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeClassLikeType.promoteIntegerTypeToIntIfRequired(): ConeClassLikeType =
|
private fun ConeClassLikeType.promoteIntegerTypeToIntIfRequired(): ConeClassLikeType =
|
||||||
when (lookupTag.classId) {
|
when (lookupTag.classId) {
|
||||||
StandardClassIds.Byte, StandardClassIds.Short -> PrimitiveTypes.Int
|
StandardClassIds.Byte, StandardClassIds.Short -> StandardTypes.Int
|
||||||
StandardClassIds.Long, StandardClassIds.Int, StandardClassIds.Float, StandardClassIds.Double, StandardClassIds.Char -> this
|
StandardClassIds.Long, StandardClassIds.Int, StandardClassIds.Float, StandardClassIds.Double, StandardClassIds.Char -> this
|
||||||
else -> error("Primitive number type expected: $this")
|
else -> error("Primitive number type expected: $this")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
|||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.StandardClassIds
|
import org.jetbrains.kotlin.name.StandardClassIds
|
||||||
|
|
||||||
object PrimitiveTypes {
|
object StandardTypes {
|
||||||
val Boolean: ConeClassLikeType = StandardClassIds.Boolean.createType()
|
val Boolean: ConeClassLikeType = StandardClassIds.Boolean.createType()
|
||||||
val Char: ConeClassLikeType = StandardClassIds.Char.createType()
|
val Char: ConeClassLikeType = StandardClassIds.Char.createType()
|
||||||
val Byte: ConeClassLikeType = StandardClassIds.Byte.createType()
|
val Byte: ConeClassLikeType = StandardClassIds.Byte.createType()
|
||||||
|
|||||||
Reference in New Issue
Block a user