[java] improve error message (IDEA-223692)

GitOrigin-RevId: df344c76be34232b3dc682d36b9d233ab2a6d54f
This commit is contained in:
Bas Leijdekkers
2024-03-08 16:19:52 +01:00
committed by intellij-monorepo-bot
parent 17d30e0697
commit d19410735d
6 changed files with 13 additions and 13 deletions

View File

@@ -4,7 +4,7 @@ import static p.Boo.*;
class FooImpl implements Foo, Boo {
public void baz() {
<error descr="Static method may be invoked on containing interface class only">foo();</error>
<error descr="Static method may only be called on its containing interface">foo();</error>
bar();
boo();
}

View File

@@ -1,7 +1,7 @@
import static p.Foo.FooEx.<error descr="Static method may be invoked on containing interface class only">foo</error>;
import static p.Foo.FooEx.<error descr="Static method may only be called on its containing interface">foo</error>;
class FooImpl {
public void baz() {
<error descr="Static method may be invoked on containing interface class only">foo();</error>
<error descr="Static method may only be called on its containing interface">foo();</error>
}
}

View File

@@ -11,16 +11,16 @@ class Bug {
interface IFunction extends Function<Integer, Integer> {
static void a() {
Function<Integer, Integer> identity = <error descr="Static method may be invoked on containing interface class only">identity();</error>
Function<Integer, Integer> identity = <error descr="Static method may only be called on its containing interface">identity();</error>
}
}
public void foo() {
Function<Integer, Integer> f = Function.identity();
Function<Integer, Integer> g = <error descr="Static method may be invoked on containing interface class only">f.identity();</error>
Function<Integer, Integer> g = <error descr="Static method may only be called on its containing interface">f.identity();</error>
Function<Integer, Integer> h = IFunction.<error descr="Static method may be invoked on containing interface class only">identity</error>();
Function<Integer, Integer> h = IFunction.<error descr="Static method may only be called on its containing interface">identity</error>();
}
}
@@ -40,15 +40,15 @@ class StaticMethodInterfaceExample {
}
public <T extends MyImplementation> void doStuff1() {
<error descr="Static method may be invoked on containing interface class only">T.staticMethod();</error>
<error descr="Static method may only be called on its containing interface">T.staticMethod();</error>
}
public <T extends MyInterface & X> void doStuff2() {
<error descr="Static method may be invoked on containing interface class only">T.staticMethod();</error>
<error descr="Static method may only be called on its containing interface">T.staticMethod();</error>
}
public <T extends MyImplementation & MyInterface> void doStuff3() {
<error descr="Static method may be invoked on containing interface class only">T.staticMethod();</error>
<error descr="Static method may only be called on its containing interface">T.staticMethod();</error>
}
}
}

View File

@@ -4,8 +4,8 @@ interface I {
class A implements I {
{
System.out.println(A./*c1*/<error descr="Static method may be invoked on containing interface class only">foo</error>());
Runnable r = <error descr="Static method may be invoked on containing interface class only">A/*c2*/::<String>foo;</error>
System.out.println(A./*c1*/<error descr="Static method may only be called on its containing interface">foo</error>());
Runnable r = <error descr="Static method may only be called on its containing interface">A/*c2*/::<String>foo;</error>
System.out.println(r);
}
}

View File

@@ -39,7 +39,7 @@ class Test2 {
public static void main(IJ s, J<String> j) {
s.f("");
<error descr="Static method may be invoked on containing interface class only">j.j("");</error>
<error descr="Static method may only be called on its containing interface">j.j("");</error>
}
}