mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DfaBoxedValue#createUnboxed: disable for non-primitive constants (e.g. strings)
This commit is contained in:
+3
-3
@@ -15,12 +15,13 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.dataFlow.value;
|
||||
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import java.util.HashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DfaBoxedValue extends DfaValue {
|
||||
@@ -70,8 +71,7 @@ public class DfaBoxedValue extends DfaValue {
|
||||
return ((DfaBoxedValue)value).getWrappedValue();
|
||||
}
|
||||
if (value instanceof DfaConstValue) {
|
||||
if (value == value.myFactory.getConstFactory().getNull()) return DfaUnknownValue.getInstance();
|
||||
return value;
|
||||
return TypeConversionUtil.isPrimitiveAndNotNull(((DfaConstValue)value).getType()) ? value : DfaUnknownValue.getInstance();
|
||||
}
|
||||
if (value instanceof DfaVariableValue) {
|
||||
DfaVariableValue var = (DfaVariableValue)value;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class Testcase {
|
||||
void test() {
|
||||
<error descr="Incompatible types. Found: 'java.lang.String', required: 'java.lang.Character'">Character x = "foo";</error>
|
||||
}
|
||||
}
|
||||
@@ -640,4 +640,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testStringEquality() { doTest(); }
|
||||
public void testAssignmentFieldAliasing() { doTest(); }
|
||||
public void testNewBoxedNumberEquality() { doTest(); }
|
||||
public void testBoxingIncorrectLiteral() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user