missed constraint on lower bound of captured wildcard (IDEA-169083)

This commit is contained in:
Anna.Kozlova
2017-03-07 11:42:25 +01:00
parent 15221dd37f
commit 8cb5670877
3 changed files with 28 additions and 0 deletions
@@ -185,6 +185,13 @@ public class StrictSubtypingConstraint implements ConstraintFormula {
return true;
}
if (myT instanceof PsiCapturedWildcardType) {
PsiType lowerBound = ((PsiCapturedWildcardType)myT).getLowerBound();
if (lowerBound != PsiType.NULL) {
constraints.add(new StrictSubtypingConstraint(lowerBound, myS));
}
}
return true;
}
@@ -0,0 +1,17 @@
import java.util.Collections;
import java.util.List;
interface Processor<P> {
void process(P t);
}
class Test {
void foo(Processor<? super List<String>> p) {
p.process(Collections.emptyList());
}
void bar(Processor<? extends List<String>> p) {
p.process<error descr="'process(capture<? extends java.util.List<java.lang.String>>)' in 'Processor' cannot be applied to '(java.util.List<java.lang.Object>)'">(Collections.emptyList())</error>;
}
}
@@ -1005,6 +1005,10 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
doTest(true);
}
public void testLowerBoundOfCapturedWildcardInSubtypingConstraint() throws Exception {
doTest(true);
}
public void testMembersContainedInCapturedWildcardType() throws Exception {
doTest();
}