mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DfaMemoryStateImpl: fix possible ClassCastException
This commit is contained in:
+4
-1
@@ -235,7 +235,10 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
setVariableState(var, state.withFacts(facts));
|
||||
SpecialFieldValue specialFieldValue = facts.get(DfaFactType.SPECIAL_FIELD_VALUE);
|
||||
if (specialFieldValue != null) {
|
||||
setVarValue((DfaVariableValue)specialFieldValue.getField().createValue(myFactory, var), specialFieldValue.toConstant(myFactory));
|
||||
DfaValue targetSpecialField = specialFieldValue.getField().createValue(myFactory, var);
|
||||
if (targetSpecialField instanceof DfaVariableValue) {
|
||||
setVarValue((DfaVariableValue)targetSpecialField, specialFieldValue.toConstant(myFactory));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (DfaUtil.isComparedByEquals(value.getType()) && !DfaUtil.isComparedByEquals(var.getType())) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
final class MyClass {
|
||||
static final int[] arr = {1,2,3};
|
||||
|
||||
void test() {
|
||||
<error descr="Cannot assign a value to final variable 'arr'">arr</error> = new int[] {4};
|
||||
}
|
||||
}
|
||||
@@ -670,4 +670,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testNotNullAnonymousConstructor() { doTest(); }
|
||||
public void testCaughtNPE() { doTest(); }
|
||||
public void testTernaryNullability() { doTest(); }
|
||||
public void testRewriteFinal() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user