IDEA-121215 (Java 1.8: "Interface may be annotated with @FunctionalInterface" inspection should not report @interfaces)

This commit is contained in:
Bas Leijdekkers
2014-02-26 21:00:44 +01:00
parent 4f97ffeef7
commit 7b58b81761
4 changed files with 11 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -185,7 +185,7 @@ public class LambdaUtil {
if (psiClass instanceof PsiAnonymousClass) {
psiClass = PsiUtil.resolveClassInType(((PsiAnonymousClass)psiClass).getBaseClassType());
}
if (psiClass != null && psiClass.isInterface()) {
if (psiClass != null && psiClass.isInterface() && !psiClass.isAnnotationType()) {
final List<MethodSignature> methods = new ArrayList<MethodSignature>();
final Collection<HierarchicalMethodSignature> visibleSignatures = psiClass.getVisibleSignatures();
for (HierarchicalMethodSignature signature : visibleSignatures) {

View File

@@ -0,0 +1,3 @@
<error descr="Test is not a functional interface">@FunctionalInterface</error>
@interface Test {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -77,6 +77,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIntersectionTypeInCast() { doTest(); }
public void testAmbiguitySpecificReturn() { doTest(true); }
public void testFunctionalInterfaceAnnotation() { doTest(); }
public void testFunctionalInterfaceAnnotation2() { doTest(); }
public void testAmbiguityReturnValueResolution() { doTest(); }
public void testAmbiguityReturnValueResolution1() { doTest(); }
public void testAmbiguityReturnValueResolution2() { doTest(true); }

View File

@@ -44,6 +44,10 @@ public class InterfaceMayBeAnnotatedFunctionalInspectionTest extends LightInspec
"}");
}
public void testAnnotationType() {
doTest("@interface A {}");
}
@Override
protected InspectionProfileEntry getInspection() {
return new InterfaceMayBeAnnotatedFunctionalInspection();