mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: use site substitutor during return constraints processing (red code in Collectors)
This commit is contained in:
+2
-2
@@ -369,7 +369,7 @@ public class InferenceSession {
|
||||
targetType = getTargetType(context);
|
||||
}
|
||||
if (targetType != null) {
|
||||
registerConstraints(returnType, targetType);
|
||||
registerConstraints(PsiUtil.isRawSubstitutor(method, mySiteSubstitutor) ? returnType : mySiteSubstitutor.substitute(returnType), targetType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,7 +400,7 @@ public class InferenceSession {
|
||||
PsiTypeParameter[] copy = new PsiTypeParameter[typeParameters.length];
|
||||
for (int i = 0; i < typeParameters.length; i++) {
|
||||
PsiTypeParameter typeParameter = typeParameters[i];
|
||||
copy[i] = elementFactory.createTypeParameterFromText(typeParameter.getName(), null);
|
||||
copy[i] = elementFactory.createTypeParameterFromText("rCopy" + typeParameter.getName(), null);
|
||||
initBounds(copy[i]);
|
||||
subst = subst.put(typeParameter, elementFactory.createType(copy[i]));
|
||||
}
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import com.intellij.psi.impl.source.resolve.graphInference.InferenceVariable;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiMethodCallExpressionImpl;
|
||||
import com.intellij.psi.infos.MethodCandidateInfo;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -134,7 +135,7 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
|
||||
if (!accepted) {
|
||||
//todo return false;
|
||||
}
|
||||
callSession.registerConstraints(returnType, substitutor.substitute(returnType));
|
||||
callSession.registerConstraints(method != null && !PsiUtil.isRawSubstitutor(method, siteSubstitutor) ? siteSubstitutor.substitute(returnType) : returnType, substitutor.substitute(returnType));
|
||||
if (callSession.repeatInferencePhases(true)) {
|
||||
final Collection<InferenceVariable> inferenceVariables = callSession.getInferenceVariables();
|
||||
if (sameMethodCall) {
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collector;
|
||||
|
||||
class Collectors {
|
||||
|
||||
public static <A,R,RR> void collectingAndThen(Function<R, RR> finisher, Function<A, R> finisher1) {
|
||||
Function<A, RR> f = finisher1.andThen(finisher);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class Collectors1 {
|
||||
public static<T,A,R,RR> Collector<T,A,RR> collectingAndThen(Function<R, RR> finisher, Function<A, R> function) {
|
||||
return factory(function.andThen(finisher));
|
||||
}
|
||||
|
||||
static <Ts, As, Rs> Collector<Ts, As, Rs> factory(Function<As, Rs> f) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+4
@@ -164,6 +164,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSiteSubstitutionForReturnConstraint() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user