Refactoring. Remove type capability Flexibility.
This commit is contained in:
+2
-2
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.jvm
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.flexibility
|
||||
import org.jetbrains.kotlin.types.asFlexibleType
|
||||
import org.jetbrains.kotlin.types.isFlexible
|
||||
|
||||
object JvmTypeSpecificityComparator : TypeSpecificityComparator {
|
||||
@@ -28,7 +28,7 @@ object JvmTypeSpecificityComparator : TypeSpecificityComparator {
|
||||
if (!specific.isFlexible() || general.isFlexible()) return false
|
||||
|
||||
// general is inflexible
|
||||
val flexibility = specific.flexibility()
|
||||
val flexibility = specific.asFlexibleType()
|
||||
|
||||
// For primitive types we have to take care of the case when there are two overloaded methods like
|
||||
// foo(int) and foo(Integer)
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.flexibility
|
||||
import org.jetbrains.kotlin.types.asFlexibleType
|
||||
import org.jetbrains.kotlin.types.isFlexible
|
||||
|
||||
class WhenByPlatformEnumChecker : AdditionalTypeChecker {
|
||||
@@ -34,7 +34,7 @@ class WhenByPlatformEnumChecker : AdditionalTypeChecker {
|
||||
if (expression is KtWhenExpression && expression.elseExpression == null) {
|
||||
// Check for conditionally-exhaustive when on platform enums, see KT-6399
|
||||
val type = expression.subjectExpression?.let { c.trace.getType(it) } ?: return
|
||||
if (type.isFlexible() && TypeUtils.isNullableType(type.flexibility().upperBound) && !type.annotations.isMarkedNotNull()) {
|
||||
if (type.isFlexible() && TypeUtils.isNullableType(type.asFlexibleType().upperBound) && !type.annotations.isMarkedNotNull()) {
|
||||
val enumClassDescriptor = WhenChecker.getClassDescriptorOfTypeIfEnum(type) ?: return
|
||||
val context = c.trace.bindingContext
|
||||
if (WhenChecker.getEnumMissingCases(expression, context, enumClassDescriptor).isEmpty()
|
||||
|
||||
+2
-2
@@ -45,8 +45,8 @@ object JavaGenericVarianceViolationTypeChecker : AdditionalTypeChecker {
|
||||
// optimization: if no arguments or flexibility, everything is OK
|
||||
if (expectedType.arguments.isEmpty() || !expectedType.isFlexible()) return
|
||||
|
||||
val lowerBound = expectedType.flexibility().lowerBound
|
||||
val upperBound = expectedType.flexibility().upperBound
|
||||
val lowerBound = expectedType.asFlexibleType().lowerBound
|
||||
val upperBound = expectedType.asFlexibleType().upperBound
|
||||
|
||||
// Use site variance projection is always the same for flexible types
|
||||
if (lowerBound.constructor == upperBound.constructor) return
|
||||
|
||||
Reference in New Issue
Block a user