new inference: processing of compound bounds

This commit is contained in:
Anna Kozlova
2014-03-27 20:54:27 +01:00
parent e55a20cc24
commit b55c83742b
4 changed files with 26 additions and 2 deletions
@@ -66,11 +66,15 @@ public class SubtypingConstraint implements ConstraintFormula {
@Override
public boolean reduce(InferenceSession session, List<ConstraintFormula> constraints) {
if (myT instanceof PsiWildcardType) {
final PsiType tBound = ((PsiWildcardType)myT).getBound();
PsiType tBound = ((PsiWildcardType)myT).getBound();
if (tBound == null) {
return true;
}
if (tBound instanceof PsiCapturedWildcardType) {
tBound = ((PsiWildcardType)myT).isExtends() ? ((PsiCapturedWildcardType)tBound).getUpperBound()
: ((PsiCapturedWildcardType)tBound).getLowerBound();
}
if (myS instanceof PsiCapturedWildcardType) {
myS = ((PsiCapturedWildcardType)myS).getWildcard();
}
@@ -0,0 +1,16 @@
import java.util.*;
import java.util.function.Consumer;
class NachCollections<K,V> {
<K1, V1> Consumer<Map.Entry<K1, V1>> consumer(Consumer<Map.Entry<K1, V1>> c) {
return null;
}
public void forEach(Collection<? extends Map.Entry<K,V>> c1,
Collection<? super Map.Entry<K,V>> c2,
Consumer<Map.Entry<K, V>> a) {
c1.forEach(consumer(a));
c2.forEach(consumer<error descr="'consumer(java.util.function.Consumer<java.util.Map.Entry<K1,V1>>)' in 'NachCollections' cannot be applied to '(java.util.function.Consumer<java.util.Map.Entry<K,V>>)'">(a)</error>);
}
}
@@ -10,6 +10,6 @@ class Node<NodeTypeT extends NodeType> {
class Main {
public static void main(NodeProperty<NumberExpression, Integer> nval, Node<? extends NodeType> expr) {
int val = expr.get<error descr="'get(NodeProperty<? super capture<? extends NodeType>,java.lang.Object>)' in 'Node' cannot be applied to '(NodeProperty<NumberExpression,java.lang.Integer>)'">(nval)</error>;
int val = expr.get<error descr="'get(NodeProperty<? super capture<? extends NodeType>,java.lang.Integer>)' in 'Node' cannot be applied to '(NodeProperty<NumberExpression,java.lang.Integer>)'">(nval)</error>;
}
}
@@ -755,6 +755,10 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
public void testErasure() throws Exception { doTest(); }
public void testWildcardBoundsCombination() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}