[NI] Use definitely not-null types for smartcasts
This commit is contained in:
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.js.translate.expression
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.CodegenUtil
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.js.backend.ast.*
|
||||
@@ -125,7 +126,9 @@ private constructor(private val whenExpression: KtWhenExpression, context: Trans
|
||||
|
||||
val dataFlow = DataFlowValueFactory.createDataFlowValue(
|
||||
ktSubject, subjectType, bindingContext(), context().declarationDescriptor ?: context().currentModule)
|
||||
val expectedTypes = bindingContext().getDataFlowInfoBefore(ktSubject).getStableTypes(dataFlow) + setOf(subjectType)
|
||||
val languageVersionSettings = context().config.configuration.languageVersionSettings
|
||||
val expectedTypes = bindingContext().getDataFlowInfoBefore(ktSubject).getStableTypes(dataFlow, languageVersionSettings) +
|
||||
setOf(subjectType)
|
||||
val subject = expressionToMatch ?: return null
|
||||
var subjectSupplier = { subject }
|
||||
|
||||
|
||||
+3
-1
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.js.translate.intrinsic.operation
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.PrimitiveType
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.js.backend.ast.JsBinaryOperation
|
||||
import org.jetbrains.kotlin.js.backend.ast.JsBinaryOperator
|
||||
@@ -114,7 +115,8 @@ object EqualsBOIF : BinaryOperationIntrinsicFactory {
|
||||
val dataFlow = DataFlowValueFactory.createDataFlowValue(expression, ktType, bindingContext, descriptor)
|
||||
val isPrimitiveFn = KotlinBuiltIns::isPrimitiveTypeOrNullablePrimitiveType
|
||||
|
||||
return bindingContext.getDataFlowInfoBefore(expression).getStableTypes(dataFlow).find(isPrimitiveFn) ?: // Smart-casts
|
||||
val languageVersionSettings = context.config.configuration.languageVersionSettings
|
||||
return bindingContext.getDataFlowInfoBefore(expression).getStableTypes(dataFlow, languageVersionSettings).find(isPrimitiveFn) ?: // Smart-casts
|
||||
TypeUtils.getAllSupertypes(ktType).find(isPrimitiveFn) ?: // Generic super-types
|
||||
ktType // Default
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user