It's ok to have no subject expression
This commit is contained in:
+4
-12
@@ -155,11 +155,9 @@ class PatternMatchingTypingVisitor internal constructor(facade: ExpressionTyping
|
|||||||
override fun createDataFlowValue(contextAfterSubject: ExpressionTypingContext, builtIns: KotlinBuiltIns) =
|
override fun createDataFlowValue(contextAfterSubject: ExpressionTypingContext, builtIns: KotlinBuiltIns) =
|
||||||
DataFlowValue.nullValue(builtIns)
|
DataFlowValue.nullValue(builtIns)
|
||||||
|
|
||||||
override fun makeValueArgument(): ValueArgument =
|
override fun makeValueArgument(): ValueArgument? = null
|
||||||
error("Should not be called for Subject.None")
|
|
||||||
|
|
||||||
override val valueExpression: KtExpression
|
override val valueExpression: KtExpression? get() = null
|
||||||
get() = error("Should not be called for Subject.None")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -533,17 +531,11 @@ class PatternMatchingTypingVisitor internal constructor(facade: ExpressionTyping
|
|||||||
|
|
||||||
override fun visitWhenConditionWithExpression(condition: KtWhenConditionWithExpression) {
|
override fun visitWhenConditionWithExpression(condition: KtWhenConditionWithExpression) {
|
||||||
val expression = condition.expression ?: return
|
val expression = condition.expression ?: return
|
||||||
val subjectValueExpression = subject.valueExpression
|
|
||||||
|
|
||||||
val basicDataFlowInfo = checkTypeForExpressionCondition(context, expression, subject.type, subject is Subject.None, subject.dataFlowValue)
|
val basicDataFlowInfo = checkTypeForExpressionCondition(context, expression, subject.type, subject is Subject.None, subject.dataFlowValue)
|
||||||
val moduleDescriptor = DescriptorUtils.getContainingModule(context.scope.ownerDescriptor)
|
val moduleDescriptor = DescriptorUtils.getContainingModule(context.scope.ownerDescriptor)
|
||||||
newDataFlowInfo = if (subjectValueExpression != null) {
|
val dataFlowInfoFromES = components.effectSystem.getDataFlowInfoWhenEquals(subject.valueExpression, expression, context.trace, moduleDescriptor)
|
||||||
val dataFlowInfoFromES = components.effectSystem.getDataFlowInfoWhenEquals(subject.valueExpression, expression, context.trace, moduleDescriptor)
|
newDataFlowInfo = basicDataFlowInfo.and(dataFlowInfoFromES)
|
||||||
basicDataFlowInfo.and(dataFlowInfoFromES)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
basicDataFlowInfo
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitKtElement(element: KtElement) {
|
override fun visitKtElement(element: KtElement) {
|
||||||
|
|||||||
Reference in New Issue
Block a user