[FIR] Add synthetic else branch to when if it's missing to LightTreeFirBuilder

This commit is contained in:
Dmitriy Novozhilov
2019-09-02 11:12:35 +03:00
parent 5c29af4b53
commit 54eb4cf928
@@ -497,6 +497,7 @@ class ExpressionsConverter(
if (hasSubject) {
subject.bind(this)
}
var thereIsElse = false
for (entry in whenEntries) {
val branch = entry.firBlock
branches += if (!entry.isElse) {
@@ -508,11 +509,15 @@ class ExpressionsConverter(
FirWhenBranchImpl(null, firCondition, branch)
}
} else {
thereIsElse = true
FirWhenBranchImpl(
null, FirElseIfTrueCondition(null), branch
)
}
}
if (!thereIsElse) {
branches += FirWhenBranchImpl(null, FirElseIfTrueCondition(null), FirEmptyExpressionBlock())
}
}
}