K2: Optimize one-branch when-expr case only for independent context
Using independent one where `when` is nested doesn't look correct
This commit is contained in:
committed by
Space Team
parent
04d3996e68
commit
8f8ea8c57f
+1
-1
@@ -68,7 +68,7 @@ class FirControlFlowStatementsResolveTransformer(transformer: FirAbstractBodyRes
|
||||
context.withWhenSubjectType(subjectType, components) {
|
||||
when {
|
||||
whenExpression.branches.isEmpty() -> {}
|
||||
whenExpression.isOneBranch() -> {
|
||||
whenExpression.isOneBranch() && data is ResolutionMode.ContextIndependent -> {
|
||||
whenExpression = whenExpression.transformBranches(transformer, ResolutionMode.ContextIndependent)
|
||||
whenExpression.resultType = whenExpression.branches.first().result.resultType
|
||||
// when with one branch cannot be completed if it's not already complete in the first place
|
||||
|
||||
Reference in New Issue
Block a user