reifiable types: ensure that generic types with only all type params as unbound wildcards are treated as reifiable (IDEA-139577)

This commit is contained in:
Anna Kozlova
2015-04-24 20:33:37 +02:00
parent 344ebf19aa
commit 511a356788
2 changed files with 9 additions and 4 deletions
@@ -48,10 +48,13 @@ public class JavaGenericsUtil {
}
PsiType[] parameters = classType.getParameters();
for (PsiType parameter : parameters) {
if (parameter instanceof PsiWildcardType && ((PsiWildcardType)parameter).getBound() == null) {
return true;
if (parameters.length > 0) {
for (PsiType parameter : parameters) {
if (!(parameter instanceof PsiWildcardType && ((PsiWildcardType)parameter).getBound() == null)) {
return false;
}
}
return true;
}
final PsiClass resolved = ((PsiClassType)PsiUtil.convertAnonymousToBaseType(classType)).resolve();
if (resolved instanceof PsiTypeParameter) {
@@ -1,7 +1,7 @@
import java.util.List;
<error descr="'@SafeVarargs' not applicable to type">@SafeVarargs</error>
public class SafeVarargsTests {
class SafeVarargsTests {
//fixed arity
<error descr="@SafeVarargs is not allowed on methods with fixed arity">@SafeVarargs</error>
public void testNonVarargs1(){}
@@ -43,6 +43,8 @@ public class SafeVarargsTests {
public static <T> void foo1(List<T>... <warning descr="Parameter 't' is never used">t</warning>){}
@SafeVarargs
public static <T> void foo2(List<? extends T>... <warning descr="Parameter 't' is never used">t</warning>){}
@SafeVarargs
public static <T> void foo2(java.util.Map<?, T>... <warning descr="Parameter 't' is never used">t</warning>){}
}