forbid native in interfaces (IDEA-140491)

This commit is contained in:
Anna Kozlova
2015-05-20 12:03:04 +02:00
parent f53bb94115
commit 2fc7821d06
3 changed files with 10 additions and 0 deletions

View File

@@ -941,6 +941,10 @@ public class HighlightUtil extends HighlightUtilBase {
isAllowed &= modifierOwnerParent instanceof PsiClass && !((PsiClass)modifierOwnerParent).isInterface();
}
if (containingClass != null && containingClass.isInterface()) {
isAllowed &= !PsiModifier.NATIVE.equals(modifier);
}
if (containingClass != null && containingClass.isAnnotationType()) {
isAllowed &= !PsiModifier.STATIC.equals(modifier);
isAllowed &= !PsiModifier.DEFAULT.equals(modifier);

View File

@@ -0,0 +1,5 @@
interface A {
default <error descr="Modifier 'native' not allowed here">native</error> void m(){}
static <error descr="Modifier 'native' not allowed here">native</error> void m1(){}
<error descr="Modifier 'native' not allowed here">native</error> void m2();
}

View File

@@ -36,6 +36,7 @@ public class Interface8MethodsHighlightingTest extends LightCodeInsightFixtureTe
public void testStaticMethodCalls() { doTest(false, false); }
public void testStaticMethodCallsAndOverloadResolution() { doTest(false, false); }
public void testDefaultMethodOverrideEquivalentObject() { doTest(false, false); }
public void testModifierNativeInInterface() { doTest(false, false); }
public void testStaticMethods() { doTest(false, false); }
public void testFinalStaticDefaultMethods() { doTest(false, false); }
public void testIDEA122720() { doTest(false, false); }