IDEA-386847 [java]: add default modifier when making interface method non-static

GitOrigin-RevId: fde665d19cdb6fef9cf81e81c93ac8ddcf05789f
This commit is contained in:
Bas Leijdekkers
2026-03-27 09:44:38 +00:00
committed by intellij-monorepo-bot
parent 873ef84318
commit fc7c77754e
4 changed files with 32 additions and 0 deletions
@@ -238,6 +238,14 @@ public class ModifierFix extends PsiBasedModCommandAction<PsiModifierListOwner>
removeFinalModifierFromMethods(aClass);
}
}
else {
if (owner instanceof PsiMethod method && PsiModifier.STATIC.equals(myModifier)) {
PsiClass containingClass = method.getContainingClass();
if (containingClass != null && containingClass.isInterface()) {
modifierList.setModifierProperty(PsiModifier.DEFAULT, true);
}
}
}
changeModifierList(modifierList);
}
@@ -0,0 +1,8 @@
// "Make 'y())' not static" "false"
abstract interface Interface {
int f();
static void y() {
<caret>f(); // <- Error
}
}
@@ -0,0 +1,8 @@
// "Make 'y()' not static" "true"
abstract interface Interface {
int f();
default void y() {
f(); // <- Error
}
}
@@ -0,0 +1,8 @@
// "Make 'y()' not static" "true"
abstract interface Interface {
int f();
static void y() {
<caret>f(); // <- Error
}
}