mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
new inference: do not prefer specifics based on void return type for both void and value compatible lambdas
This commit is contained in:
@@ -995,8 +995,9 @@ public class InferenceSession {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sReturnType == PsiType.VOID && session != null) {
|
||||
return false;
|
||||
final List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg);
|
||||
if (sReturnType == PsiType.VOID) {
|
||||
return returnExpressions.isEmpty() && session == null;
|
||||
}
|
||||
|
||||
if (LambdaUtil.isFunctionalType(sReturnType) && LambdaUtil.isFunctionalType(tReturnType) &&
|
||||
@@ -1005,15 +1006,14 @@ public class InferenceSession {
|
||||
|
||||
//Otherwise, if R1 and R2 are functional interface types, and neither interface is a subinterface of the other,
|
||||
//then these rules are applied recursively to R1 and R2, for each result expression in expi.
|
||||
final List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg);
|
||||
if (!isFunctionalTypeMoreSpecific(sReturnType, tReturnType, session, returnExpressions.toArray(new PsiExpression[returnExpressions.size()]))) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType;
|
||||
final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType;
|
||||
final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType && sReturnType != PsiType.VOID;
|
||||
final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType && tReturnType != PsiType.VOID;
|
||||
if (sPrimitive ^ tPrimitive) {
|
||||
for (PsiExpression returnExpression : LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg)) {
|
||||
for (PsiExpression returnExpression : returnExpressions) {
|
||||
if (!PsiPolyExpressionUtil.isPolyExpression(returnExpression)) {
|
||||
final PsiType returnExpressionType = returnExpression.getType();
|
||||
if (sPrimitive) {
|
||||
|
||||
@@ -22,6 +22,6 @@ class AmbiguityRawGenerics {
|
||||
<Z> void foo(I3<Z> s) { }
|
||||
|
||||
void bar() {
|
||||
foo<error descr="Ambiguous method call: both 'AmbiguityRawGenerics.foo(I1)' and 'AmbiguityRawGenerics.foo(I2)' match">(()-> { throw new RuntimeException(); })</error>;
|
||||
foo<error descr="Ambiguous method call: both 'AmbiguityRawGenerics.foo(I)' and 'AmbiguityRawGenerics.foo(I1)' match">(()-> { throw new RuntimeException(); })</error>;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user