[FIR] Try to infer result type of incomplete when expression
^KT-62069 Fixed
This commit is contained in:
committed by
Space Team
parent
e2f245096c
commit
88f7b085e6
+4
-2
@@ -68,7 +68,9 @@ class FirControlFlowStatementsResolveTransformer(transformer: FirAbstractBodyRes
|
||||
var completionNeeded = false
|
||||
context.withWhenSubjectType(subjectType, components) {
|
||||
when {
|
||||
whenExpression.branches.isEmpty() -> {}
|
||||
whenExpression.branches.isEmpty() -> {
|
||||
whenExpression.resultType = session.builtinTypes.unitType.type
|
||||
}
|
||||
whenExpression.isOneBranch() && data.forceFullCompletion && data !is ResolutionMode.WithExpectedType -> {
|
||||
whenExpression = whenExpression.transformBranches(transformer, ResolutionMode.ContextIndependent)
|
||||
whenExpression.resultType = whenExpression.branches.first().result.resolvedType
|
||||
@@ -115,7 +117,7 @@ class FirControlFlowStatementsResolveTransformer(transformer: FirAbstractBodyRes
|
||||
}
|
||||
|
||||
private fun FirWhenExpression.replaceReturnTypeIfNotExhaustive(): FirWhenExpression {
|
||||
if (!isProperlyExhaustive) {
|
||||
if (!isProperlyExhaustive && !usedAsExpression) {
|
||||
resultType = session.builtinTypes.unitType.type
|
||||
}
|
||||
return this
|
||||
|
||||
Reference in New Issue
Block a user