mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
new inference: site substitution from remembered properties (IDEA-132417)
This commit is contained in:
+1
-1
@@ -105,7 +105,7 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
|
||||
|
||||
if (typeParams != null) {
|
||||
PsiSubstitutor siteSubstitutor =
|
||||
resolveResult instanceof MethodCandidateInfo && method != null && !method.isConstructor() ? ((MethodCandidateInfo)resolveResult).getSiteSubstitutor() : PsiSubstitutor.EMPTY;
|
||||
resolveResult instanceof MethodCandidateInfo && method != null && !method.isConstructor() ? ((MethodCandidateInfo)resolveResult).getSiteSubstitutor() : candidateProperties != null ? candidateProperties.getSubstitutor() : PsiSubstitutor.EMPTY;
|
||||
final InferenceSession callSession = new InferenceSession(typeParams, siteSubstitutor, myExpression.getManager(), myExpression);
|
||||
callSession.propagateVariables(session.getInferenceVariables());
|
||||
if (method != null) {
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class Test {
|
||||
public static class Thing {
|
||||
public Integer toPresenter() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public <U> void map1(Function<Object, U> mapper) {}
|
||||
|
||||
private void getPresentersFailure( final Stream<Thing> stream) {
|
||||
map1((roles) -> {
|
||||
return stream.map(Thing::toPresenter);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Test1 {
|
||||
public interface Convertable {
|
||||
ThingPresenter toPresenter();
|
||||
}
|
||||
|
||||
public static class Thing implements Convertable {
|
||||
@Override
|
||||
public ThingPresenter toPresenter() {
|
||||
return new ThingPresenter("thing");
|
||||
}
|
||||
}
|
||||
|
||||
public static class ThingPresenter {
|
||||
public String value;
|
||||
public ThingPresenter(String value) { this.value = value; }
|
||||
}
|
||||
|
||||
private static Stream<ThingPresenter> getPresentersFailure(Supplier<Optional<List<Thing>>> thingSupplier) {
|
||||
Optional<List<Thing>> personRoles = thingSupplier.get();
|
||||
return personRoles.map(roles -> roles.stream().map(Thing::toPresenter)).get();
|
||||
}
|
||||
|
||||
private static Stream<ThingPresenter> getPresentersWorking(Supplier<Optional<List<Thing>>> thingSupplier) {
|
||||
Optional<List<Thing>> personRoles = thingSupplier.get();
|
||||
return personRoles.map(roles -> roles.stream().map(t -> t.toPresenter())).get();
|
||||
}
|
||||
}
|
||||
+4
@@ -156,6 +156,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPropertiesInsteadOfSiteSubstitutorIfAny() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user