static methods in interfaces can't be hidden in subclasses (IDEA-124921)

This commit is contained in:
Anna Kozlova
2014-05-12 13:08:28 +04:00
parent 26baf8f596
commit 5bf5dd0450
4 changed files with 15 additions and 0 deletions

View File

@@ -540,6 +540,11 @@ public class GenericsHighlightUtil {
return null;
}
if (superMethod.hasModifierProperty(PsiModifier.STATIC) && superContainingClass != null &&
superContainingClass.isInterface() && PsiUtil.isLanguageLevel8OrHigher(superContainingClass)) {
return null;
}
final PsiType retErasure1 = TypeConversionUtil.erasure(checkMethod.getReturnType());
final PsiType retErasure2 = TypeConversionUtil.erasure(superMethod.getReturnType());

View File

@@ -1142,6 +1142,7 @@ public class HighlightMethodUtil {
}
if (isMethodStatic) {
if (superClass.isInterface()) return null;
int accessLevel = PsiUtil.getAccessLevel(modifierList);
String accessModifier = PsiUtil.getAccessModifier(accessLevel);
HighlightInfo info = isWeaker(method, modifierList, accessModifier, accessLevel, superMethod, true);

View File

@@ -0,0 +1,8 @@
interface StaticBase<T> {
static <T> void foo(T t) {}
}
class Foo implements StaticBase<Number> {
static <T> void foo(T t){}
}

View File

@@ -39,6 +39,7 @@ public class Interface8MethodsHighlightingTest extends LightCodeInsightFixtureTe
public void testFinalStaticDefaultMethods() { doTest(false, false); }
public void testIDEA122720() { doTest(false, false); }
public void testIDEA123839() { doTest(false, false); }
public void testStaticOverloading() { doTest(false, false); }
public void testDefaultSupersInStaticContext() {
doTest(false, false);
}