mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 02:09:59 +07:00
fix method hierarchy with default methods: mark method to implement if it abstract and overrides default method (IDEA-101167)
This commit is contained in:
@@ -271,9 +271,10 @@ public class PsiSuperMethodImplUtil {
|
||||
if (superClass != null) {
|
||||
if (superClass.isInterface() ||
|
||||
CommonClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName())) {
|
||||
if (!superMethod.hasModifierProperty(PsiModifier.DEFAULT) || !InheritanceUtil.isInheritorOrSelf(superClass, containingClass, true)) {
|
||||
return true;
|
||||
if (superMethod.hasModifierProperty(PsiModifier.DEFAULT) || hierarchicalMethodSignature.getMethod().hasModifierProperty(PsiModifier.DEFAULT)) {
|
||||
return !InheritanceUtil.isInheritorOrSelf(superClass, containingClass, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (containingClass != null) {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
enum StreamShape {
|
||||
REFERENCE,
|
||||
INT_VALUE,
|
||||
LONG_VALUE,
|
||||
DOUBLE_VALUE;
|
||||
}
|
||||
|
||||
interface TerminalSink<T, R> extends Sink<T> {
|
||||
R getAndClearState();
|
||||
}
|
||||
interface IntConsumer {
|
||||
public void accept(int value);
|
||||
}
|
||||
|
||||
interface Consumer<T> {
|
||||
public void accept(T t);
|
||||
}
|
||||
|
||||
class ForEachOp<T> {
|
||||
|
||||
protected ForEachOp(TerminalSink<T, Void> sink, StreamShape shape) {}
|
||||
|
||||
protected interface VoidTerminalSink<T> extends TerminalSink<T, Void> {
|
||||
default public Void getAndClearState() {
|
||||
return null;
|
||||
}
|
||||
public interface OfInt extends VoidTerminalSink<Integer>, Sink.OfInt{}
|
||||
}
|
||||
|
||||
<error descr="Class 'Foo' must either be declared abstract or implement abstract method 'accept(int)' in 'OfInt'">class Foo implements VoidTerminalSink.OfInt</error> {}
|
||||
|
||||
public static <T> ForEachOp<T> make(final Consumer<? super T> consumer) {
|
||||
return new ForEachOp<>((VoidTerminalSink<T>) consumer::accept, StreamShape.REFERENCE);
|
||||
}
|
||||
|
||||
public static void make(final IntConsumer consumer) {
|
||||
VoidTerminalSink.OfInt accept = consumer::accept;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface Sink<T> extends Consumer<T> {
|
||||
default void accept(int value) {}
|
||||
interface OfInt extends Sink<Integer>, IntConsumer {
|
||||
void accept(int value);
|
||||
default void accept(Integer i) {}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ public class Interface8MethodsHighlightingTest extends LightDaemonAnalyzerTestCa
|
||||
public void testDefaultMethodVisibility() { doTest(true, false); }
|
||||
public void testInheritUnrelatedDefaults() { doTest(true, false); }
|
||||
public void testExtensionMethods() { doTest(false, false); }
|
||||
public void testInheritDefaultMethodInInterface() { doTest(false, false); }
|
||||
|
||||
public void testExtensionMethodSyntax() {
|
||||
enableInspectionTools(DeprecatedDefenderSyntaxInspection.class);
|
||||
|
||||
Reference in New Issue
Block a user