diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java index 98d148bfcff..77839c93515 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java @@ -89,7 +89,7 @@ public class CompileTimeConstantChecker { } if (!noExpectedTypeOrError(expectedType)) { - JetType valueType = value.getType(KotlinBuiltIns.getInstance()); + JetType valueType = value.getType(builtIns); if (!JetTypeChecker.DEFAULT.isSubtypeOf(valueType, expectedType)) { return reportError(CONSTANT_EXPECTED_TYPE_MISMATCH.on(expression, "integer", expectedType)); } @@ -106,7 +106,7 @@ public class CompileTimeConstantChecker { return reportError(FLOAT_LITERAL_OUT_OF_RANGE.on(expression)); } if (!noExpectedTypeOrError(expectedType)) { - JetType valueType = value.getType(KotlinBuiltIns.getInstance()); + JetType valueType = value.getType(builtIns); if (!JetTypeChecker.DEFAULT.isSubtypeOf(valueType, expectedType)) { return reportError(CONSTANT_EXPECTED_TYPE_MISMATCH.on(expression, "floating-point", expectedType)); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt b/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt index c02531b4064..18bd22195c7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.types.LazyType import org.jetbrains.kotlin.resolve.calls.inference.isCaptured +import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns public data class ApproximationBounds( public val lower: T, @@ -56,9 +57,9 @@ private fun TypeArgument.toTypeProjection(): TypeProjection { fun removeProjectionIfRedundant(variance: Variance) = if (variance == typeParameter.getVariance()) Variance.INVARIANT else variance return when { inProjection == outProjection -> TypeProjectionImpl(inProjection) - inProjection == NOTHING && typeParameter.getVariance() != Variance.IN_VARIANCE -> + KotlinBuiltIns.isNothing(inProjection) && typeParameter.getVariance() != Variance.IN_VARIANCE -> TypeProjectionImpl(removeProjectionIfRedundant(Variance.OUT_VARIANCE), outProjection) - outProjection == NULLABLE_ANY -> TypeProjectionImpl(removeProjectionIfRedundant(Variance.IN_VARIANCE), inProjection) + KotlinBuiltIns.isNullableAny(outProjection) -> TypeProjectionImpl(removeProjectionIfRedundant(Variance.IN_VARIANCE), inProjection) else -> TypeProjectionImpl(removeProjectionIfRedundant(Variance.OUT_VARIANCE), outProjection) } } @@ -66,8 +67,8 @@ private fun TypeArgument.toTypeProjection(): TypeProjection { private fun TypeProjection.toTypeArgument(typeParameter: TypeParameterDescriptor) = when (TypeSubstitutor.combine(typeParameter.getVariance(), getProjectionKind()) : Variance) { Variance.INVARIANT -> TypeArgument(typeParameter, getType(), getType()) - Variance.IN_VARIANCE -> TypeArgument(typeParameter, getType(), NULLABLE_ANY) - Variance.OUT_VARIANCE -> TypeArgument(typeParameter, NOTHING, getType()) + Variance.IN_VARIANCE -> TypeArgument(typeParameter, getType(), typeParameter.builtIns.getNullableAnyType()) + Variance.OUT_VARIANCE -> TypeArgument(typeParameter, typeParameter.builtIns.getNothingType(), getType()) } public fun approximateCapturedTypesIfNecessary(typeProjection: TypeProjection?): TypeProjection? {