mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
new inference: distinguish return type type parameters and current session inference variables (IDEA-135001)
This commit is contained in:
+1
-1
@@ -488,7 +488,7 @@ public class InferenceSession {
|
||||
if (psiClass != null) {
|
||||
LOG.assertTrue(returnType instanceof PsiClassType);
|
||||
final PsiTypeParameter[] typeParameters = psiClass.getTypeParameters();
|
||||
InferenceVariable[] copy = initBounds(myContext, typeParameters);
|
||||
InferenceVariable[] copy = initBounds(null, typeParameters);
|
||||
final PsiType substitutedCapture = PsiUtil.captureToplevelWildcards(returnType, myContext);
|
||||
myIncorporationPhase.addCapture(copy, (PsiClassType)substituteWithInferenceVariables(returnType));
|
||||
addConstraint(new TypeCompatibilityConstraint(targetType, substitutedCapture));
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class Test {
|
||||
private void foo(Function<? super Integer, Stream<Integer>> first) {
|
||||
Function<? super Integer, Object> second = first.andThen(s -> s.map(null));
|
||||
}
|
||||
|
||||
|
||||
private final Function<? super Integer, ? extends Stream<? extends Integer>> first =
|
||||
response -> Arrays.asList(response).stream().map(i -> i++);
|
||||
|
||||
private final Function<? super Integer, ? extends Stream<Map<String, Integer>>> second = first.andThen(
|
||||
mid -> mid.map(i -> {
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
map.put("key", i);
|
||||
return map;
|
||||
}));
|
||||
}
|
||||
+4
@@ -58,6 +58,10 @@ public class ConstraintsInferenceMiscTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testWildcardParameterizedReturnTypeConflictWithParameterTypes() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest(final boolean checkWarnings) {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user