do not infer from wildcard with raw bound (IDEA-110947)

This commit is contained in:
anna
2013-07-24 16:07:01 +02:00
parent 504d6eff77
commit d59413a8a1
3 changed files with 25 additions and 1 deletions

View File

@@ -522,7 +522,13 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
private static Pair<PsiType, ConstraintType> processArgType(PsiType arg, final ConstraintType constraintType,
final boolean captureWildcard) {
if (arg instanceof PsiWildcardType && !captureWildcard) return FAILED_INFERENCE;
if (arg != PsiType.NULL) return new Pair<PsiType, ConstraintType>(arg, constraintType);
if (arg != PsiType.NULL) {
if (arg instanceof PsiWildcardType) {
final PsiType bound = ((PsiWildcardType)arg).getBound();
if (bound instanceof PsiClassType && ((PsiClassType)bound).isRaw()) return Pair.create(null, constraintType);
}
return new Pair<PsiType, ConstraintType>(arg, constraintType);
}
return null;
}

View File

@@ -0,0 +1,17 @@
interface Result {}
interface Command<R extends Result> {}
interface Procedure<C extends Command<Result>> {
}
abstract class ProcedureService {
abstract <C extends Command<Result>> Class<? extends Procedure<Command<Result>>> getProcedure(Class<C> cmd);
public <C extends Command<Result>> void execute(Class<? extends Command> aClass) {
Class<Procedure<Command<Result>>> procedureClass = getProcedure(aClass);
<error descr="Incompatible types. Found: 'java.lang.Class<capture<? extends Command>>', required: 'java.lang.Class<Command>'">Class<Command> c = aClass;</error>
<error descr="Incompatible types. Found: 'java.lang.Class<capture<? extends Command>>', required: 'java.lang.Class<C>'">Class<C> c1 = aClass;</error>
}
}

View File

@@ -301,6 +301,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA67682() { doTest5(false); }
public void testIDEA57391() { doTest5(false); }
public void testIDEA110869() { doTest5(false); }
public void testIDEA110947() { doTest5(false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));