diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaTypeValue.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaTypeValue.java index 9d954b587f65..e7f5a9c35294 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaTypeValue.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaTypeValue.java @@ -25,8 +25,10 @@ package com.intellij.codeInspection.dataFlow.value; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiKeyword; import com.intellij.psi.PsiType; +import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.containers.HashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -47,12 +49,10 @@ public class DfaTypeValue extends DfaValue { @NotNull public DfaTypeValue create(@NotNull PsiType type, boolean nullable) { + type = TypeConversionUtil.erasure(type); mySharedInstance.myType = type; - mySharedInstance.myCanonicalText = type.getCanonicalText(); + mySharedInstance.myCanonicalText = StringUtil.notNullize(type.getCanonicalText(), PsiKeyword.NULL); mySharedInstance.myIsNullable = nullable; - if (mySharedInstance.myCanonicalText == null) { - mySharedInstance.myCanonicalText = PsiKeyword.NULL; - } String id = mySharedInstance.toString(); ArrayList conditions = myStringToObject.get(id); @@ -65,7 +65,7 @@ public class DfaTypeValue extends DfaValue { } } - DfaTypeValue result = new DfaTypeValue(type, nullable, myFactory); + DfaTypeValue result = new DfaTypeValue(type, nullable, myFactory, mySharedInstance.myCanonicalText); conditions.add(result); return result; } @@ -83,14 +83,11 @@ public class DfaTypeValue extends DfaValue { super(factory); } - private DfaTypeValue(PsiType type, boolean isNullable, DfaValueFactory factory) { + private DfaTypeValue(PsiType type, boolean isNullable, DfaValueFactory factory, String canonicalText) { super(factory); myType = type; myIsNullable = isNullable; - myCanonicalText = type.getCanonicalText(); - if (myCanonicalText == null) { - myCanonicalText = PsiKeyword.NULL; - } + myCanonicalText = canonicalText; } public PsiType getType() { diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NoGenericCCE.java b/java/java-tests/testData/inspection/dataFlow/fixture/NoGenericCCE.java new file mode 100644 index 000000000000..edb3bdc3ada6 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/NoGenericCCE.java @@ -0,0 +1,8 @@ +import java.util.ArrayList; + +class X { + public static void main(String[] args) { + Object list = new ArrayList<>(); + ArrayList list1 = (ArrayList) list; + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java index 6de4bef6febd..6f9c7b089386 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java @@ -285,4 +285,5 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase { public void testContractAnnotation() { doTest(); } public void testBoxingImpliesNotNull() { doTest(); } public void testLargeIntegersAreNotEqualWhenBoxed() { doTest(); } + public void testNoGenericCCE() { doTest(); } } diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy index 36d6b534c67d..df43e5b4f980 100644 --- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy @@ -149,9 +149,12 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase { Collection pkgDirs = pkg.directories.collect { it.virtualFile } Collection pkgChildren = pkgDirs.collect { it.children as List }.flatten() PsiFile javaSrc = psiManager.findFile(pkgChildren.find { it.name == 'LibraryClass.java' }) - assert !javaSrc.node.parsed + assert !javaSrc.contentsLoaded + assert !javaSrc.stub assert pkg.containsClassNamed('LibraryClass') + assert !javaSrc.contentsLoaded + assert !javaSrc.stub assert !javaSrc.node.parsed }