From 42b2534c46c26077dcdab98f8490a42d7a93d9f7 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 9 Jun 2017 13:39:27 +0300 Subject: [PATCH] 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 --- .../kotlin/resolve/jvm/checkers/WhenByPlatformEnumChecker.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/WhenByPlatformEnumChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/WhenByPlatformEnumChecker.kt index 6fac62246d1..99187136385 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/WhenByPlatformEnumChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/WhenByPlatformEnumChecker.kt @@ -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 { } } -} \ No newline at end of file +}