KT-53255. Fix StackOverflow during IR verification from K2

In FIR we desugar when with multiple conditions leading to same block
as tree of OR expressions

Given
```
when(some) {
  "a", "b", "c" -> {}
  else -> {}
}
```

actually desugared into
```
when(val <subj> = some) {
  <subj> == "a" || <subj> == "b" || <subj> == "c" -> {}
  else -> {}
}
```

There is a multiple ways of how we can organize such expressions in FIR
Previously it was just nesting-chain of OR expressions

While the most efficient way in terms of required stack depth is
a balanced tree

KT-53255
This commit is contained in:
Simon Ogorodnik
2022-10-19 04:29:10 +02:00
committed by Space Team
parent ac8cae16ba
commit 2cf8f75a90
6 changed files with 67 additions and 61 deletions
-1
View File
@@ -1,5 +1,4 @@
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
fun box(): String {
return when ("foo") {