mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
lambda: forbid type params in SAM methods (IDEA-101553)
This commit is contained in:
@@ -32,7 +32,12 @@ public class LambdaHighlightingUtil {
|
||||
final List<MethodSignature> signatures = LambdaUtil.findFunctionCandidates(psiClass);
|
||||
if (signatures == null) return "Target type of a lambda conversion must be an interface";
|
||||
if (signatures.isEmpty()) return "No target method found";
|
||||
return signatures.size() == 1 ? null : "Multiple non-overriding abstract methods found";
|
||||
if (signatures.size() == 1) {
|
||||
final MethodSignature functionalMethod = signatures.get(0);
|
||||
if (functionalMethod.getTypeParameters().length > 0) return "Target method is generic";
|
||||
return null;
|
||||
}
|
||||
return "Multiple non-overriding abstract methods found";
|
||||
}
|
||||
|
||||
public static String checkReturnTypeCompatible(PsiLambdaExpression lambdaExpression, PsiType functionalInterfaceReturnType) {
|
||||
|
||||
+2
-2
@@ -76,11 +76,11 @@ public class FunctionalInterfaceTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
public void testMethodWithTypeParam() throws Exception {
|
||||
doTestFunctionalInterface(null);
|
||||
doTestFunctionalInterface("Target method is generic");
|
||||
}
|
||||
|
||||
public void testTwoMethodsSameSignatureTypeParams() throws Exception {
|
||||
doTestFunctionalInterface(null);
|
||||
doTestFunctionalInterface("Target method is generic");
|
||||
}
|
||||
|
||||
public void testAbstractClass() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user