Remove a couple of usages of KotlinBuiltIns.getInstance()

This commit is contained in:
Pavel V. Talanov
2015-04-28 13:31:28 +03:00
parent 7d28f8d2cf
commit 032846aba0
2 changed files with 7 additions and 6 deletions
@@ -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));
}
@@ -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<T>(
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? {