mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 19:02:13 +07:00
CreateMissingSwitchBranchesAction: disable for long type
Fixes EA-218697 - IAE: CreateMissingSwitchBranchesAction$Value.fromConstant GitOrigin-RevId: 4d12ab41954dd0dbcebeadaccbeaea1d064078d4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b9e6d12fb6
commit
42c3f75c71
+1
-1
@@ -85,7 +85,7 @@ public class CreateMissingSwitchBranchesAction extends PsiElementBaseIntentionAc
|
||||
PsiType type = expression.getType();
|
||||
if (dfr != null) {
|
||||
LongRangeSet range = dfr.getExpressionFact(expression, DfaFactType.RANGE);
|
||||
if (range != null && !range.isCardinalityBigger(MAX_NUMBER_OF_BRANCHES)) {
|
||||
if (range != null && type != null && PsiType.INT.isAssignableFrom(type) && !range.isCardinalityBigger(MAX_NUMBER_OF_BRANCHES)) {
|
||||
return range.stream().mapToObj(c -> Value.fromConstant(TypeConversionUtil.computeCastTo(c, type))).collect(Collectors.toList());
|
||||
}
|
||||
Set<Object> values = dfr.getExpressionValues(expression);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class DataflowLong {
|
||||
void test() {
|
||||
long x = Math.random() > 0.5 ? 1 : 2;
|
||||
|
||||
switch<caret> (x) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -11,6 +11,10 @@ public class CreateMissingSwitchBranchesActionTest extends IPPTestCase {
|
||||
public void testDataflowInt() {
|
||||
doTest(CreateSwitchBranchesUtil.getActionName(Arrays.asList("1", "3", "5", "7", "9")));
|
||||
}
|
||||
|
||||
public void testDataflowLong() {
|
||||
assertIntentionNotAvailable(CreateSwitchBranchesUtil.getActionName(Arrays.asList("1", "2")));
|
||||
}
|
||||
|
||||
public void testDataflowIntMixedTypes() {
|
||||
doTest(CreateSwitchBranchesUtil.getActionName(Arrays.asList("0", "1", "3", "4", "6", "7", "9")));
|
||||
|
||||
Reference in New Issue
Block a user