From 867d5f227d7f1887b57b154e347c0ee312c8732b Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 5 Aug 2013 17:53:40 +0200 Subject: [PATCH] least upper bound for primitive arrays fixed (IDEA-111420) --- .../src/com/intellij/psi/GenericsUtil.java | 14 ++++++++++++-- .../advHighlighting7/IDEA111420.java | 10 ++++++++++ .../daemon/LightAdvHighlightingJdk7Test.java | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111420.java diff --git a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java index db4a52a03d9d..f6637fde49e1 100644 --- a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java @@ -70,8 +70,18 @@ public class GenericsUtil { } if (type1 instanceof PsiArrayType && type2 instanceof PsiArrayType) { - final PsiType componentType = getLeastUpperBound(((PsiArrayType)type1).getComponentType(), - ((PsiArrayType)type2).getComponentType(), compared, manager); + final PsiType componentType1 = ((PsiArrayType)type1).getComponentType(); + final PsiType componentType2 = ((PsiArrayType)type2).getComponentType(); + final PsiType componentType = getLeastUpperBound(componentType1, componentType2, compared, manager); + if (componentType1 instanceof PsiPrimitiveType && + componentType2 instanceof PsiPrimitiveType && + componentType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) { + final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory(); + final GlobalSearchScope resolveScope = GlobalSearchScope.allScope(manager.getProject()); + final PsiClassType cloneable = factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_CLONEABLE, resolveScope); + final PsiClassType serializable = factory.createTypeByFQClassName(CommonClassNames.JAVA_IO_SERIALIZABLE, resolveScope); + return PsiIntersectionType.createIntersection(componentType, cloneable, serializable); + } return componentType.createArrayType(); } if (type1 instanceof PsiIntersectionType) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111420.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111420.java new file mode 100644 index 000000000000..173e0f2f3be0 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111420.java @@ -0,0 +1,10 @@ +import java.util.List; + +public class Test { + private static final List> PRIMITIVE_ARRAY_TYPES = asList(byte[].class, int[].class); + private static final List PRIMITIVE_ARRAY_TYPES1 = asList(byte[].class, int[].class); + + public static List asList(T... a) { + return null; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java index c2bd75e8bd8a..2ed507832efc 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java @@ -178,4 +178,5 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testIDEA63731() { doTest(false, false); } public void testIDEA62056() { doTest(false, false); } public void testIDEA78916() { doTest(false, false); } + public void testIDEA111420() { doTest(false, false); } }