strictfp in interfaces for java 1.8 (IDEA-138501)

This commit is contained in:
Anna Kozlova
2015-03-31 13:48:27 +02:00
parent a4eba96102
commit b0db0e5444
3 changed files with 17 additions and 2 deletions
@@ -886,11 +886,17 @@ public class HighlightUtil extends HighlightUtilBase {
isAllowed = false;
}
if (PsiModifier.PRIVATE.equals(modifier) || PsiModifier.PROTECTED.equals(modifier) || PsiModifier.TRANSIENT.equals(modifier) ||
PsiModifier.STRICTFP.equals(modifier) || PsiModifier.SYNCHRONIZED.equals(modifier)) {
if (PsiModifier.PRIVATE.equals(modifier)) {
isAllowed &= modifierOwnerParent instanceof PsiClass &&
(!((PsiClass)modifierOwnerParent).isInterface() || PsiUtil.isLanguageLevel9OrHigher(modifierOwner));
}
else if (PsiModifier.STRICTFP.equals(modifier)) {
isAllowed &= modifierOwnerParent instanceof PsiClass && (!((PsiClass)modifierOwnerParent).isInterface() || PsiUtil.isLanguageLevel8OrHigher(modifierOwner));
}
else if (PsiModifier.PROTECTED.equals(modifier) || PsiModifier.TRANSIENT.equals(modifier) ||
PsiModifier.SYNCHRONIZED.equals(modifier)) {
isAllowed &= modifierOwnerParent instanceof PsiClass && !((PsiClass)modifierOwnerParent).isInterface();
}
if (containingClass != null && containingClass.isAnnotationType()) {
isAllowed &= !PsiModifier.STATIC.equals(modifier);
@@ -0,0 +1,5 @@
interface A {
<error descr="Illegal combination of modifiers: 'strictfp' and 'abstract'">strictfp</error> void m();
strictfp default void m1(){}
strictfp static void m2() {}
}
@@ -43,6 +43,10 @@ public class LightAdvHighlightingJdk8Test extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testStrictfpInsideInterface() throws Exception {
doTest();
}
private void doTest() {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false);