type params: error for jdk < 1.7 (IDEA-67861)

This commit is contained in:
anna
2013-01-07 19:01:29 +01:00
parent 542009391b
commit d1893766c4
4 changed files with 13 additions and 2 deletions

View File

@@ -145,7 +145,7 @@ public class GenericsHighlightUtil {
final String description;
if (targetParametersNum == 0) {
if (PsiTreeUtil.getParentOfType(referenceParameterList, PsiCall.class) != null &&
PsiUtil.isLanguageLevel7OrHigher(referenceParameterList)) {
JavaVersionService.getInstance().isAtLeast(referenceParameterList, JavaSdkVersion.JDK_1_7)) {
description = null;
}
else {

View File

@@ -15,6 +15,8 @@
*/
package com.intellij.psi.infos;
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.*;
@@ -136,7 +138,7 @@ public class MethodCandidateInfo extends CandidateInfo{
final PsiMethod psiMethod = getElement();
PsiTypeParameter[] typeParams = psiMethod.getTypeParameters();
if (myTypeArguments != null && typeParams.length != myTypeArguments.length && !PsiUtil.isLanguageLevel7OrHigher(psiMethod)){
return false;
return typeParams.length == 0 && JavaVersionService.getInstance().isAtLeast(psiMethod, JavaSdkVersion.JDK_1_7);
}
PsiSubstitutor substitutor = getSubstitutor();
return GenericsUtil.isTypeArgumentsApplicable(typeParams, substitutor, getParent());

View File

@@ -0,0 +1,8 @@
abstract class C {
<T> void foo(Object s){ }
abstract String foo(String s);
{
this.<String>foo("").toLowerCase();
}
}

View File

@@ -195,6 +195,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA98421() { doTest5(false); }
public void testErasureTypeParameterBound() { doTest5(false); }
public void testThisAsAccessObject() { doTest5(false); }
public void testIDEA67861() { doTest7Incompatibility(false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));