mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
lambda: inference from formal params fixed (IDEA-101176)
This commit is contained in:
@@ -743,7 +743,7 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
Pair<PsiType, ConstraintType> constraint = null;
|
||||
final List<PsiExpression> expressions = LambdaUtil.getReturnExpressions(lambdaExpression);
|
||||
for (final PsiExpression expression : expressions) {
|
||||
final boolean independent = LambdaUtil.isFreeFromTypeInferenceArgs(methodParameters, lambdaExpression, expression, subst, functionalInterfaceType, typeParam);
|
||||
final boolean independent = lambdaExpression.hasFormalParameterTypes() || LambdaUtil.isFreeFromTypeInferenceArgs(methodParameters, lambdaExpression, expression, subst, functionalInterfaceType, typeParam);
|
||||
if (!independent) {
|
||||
if (lowerBound != PsiType.NULL) {
|
||||
return null;
|
||||
@@ -817,7 +817,7 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
final PsiParameter[] methodParameters = method.getParameterList().getParameters();
|
||||
PsiType[] methodParamTypes = new PsiType[methodParameters.length];
|
||||
for (int i = 0; i < methodParameters.length; i++) {
|
||||
methodParamTypes[i] = subst.substitute(methodParameters[i].getType());
|
||||
methodParamTypes[i] = GenericsUtil.eliminateWildcards(subst.substitute(methodParameters[i].getType()));
|
||||
}
|
||||
return inferTypeForMethodTypeParameterInner(typeParam, methodParamTypes, lambdaArgs, subst, null, DefaultParameterTypeInferencePolicy.INSTANCE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class IDEA101176 {
|
||||
|
||||
static {
|
||||
foo((Integer i) -> i > 60);
|
||||
}
|
||||
|
||||
static <T> void foo(Predicate<? super T> p){}
|
||||
interface Predicate<T> {
|
||||
public boolean test(T t);
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,10 @@ public class LambdaParamsTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInferFromFormal() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user