mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
EA-57951 - AIOOBE: AnonymousCanBeLambdaInspection.getInferredType
anonymous -> lambda on varargs place
This commit is contained in:
@@ -141,7 +141,19 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
|
||||
.inferTypeArguments(method.getTypeParameters(), parameters, expressions,
|
||||
((MethodCandidateInfo)result).getSiteSubstitutor(), callExpr.getParent(),
|
||||
DefaultParameterTypeInferencePolicy.INSTANCE);
|
||||
return substitutor.substitute(parameters[i].getType());
|
||||
PsiType paramType;
|
||||
if (i < parameters.length) {
|
||||
paramType = parameters[i].getType();
|
||||
}
|
||||
else {
|
||||
paramType = parameters[parameters.length - 1].getType();
|
||||
if (!(paramType instanceof PsiEllipsisType)) {
|
||||
return null;
|
||||
}
|
||||
paramType = ((PsiEllipsisType)paramType).getComponentType();
|
||||
}
|
||||
|
||||
return substitutor.substitute(paramType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace with lambda" "true"
|
||||
class Test2 {
|
||||
|
||||
void f(Runnable... rs){}
|
||||
{
|
||||
f(null, () -> {
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Replace with lambda" "true"
|
||||
class Test2 {
|
||||
|
||||
void f(Runnable... rs){}
|
||||
{
|
||||
f(null, new Run<caret>nable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user