diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/when/SwitchCodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/when/SwitchCodegenUtil.java index a45f446542c..74730d893ab 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/when/SwitchCodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/when/SwitchCodegenUtil.java @@ -101,6 +101,10 @@ public class SwitchCodegenUtil { boolean isStatement, @NotNull ExpressionCodegen codegen ) { + if (!isThereEntriesButElse(expression)) { + return null; + } + Type subjectType = codegen.expressionType(expression.getSubjectExpression()); BindingContext bindingContext = codegen.getBindingContext(); @@ -121,6 +125,11 @@ public class SwitchCodegenUtil { return null; } + private static boolean isThereEntriesButElse(@NotNull JetWhenExpression expression) { + List entries = expression.getEntries(); + return !entries.isEmpty() && (entries.size() > 1 || !entries.get(0).isElse()); + } + private static boolean isIntegralConstantsSwitch( @NotNull JetWhenExpression expression, @NotNull Type subjectType,