mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
java 8 interfaces: default/static preferences (IDEA-136171)
This commit is contained in:
@@ -307,9 +307,11 @@ public class PsiSuperMethodImplUtil {
|
||||
if (superClass != null) {
|
||||
if (superClass.isInterface() ||
|
||||
CommonClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName())) {
|
||||
if (superMethod.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (superMethod.hasModifierProperty(PsiModifier.STATIC) ||
|
||||
superMethod.hasModifierProperty(PsiModifier.DEFAULT) && hierarchicalMethodSignature.getMethod().hasModifierProperty(PsiModifier.STATIC)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (superMethod.hasModifierProperty(PsiModifier.DEFAULT) ||
|
||||
hierarchicalMethodSignature.getMethod().hasModifierProperty(PsiModifier.DEFAULT)) {
|
||||
return !InheritanceUtil.isInheritorOrSelf(superClass, containingClass, true);
|
||||
|
||||
+7
@@ -534,6 +534,13 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
return Specifics.FIRST;
|
||||
}
|
||||
|
||||
if (method1.hasModifierProperty(PsiModifier.DEFAULT) && method2.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
return Specifics.FIRST;
|
||||
}
|
||||
|
||||
if (method2.hasModifierProperty(PsiModifier.DEFAULT) && method1.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
return Specifics.SECOND;
|
||||
}
|
||||
}
|
||||
|
||||
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && myArgumentsList instanceof PsiExpressionList && (typeParameters1.length == 0 || typeParameters2.length == 0)) {
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
class Test {
|
||||
interface I {
|
||||
default void f() {}
|
||||
}
|
||||
|
||||
interface J {
|
||||
static void f() {}
|
||||
}
|
||||
|
||||
static class IJ implements I, J {}
|
||||
static class JI implements J, I {}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new IJ(). f();
|
||||
new JI(). f();
|
||||
J.f();
|
||||
}
|
||||
}
|
||||
+4
@@ -79,6 +79,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPreferDefaultMethodsOverStatic() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user