IDEA-94990: java 6 bug workaround

This commit is contained in:
anna
2012-11-15 19:08:03 +01:00
parent fc6e27c417
commit 77d6b68a6b
5 changed files with 41 additions and 7 deletions

View File

@@ -27,7 +27,7 @@ import org.jetbrains.annotations.TestOnly;
* @since 3/28/12
*/
public class JavaVersionServiceImpl extends JavaVersionService {
private JavaSdkVersion myTestVersion = null;
private JavaSdkVersion myTestVersion = JavaSdkVersion.JDK_1_7;
@TestOnly
public void setTestVersion(@Nullable JavaSdkVersion testVersion, Disposable parentDisposable) {
@@ -35,7 +35,7 @@ public class JavaVersionServiceImpl extends JavaVersionService {
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
myTestVersion = null;
myTestVersion = JavaSdkVersion.JDK_1_7;
}
});
}

View File

@@ -16,6 +16,8 @@
package com.intellij.psi.impl.source.resolve;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.JavaVersionService;
import com.intellij.openapi.util.Pair;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
@@ -532,6 +534,7 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
if (!(param instanceof PsiClassType)) return null;
PsiManager manager = typeParam.getManager();
if (arg instanceof PsiPrimitiveType) {
if (!JavaVersionService.getInstance().isAtLeast(typeParam, JavaSdkVersion.JDK_1_7)) return null;
arg = ((PsiPrimitiveType)arg).getBoxedType(typeParam);
if (arg == null) return null;
}

View File

@@ -0,0 +1,12 @@
class Test {
public <T> T doStuff() {
return null;
}
public boolean test() {
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'boolean'">return doStuff();</error>
}
public Boolean test1() {
return doStuff();
}
}

View File

@@ -0,0 +1,12 @@
class Test {
public <T> T doStuff() {
return null;
}
public boolean test() {
return doStuff();
}
public Boolean test1() {
return doStuff();
}
}

View File

@@ -61,6 +61,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
level = LanguageLevel.JDK_1_5;
}
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(level);
((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_6, myTestRootDisposable);
}
@Override
@@ -79,7 +80,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testExplicitMethodParameters1() throws Exception { doTest(false); }
public void testInferenceWithBounds() throws Exception { doTest(false); }
public void testInferenceWithSuperBounds() throws Exception { doTest(false); }
public void testInferenceWithUpperBoundPromotion() throws Exception { doTest(false); }
public void testInferenceWithUpperBoundPromotion() throws Exception { doTest17Incompatibility(); }
public void testVariance() throws Exception { doTest(false); }
public void testForeachTypes() throws Exception { doTest(false); }
public void testRawOverridingMethods() throws Exception { doTest(false); }
@@ -96,7 +97,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testUncheckedOverriding() throws Exception { doTest(true); }
public void testWildcardTypes() throws Exception { doTest(true); }
public void testConvertibleTypes() throws Exception { doTest(true); }
public void testIntersectionTypes() throws Exception { doTest(true); }
public void testIntersectionTypes() throws Exception { doTest17Incompatibility(true); }
public void testVarargs() throws Exception { doTest(true); }
public void testTypeArgsOnRaw() throws Exception { doTest(false); }
public void testConditionalExpression() throws Exception { doTest(false); }
@@ -152,8 +153,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA67681() throws Exception { doTest(false); }
public void testIDEA67599() throws Exception { doTest(false); }
public void testIDEA57668() throws Exception { doTest(false); }
public void testIDEA57667() throws Exception { doTest(false); }
public void testIDEA57650() throws Exception { doTest(false); }
public void testIDEA57667() throws Exception { doTest17Incompatibility(false); }
public void testIDEA57650() throws Exception { doTest17Incompatibility(false); }
public void testIDEA57378() throws Exception { doTest(false); }
public void testIDEA57557() throws Exception { doTest(false); }
public void testIDEA57563() throws Exception { doTest(false); }
@@ -195,6 +196,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA91626() throws Exception { doTest(true); }
public void testIDEA92022() throws Exception { doTest(false); }
public void testRawOnParameterized() throws Exception { doTest(false); }
public void testFailedInferenceWithBoxing() throws Exception { doTest(false); }
public void testFixedFailedInferenceWithBoxing() throws Exception { doTest17Incompatibility(false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
@@ -207,7 +210,11 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
}
private void doTest17Incompatibility() throws Exception {
doTest17Incompatibility(false);
}
private void doTest17Incompatibility(final boolean warnings) throws Exception {
((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_7, getTestRootDisposable());
doTest(false);
doTest(warnings);
}
}