mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
new inference: lift type parameters; stop inference after false appears in bounds
This commit is contained in:
@@ -251,7 +251,7 @@ public class InferenceSession {
|
||||
inferenceVariable.ignoreInstantiation();
|
||||
}
|
||||
if (!proceedWithAdditionalConstraints(additionalConstraints)) {
|
||||
//return prepareSubstitution();
|
||||
return prepareSubstitution();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -636,9 +636,9 @@ public class InferenceSession {
|
||||
for (List<InferenceVariable> variables : independentVars) {
|
||||
for (InferenceVariable inferenceVariable : variables) {
|
||||
|
||||
if (inferenceVariable.getInstantiation() != PsiType.NULL) continue;
|
||||
final PsiTypeParameter typeParameter = inferenceVariable.getParameter();
|
||||
try {
|
||||
if (inferenceVariable.getInstantiation() != PsiType.NULL) continue;
|
||||
final List<PsiType> eqBounds = inferenceVariable.getBounds(InferenceBound.EQ);
|
||||
final List<PsiType> lowerBounds = inferenceVariable.getBounds(InferenceBound.LOWER);
|
||||
final List<PsiType> upperBounds = inferenceVariable.getBounds(InferenceBound.UPPER);
|
||||
@@ -820,7 +820,10 @@ public class InferenceSession {
|
||||
}
|
||||
if (!dependsOnOutput) {
|
||||
subset.add(constraint);
|
||||
varsToResolve.addAll(inputVariables);
|
||||
for (InferenceVariable variable : inputVariables) {
|
||||
varsToResolve.addAll(variable.getDependencies(this));
|
||||
varsToResolve.add(variable);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -149,14 +149,16 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
||||
}
|
||||
LOG.assertTrue(referencedMethodReturnType != null, method);
|
||||
|
||||
session.initBounds(method.getTypeParameters());
|
||||
session.initBounds(containingClass.getTypeParameters());
|
||||
|
||||
if (typeParameters.length == 0 && ((PsiMethod)resolve).getTypeParameters().length > 0) {
|
||||
|
||||
final PsiClass interfaceClass = classResolveResult.getElement();
|
||||
LOG.assertTrue(interfaceClass != null);
|
||||
if (PsiPolyExpressionUtil.mentionsTypeParameters(referencedMethodReturnType,
|
||||
ContainerUtil.newHashSet(method.getTypeParameters()))) {
|
||||
LOG.assertTrue(interfaceMethodReturnType != null);
|
||||
constraints.add(new TypeCompatibilityConstraint(referencedMethodReturnType, interfaceMethodReturnType));
|
||||
constraints.add(new TypeCompatibilityConstraint(referencedMethodReturnType, returnType));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class NoInferenceResult {
|
||||
m((String s1) -> s1.length());
|
||||
m((String s1) -> s1);
|
||||
|
||||
m1(<error descr="Target type of a lambda conversion must be an interface">() -> { }</error>);
|
||||
m1<error descr="'m1(T)' in 'NoInferenceResult' cannot be applied to '(<lambda expression>)'">(() -> { })</error>;
|
||||
|
||||
Foo<String> foo = new Foo<String>();
|
||||
foo.map(v -> null);
|
||||
|
||||
@@ -14,7 +14,7 @@ class NoLambda {
|
||||
static <T> T id(T i2) {return i2;}
|
||||
|
||||
{
|
||||
id(<error descr="Target type of a lambda conversion must be an interface">() -> {System.out.println("hi");}</error>);
|
||||
id<error descr="'id(T)' in 'NoLambda' cannot be applied to '(<lambda expression>)'">(() -> {System.out.println("hi");})</error>;
|
||||
NoLambda.<Runnable>id(() -> {System.out.println("hi");});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user