composition of extends/super wildcard reworked (IDEA-96721)

This commit is contained in:
anna
2012-12-14 18:36:42 +01:00
parent dc9ddba2e0
commit d29e6b8b99
3 changed files with 9 additions and 3 deletions
@@ -159,7 +159,13 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
if (newBound instanceof PsiCapturedWildcardType) {
final PsiWildcardType wildcard = ((PsiCapturedWildcardType)newBound).getWildcard();
if (wildcardType.isExtends() != wildcard.isExtends()) {
return wildcard.isBounded() ? wildcard.getBound() : newBound;
if (wildcard.isBounded()) {
return wildcardType.isExtends() ? PsiWildcardType.createExtends(wildcardType.getManager(), newBound)
: PsiWildcardType.createSuper(wildcardType.getManager(), newBound);
}
else {
return newBound;
}
}
if (!wildcard.isBounded()) return PsiWildcardType.createUnbounded(wildcardType.getManager());
}
@@ -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<NodeType,java.lang.Integer>)' 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>;
}
}
@@ -152,6 +152,6 @@ public class TypeInferenceTest extends Resolve15TestCase {
}
public void testBoundComposition() throws Exception {
checkResolvesTo("java.lang.Class<?>");
checkResolvesTo("java.lang.Class<? super ? extends java.lang.Object>");
}
}