public StackValue generateWhenExpression(final KtWhenExpression expression, final boolean isStatement) { final KtExpression expr = expression.getSubjectExpression(); final Type subjectType = expressionType(expr); final Type resultType = isStatement ? Type.VOID_TYPE : expressionTypeForBranchingOperation(expression); return StackValue.operation(resultType, new Function1() { @Override public Unit invoke(InstructionAdapter v) { SwitchCodegen switchCodegen = SwitchCodegenUtil.buildAppropriateSwitchCodegenIfPossible( expression, isStatement, CodegenUtil.isExhaustive(bindingContext, expression, isStatement), ExpressionCodegen.this ); if (switchCodegen != null) { switchCodegen.generate(); return Unit.INSTANCE; } /* .... */ return null; } }); }