When2Switch: check if entry set is not empty
This commit is contained in:
committed by
Evgeny Gerashchenko
parent
d4cb822ee8
commit
706bbd7b72
@@ -101,6 +101,10 @@ public class SwitchCodegenUtil {
|
|||||||
boolean isStatement,
|
boolean isStatement,
|
||||||
@NotNull ExpressionCodegen codegen
|
@NotNull ExpressionCodegen codegen
|
||||||
) {
|
) {
|
||||||
|
if (!isThereEntriesButElse(expression)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Type subjectType = codegen.expressionType(expression.getSubjectExpression());
|
Type subjectType = codegen.expressionType(expression.getSubjectExpression());
|
||||||
BindingContext bindingContext = codegen.getBindingContext();
|
BindingContext bindingContext = codegen.getBindingContext();
|
||||||
|
|
||||||
@@ -121,6 +125,11 @@ public class SwitchCodegenUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isThereEntriesButElse(@NotNull JetWhenExpression expression) {
|
||||||
|
List<JetWhenEntry> entries = expression.getEntries();
|
||||||
|
return !entries.isEmpty() && (entries.size() > 1 || !entries.get(0).isElse());
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isIntegralConstantsSwitch(
|
private static boolean isIntegralConstantsSwitch(
|
||||||
@NotNull JetWhenExpression expression,
|
@NotNull JetWhenExpression expression,
|
||||||
@NotNull Type subjectType,
|
@NotNull Type subjectType,
|
||||||
|
|||||||
Reference in New Issue
Block a user