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,
|
||||
@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<JetWhenEntry> entries = expression.getEntries();
|
||||
return !entries.isEmpty() && (entries.size() > 1 || !entries.get(0).isElse());
|
||||
}
|
||||
|
||||
private static boolean isIntegralConstantsSwitch(
|
||||
@NotNull JetWhenExpression expression,
|
||||
@NotNull Type subjectType,
|
||||
|
||||
Reference in New Issue
Block a user