captured of non-proper wildcard can't be used as solving bound (IDEA-180042)

This commit is contained in:
Anna.Kozlova
2017-10-12 19:38:49 +02:00
parent f253087643
commit 2f1a299401
2 changed files with 14 additions and 1 deletions
@@ -1240,7 +1240,9 @@ public class InferenceSession {
//restore captured wildcard from method return type when no additional constraints were inferred
//to preserve equality of type arguments
if (capturedWildcard != null && capturedWildcard.getUpperBound().equals(getUpperBound(aClass))) {
if (capturedWildcard != null &&
capturedWildcard.getUpperBound().equals(getUpperBound(aClass)) &&
isProperType(capturedWildcard.getWildcard())) {
eqBound = capturedWildcard;
}
}
@@ -43,3 +43,14 @@ class Test {
return list.stream().collect(Collectors.toCollection(() -> create()));
}
}
class TestWithNonProperTypeBeforeCapture {
{
Set<? super List<String>> set = foo();
}
private <K> Set<? super List<K>> foo() { //#CAP<? super List<K>> is not proper, can't be used as eq bound
return null;
}
}