lambda: forbid type params in SAM methods (IDEA-101553)

This commit is contained in:
anna
2013-02-21 20:21:49 +01:00
parent 5a419aa494
commit 18adb1cefc
2 changed files with 8 additions and 3 deletions
@@ -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) {
@@ -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 {