FIR: Use NullableAny as a default bound

This commit is contained in:
Denis.Zharkov
2022-04-11 18:31:08 +03:00
committed by teamcity
parent 934b8c890e
commit 853b7ec078
2 changed files with 4 additions and 3 deletions
@@ -176,7 +176,7 @@ object FirJavaGenericVarianceViolationTypeChecker : FirFunctionCallChecker() {
return when (this) {
is ConeKotlinTypeProjectionOut -> if (isCovariant) type else this
is ConeKotlinTypeProjectionIn -> ConeKotlinTypeProjectionIn(type.removeOutProjection(!isCovariant))
is ConeStarProjection -> if (isCovariant) StandardTypes.Any else this
is ConeStarProjection -> if (isCovariant) StandardTypes.NullableAny else this
// Don't remove nested projections for types at invariant position.
is ConeKotlinTypeConflictingProjection,
is ConeKotlinType -> this
@@ -25,10 +25,11 @@ object StandardTypes {
val Double: ConeClassLikeType = StandardClassIds.Double.createType()
val Any: ConeClassLikeType = StandardClassIds.Any.createType()
val NullableAny: ConeClassLikeType = StandardClassIds.Any.createType(isNullable = true)
}
private fun ClassId.createType(): ConeClassLikeType =
ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(this), emptyArray(), isNullable = false)
private fun ClassId.createType(isNullable: Boolean = false): ConeClassLikeType =
ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(this), emptyArray(), isNullable)
fun ConeClassLikeType.isDouble(): Boolean = lookupTag.classId == StandardClassIds.Double
fun ConeClassLikeType.isFloat(): Boolean = lookupTag.classId == StandardClassIds.Float