mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
method refs: ensure inference from captured return type (IDEA-145152)
This commit is contained in:
+3
-2
@@ -197,8 +197,9 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
||||
}
|
||||
}
|
||||
|
||||
constraints.add(new TypeCompatibilityConstraint(returnType,
|
||||
session.substituteWithInferenceVariables(psiSubstitutor.substitute(referencedMethodReturnType))));
|
||||
final PsiType capturedReturnType = PsiImplUtil.normalizeWildcardTypeByPosition(psiSubstitutor.substitute(referencedMethodReturnType),
|
||||
myExpression);
|
||||
constraints.add(new TypeCompatibilityConstraint(returnType, session.substituteWithInferenceVariables(capturedReturnType)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.util.stream.Stream;
|
||||
class Test {
|
||||
|
||||
void foo(final Stream<StubElement<?>> inStream){
|
||||
inStream.map(StubElement::getPsi)
|
||||
.map(s -> s.length());
|
||||
}
|
||||
|
||||
class StubElement<T extends String> {
|
||||
T getPsi() {return null;}
|
||||
}
|
||||
}
|
||||
+4
@@ -426,6 +426,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCapturedReturnTypeOfMethodReference() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user