PSI2IR: KT-49485 chunk ktConditions to avoid stackoverflow
This commit is contained in:
+14
-11
@@ -112,18 +112,21 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta
|
||||
break
|
||||
}
|
||||
|
||||
var irBranchCondition: IrExpression? = null
|
||||
for (ktCondition in ktEntry.conditions) {
|
||||
val irCondition =
|
||||
if (irSubject != null)
|
||||
generateWhenConditionWithSubject(ktCondition, irSubject, expression.subjectExpression)
|
||||
else
|
||||
generateWhenConditionNoSubject(ktCondition)
|
||||
irBranchCondition = irBranchCondition?.let { context.whenComma(it, irCondition) } ?: irCondition
|
||||
}
|
||||
// chunk conditions to avoid stackoverflow later when IrWhen is visited
|
||||
for (ktConditions in ktEntry.conditions.toList().chunked(64)) {
|
||||
var irBranchCondition: IrExpression? = null
|
||||
for (ktCondition in ktConditions) {
|
||||
val irCondition =
|
||||
if (irSubject != null)
|
||||
generateWhenConditionWithSubject(ktCondition, irSubject, expression.subjectExpression)
|
||||
else
|
||||
generateWhenConditionNoSubject(ktCondition)
|
||||
irBranchCondition = irBranchCondition?.let { context.whenComma(it, irCondition) } ?: irCondition
|
||||
}
|
||||
|
||||
val irBranchResult = ktEntry.expression!!.genExpr()
|
||||
irWhen.branches.add(IrBranchImpl(irBranchCondition!!, irBranchResult))
|
||||
val irBranchResult = ktEntry.expression!!.genExpr()
|
||||
irWhen.branches.add(IrBranchImpl(irBranchCondition!!, irBranchResult))
|
||||
}
|
||||
}
|
||||
if (!hasExplicitElseBranch) {
|
||||
addElseBranchForExhaustiveWhenIfNeeded(irWhen, expression)
|
||||
|
||||
Reference in New Issue
Block a user