mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
inference: don't remember captured wildcard with non-proper bound (IDEA-180042)
later check could fail e.g. if bound was created inside one of nested session
This commit is contained in:
+2
-3
@@ -770,7 +770,7 @@ public class InferenceSession {
|
||||
InferenceVariable[] variables = initBounds(null, restParamSubstitution, capturedParams.toArray(PsiTypeParameter.EMPTY_ARRAY));
|
||||
int idx = 0;
|
||||
for (PsiType parameter : parameters) {
|
||||
if (parameter instanceof PsiCapturedWildcardType) {
|
||||
if (parameter instanceof PsiCapturedWildcardType && isProperType(((PsiCapturedWildcardType)parameter).getWildcard())) {
|
||||
variables[idx++].putUserData(ORIGINAL_CAPTURE, (PsiCapturedWildcardType)parameter);
|
||||
}
|
||||
}
|
||||
@@ -1234,8 +1234,7 @@ 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)) &&
|
||||
isProperType(capturedWildcard.getWildcard())) {
|
||||
capturedWildcard.getUpperBound().equals(getUpperBound(aClass))) {
|
||||
eqBound = capturedWildcard;
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -1,3 +1,4 @@
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -54,3 +55,13 @@ class TestWithNonProperTypeBeforeCapture {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class TestWithNonPropertTypeBeforeCaptureInMethodCall {
|
||||
private <K, V> void test(Stream<Map.Entry<K, V>> stream, BiFunction<K, V, ?> entryMapper) {
|
||||
stream.map(createToStringMapper(entryMapper));
|
||||
}
|
||||
|
||||
private <K, V> Function<? super Map.Entry<K, V>, String> createToStringMapper(BiFunction<K, V, ?> mapper) {
|
||||
return k -> toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user