IDEA-121952 (Java 1.8: "Interface may be annotated with @FunctionalInterface" inspection reports already annotated interfaces)

This commit is contained in:
Bas Leijdekkers
2014-03-11 11:24:12 +01:00
parent 81ca41b8cb
commit 8d172ac52a
2 changed files with 8 additions and 1 deletions
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.classlayout;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
import com.intellij.psi.LambdaHighlightingUtil;
import com.intellij.psi.LambdaUtil;
@@ -71,7 +72,7 @@ public class InterfaceMayBeAnnotatedFunctionalInspection extends BaseInspection
return;
}
super.visitClass(aClass);
if (!aClass.isInterface()) {
if (!aClass.isInterface() || AnnotationUtil.isAnnotated(aClass, "java.lang.FunctionalInterface", false)) {
return;
}
if (LambdaHighlightingUtil.checkInterfaceFunctional(aClass) != null) {
@@ -44,6 +44,12 @@ public class InterfaceMayBeAnnotatedFunctionalInspectionTest extends LightInspec
"}");
}
public void testAlreadyAnnotated() {
doTest("@FunctionalInterface interface Asd {" +
" boolean doSmth();" +
"}");
}
public void testAnnotationType() {
doTest("@interface A {}");
}