mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
lambda: allow raw types when no inference was performed
This commit is contained in:
@@ -92,12 +92,25 @@ public class LambdaUtil {
|
||||
public static boolean isLambdaFullyInferred(PsiLambdaExpression expression, PsiType functionalInterfaceType) {
|
||||
if (expression.getParameterList().getParametersCount() > 0 ||
|
||||
getFunctionalInterfaceReturnType(functionalInterfaceType) != PsiType.VOID) { //todo check that void lambdas without params check
|
||||
if (functionalInterfaceType instanceof PsiClassType && ((PsiClassType)functionalInterfaceType).isRaw()) return false;
|
||||
if (!checkRawAcceptable(expression, functionalInterfaceType)) {
|
||||
return false;
|
||||
}
|
||||
return !dependsOnTypeParams(functionalInterfaceType, functionalInterfaceType, expression, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean checkRawAcceptable(PsiLambdaExpression expression, PsiType functionalInterfaceType) {
|
||||
PsiElement parent = expression.getParent();
|
||||
while (parent instanceof PsiParenthesizedExpression) {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
if (parent instanceof PsiExpressionList && functionalInterfaceType instanceof PsiClassType && ((PsiClassType)functionalInterfaceType).isRaw()){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String checkInterfaceFunctional(PsiType functionalInterfaceType) {
|
||||
final PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(functionalInterfaceType);
|
||||
|
||||
+12
@@ -58,3 +58,15 @@ class Test4 {
|
||||
public interface TerminalOp1<T, U> extends IntermediateOp1<T, U> {}
|
||||
|
||||
}
|
||||
|
||||
class Test5 {
|
||||
{
|
||||
Block empty = x -> {};
|
||||
Block<?> empty1 = x -> {};
|
||||
System.out.println((Block) x -> {});
|
||||
}
|
||||
|
||||
interface Block<T> {
|
||||
void apply(T t);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user