[FIR] Add exhaustive checker for when expressions
Also remove generating default else branch introduced in38fa0122and54eb4cf9
This commit is contained in:
+6
-9
@@ -521,7 +521,6 @@ class ExpressionsConverter(
|
||||
if (hasSubject) {
|
||||
subject.bind(this)
|
||||
}
|
||||
var thereIsElse = false
|
||||
for (entry in whenEntries) {
|
||||
val branch = entry.firBlock
|
||||
branches += if (!entry.isElse) {
|
||||
@@ -533,15 +532,11 @@ class ExpressionsConverter(
|
||||
FirWhenBranchImpl(null, firCondition, branch)
|
||||
}
|
||||
} else {
|
||||
thereIsElse = true
|
||||
FirWhenBranchImpl(
|
||||
null, FirElseIfTrueCondition(null), branch
|
||||
)
|
||||
}
|
||||
}
|
||||
if (!thereIsElse) {
|
||||
branches += FirWhenBranchImpl(null, FirElseIfTrueCondition(null), FirEmptyExpressionBlock())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -865,10 +860,12 @@ class ExpressionsConverter(
|
||||
return FirWhenExpressionImpl(null, null, null).apply {
|
||||
val trueBranch = convertLoopBody(thenBlock)
|
||||
branches += FirWhenBranchImpl(null, firCondition, trueBranch)
|
||||
val elseBranch = convertLoopBody(elseBlock)
|
||||
branches += FirWhenBranchImpl(
|
||||
null, FirElseIfTrueCondition(null), elseBranch
|
||||
)
|
||||
elseBlock?.let {
|
||||
val elseBranch = convertLoopBody(it)
|
||||
branches += FirWhenBranchImpl(
|
||||
null, FirElseIfTrueCondition(null), elseBranch
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user