From fd72f3e8fa7758a3b505230c3928f1ef262155a1 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 3 Jun 2014 12:27:14 +0400 Subject: [PATCH] javac 6 workaround (from IDEA-16723) --- .../source/resolve/PsiOldInferenceHelper.java | 8 ++++++ .../RedundantTypeArgsInspectionTest.java | 26 ++++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java index c6bb3a4ef0e9..fd672a076a6d 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java @@ -249,6 +249,14 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper { } break OtherParameters; } + else if (currentConstraintType == ConstraintType.SUPERTYPE && !JavaVersionService.getInstance().isAtLeast(parent, JavaSdkVersion.JDK_1_7)) { + if (PsiType.NULL.equals(substitutionFromBounds)) { + substitutionFromBounds = currentSubstitution; + } + else { + substitutionFromBounds = GenericsUtil.getLeastUpperBound(substitutionFromBounds, currentSubstitution, myManager); + } + } } } } diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantTypeArgsInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantTypeArgsInspectionTest.java index c3c092c0b663..fbcdfd0e14c4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantTypeArgsInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantTypeArgsInspectionTest.java @@ -5,25 +5,37 @@ package com.intellij.codeInspection; import com.intellij.JavaTestUtil; +import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.codeInspection.miscGenerics.RedundantTypeArgsInspection; +import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.pom.java.LanguageLevel; +import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.builders.JavaModuleFixtureBuilder; import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase; +import org.jetbrains.annotations.NotNull; -public class RedundantTypeArgsInspectionTest extends JavaCodeInsightFixtureTestCase { +public class RedundantTypeArgsInspectionTest extends LightDaemonAnalyzerTestCase { + + @NotNull @Override - protected void tuneFixture(JavaModuleFixtureBuilder moduleBuilder) { - moduleBuilder.setMockJdkLevel(JavaModuleFixtureBuilder.MockJdkLevel.jdk15); + protected LocalInspectionTool[] configureLocalInspectionTools() { + return new LocalInspectionTool[] { new RedundantTypeArgsInspection()}; } + @Override + protected LanguageLevel getLanguageLevel() { + return LanguageLevel.JDK_1_6; + } + + @NotNull @Override protected String getTestDataPath() { - return JavaTestUtil.getJavaTestDataPath() + "/inspection/redundantTypeArgs/"; + return JavaTestUtil.getJavaTestDataPath(); } private void doTest() throws Throwable { - final RedundantTypeArgsInspection inspection = new RedundantTypeArgsInspection(); - myFixture.enableInspections(inspection); - myFixture.testHighlighting(true, false, false, getTestName(false) + ".java"); + IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_6, getModule(), myTestRootDisposable); + doTest("/inspection/redundantTypeArgs/" + getTestName(false) + ".java", true, false); } public void testReturnPrimitiveTypes() throws Throwable { // javac non-boxing: IDEA-53984