Remove redundant check in WhenByPlatformEnumChecker

If a type is annotated as not null its upper bound is not nullable
in most cases besides override conflicts, but in the latter case
we should behave consistently with flexibility of this type
This commit is contained in:
Denis Zharkov
2017-06-09 13:39:27 +03:00
parent fc9810182e
commit 42b2534c46
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.resolve.jvm.checkers
import org.jetbrains.kotlin.cfg.WhenChecker
import org.jetbrains.kotlin.load.java.lazy.types.isMarkedNotNull
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtWhenExpression
import org.jetbrains.kotlin.resolve.BindingContext
@@ -37,7 +36,7 @@ class WhenByPlatformEnumChecker : AdditionalTypeChecker {
// Check for conditionally-exhaustive when on platform enums, see KT-6399
val subjectExpression = expression.subjectExpression ?: return
val type = c.trace.getType(subjectExpression) ?: return
if (type.isFlexible() && TypeUtils.isNullableType(type.asFlexibleType().upperBound) && !type.annotations.isMarkedNotNull()) {
if (type.isFlexible() && TypeUtils.isNullableType(type.asFlexibleType().upperBound)) {
val dataFlowValue = DataFlowValueFactory.createDataFlowValue(subjectExpression, type, c)
val dataFlowInfo = c.trace[BindingContext.EXPRESSION_TYPE_INFO, subjectExpression]?.dataFlowInfo
if (dataFlowInfo != null && !dataFlowInfo.getStableNullability(dataFlowValue).canBeNull()) {
@@ -55,4 +54,4 @@ class WhenByPlatformEnumChecker : AdditionalTypeChecker {
}
}
}
}