mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 08:06:56 +07:00
Java: better error message when there are more arguments than parameters (IDEA-336129)
GitOrigin-RevId: a17a5f0f3878b9baf211737a614d1aa1a5103d31
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ed3ae46a60
commit
6916b6b005
@@ -27,5 +27,5 @@ class Base {
|
||||
|
||||
class Derived extends Base {
|
||||
final static Object o1 = <error descr="Non-static method 'getObject()' cannot be referenced from a static context">getObject</error>(null);
|
||||
final Object o2 = getObject<error descr="'getObject()' in 'P1.Base' cannot be applied to '(null)'">(null)</error>;
|
||||
final Object o2 = getObject<error descr="Expected no arguments but found 1">(null)</error>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class WrongNumberOfArguments {
|
||||
|
||||
void fun1(String str, Consumer<String> onFinish) { }
|
||||
void getStr(String asd) { }
|
||||
|
||||
void asd() {
|
||||
int asd = 1;
|
||||
fun1("text", s -> getStr(s), <error descr="Expected 2 arguments but found 3">asd</error>);
|
||||
}
|
||||
}
|
||||
@@ -222,8 +222,8 @@ class NestedEnums {
|
||||
}
|
||||
|
||||
enum EnumWithoutExpectedArguments {
|
||||
<error descr="'EnumWithoutExpectedArguments(int)' in 'EnumWithoutExpectedArguments' cannot be applied to '()'">ONE</error>, //comment
|
||||
<error descr="'EnumWithoutExpectedArguments(int)' in 'EnumWithoutExpectedArguments' cannot be applied to '()'">TWO</error>
|
||||
<error descr="Expected 1 argument but found 0">ONE</error>, //comment
|
||||
<error descr="Expected 1 argument but found 0">TWO</error>
|
||||
;
|
||||
EnumWithoutExpectedArguments(int a) {}
|
||||
}
|
||||
@@ -13,6 +13,6 @@ class Test2 {}
|
||||
|
||||
class Test {
|
||||
public void test(TestIF<?> testIF) {
|
||||
testIF.run<error descr="'run(capture<?>)' in 'TestIF' cannot be applied to '()'">()</error>;
|
||||
testIF.run<error descr="Expected 1 argument but found 0">()</error>;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ class Main {
|
||||
<T extends Serializable> void m(Object[] obj) {
|
||||
List<?> r1 = foo(null);
|
||||
List<? extends Serializable> r2 = foo(null);
|
||||
List<? super String> r3 = foo<error descr="'foo(? super java.lang.String & java.lang.Runnable)' in 'Main' cannot be applied to '()'">( )</error>;
|
||||
List<? super String> r3 = foo<error descr="Expected 1 argument but found 0">( )</error>;
|
||||
List<? extends Runnable> r4 = foo(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Test {
|
||||
private <<error descr="Cyclic inheritance involving 'S'"></error>S extends K, K extends S> S b(S s) {
|
||||
|
||||
if (true) return b <error descr="'b(S)' in 'Test' cannot be applied to '()'">()</error>;
|
||||
if (true) return b <error descr="Expected 1 argument but found 0">()</error>;
|
||||
<error descr="Missing return statement">}</error>
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
class Test{
|
||||
void test() {
|
||||
B b = new B<error descr="'B(java.lang.String, java.lang.String)' in 'Test.B' cannot be applied to '(java.lang.String)'">(true == false ? "bar" : null)</error>;
|
||||
B b = new B<error descr="Expected 2 arguments but found 1">(true == false ? "bar" : null)</error>;
|
||||
}
|
||||
|
||||
class B {
|
||||
|
||||
@@ -13,6 +13,6 @@ class Test2 {}
|
||||
|
||||
class Test {
|
||||
public void test(TestIF<?> testIF) {
|
||||
testIF.run<error descr="'run(capture<?>)' in 'TestIF' cannot be applied to '()'">()</error>;
|
||||
testIF.run<error descr="Expected 1 argument but found 0">()</error>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import java.util.function.UnaryOperator;
|
||||
|
||||
class Test<T> {
|
||||
private void example() {
|
||||
update(x -> x.flatMap<error descr="'flatMap()' in 'Test' cannot be applied to '(<lambda expression>)'">(y -> getEmpty())</error>);
|
||||
update(x -> x.flatMap<error descr="Expected no arguments but found 1">(y -> getEmpty())</error>);
|
||||
}
|
||||
|
||||
private <J> Test<J> flatMap() {
|
||||
|
||||
@@ -5,7 +5,7 @@ class R<T> {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
test(new R<>.O<error descr="'O(java.lang.Object)' in 'R.O' cannot be applied to '()'">()</error>);
|
||||
test(new R<>.O<error descr="Expected 1 argument but found 0">()</error>);
|
||||
}
|
||||
|
||||
private static void test(R.O o) { }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class A<R>{
|
||||
A(R value) {}
|
||||
public static void main(String[] args) {
|
||||
A<Integer> a = new A<><error descr="'A(R)' in 'A' cannot be applied to '(java.lang.String, int)'" tooltip="Expected 1 arguments but found 2">("hi", 1)</error>;
|
||||
A<Integer> a = new A<><error descr="Expected 1 argument but found 2" tooltip="Expected 1 argument but found 2">("hi", 1)</error>;
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ interface TypeB extends TypeA {
|
||||
|
||||
class Test {
|
||||
void foo(final TypeB typeB) {
|
||||
typeB.test<error descr="'test(java.lang.String[])' in 'TypeB' cannot be applied to '(java.lang.String, java.lang.String)'">("a", "b")</error>;
|
||||
typeB.test<error descr="Expected 1 argument but found 2">("a", "b")</error>;
|
||||
typeB.test<error descr="'test(java.lang.String[])' in 'TypeB' cannot be applied to '(java.lang.String)'">("a")</error>;
|
||||
typeB.test<error descr="'test(java.lang.String[])' in 'TypeB' cannot be applied to '()'">()</error>;
|
||||
typeB.test<error descr="Expected 1 argument but found 0">()</error>;
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,8 @@ class Test {
|
||||
varargs(1);
|
||||
varargs(1, "");
|
||||
varargs(1, "", "");
|
||||
usage<error descr="'usage(java.lang.String)' in 'Test' cannot be applied to '()'">()</error>;
|
||||
usage<error descr="Expected 1 argument but found 0">()</error>;
|
||||
usage("");
|
||||
usage<error descr="'usage(java.lang.String)' in 'Test' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>;
|
||||
usage<error descr="Expected 1 argument but found 2">("", "")</error>;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ interface ToStringBug {
|
||||
class Inner implements ToStringBug {
|
||||
|
||||
{
|
||||
toString<error descr="'toString()' in 'java.lang.Object' cannot be applied to '(java.lang.String)'">( "x")</error>;
|
||||
toString<error descr="Expected no arguments but found 1">( "x")</error>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import static java.util.Objects.toString;
|
||||
class Foo {
|
||||
|
||||
String go() {
|
||||
return toString<error descr="'toString()' in 'Foo' cannot be applied to '(java.lang.String)'">("foo")</error>;
|
||||
return toString<error descr="Expected no arguments but found 1">("foo")</error>;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
||||
@@ -9,7 +9,7 @@ public class EqualsCalled {
|
||||
void one() {
|
||||
E.A.<warning descr="'equals()' called on enum value">equals</warning>(E.C);
|
||||
E.B.<warning descr="'equals()' called on enum value">equals</warning>(new Object());
|
||||
E.C.equals<error descr="'equals(java.lang.Object)' in 'java.lang.Enum' cannot be applied to '()'">()</error>;
|
||||
E.C.equals<error descr="Expected 1 argument but found 0">()</error>;
|
||||
final Object A = new Object();
|
||||
A.equals(1);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ public class Npe {
|
||||
// Do something
|
||||
}
|
||||
|
||||
o.<warning descr="Method invocation 'equals' may produce 'NullPointerException'">equals</warning><error descr="'equals(java.lang.Object)' in 'java.lang.Object' cannot be applied to '()'">()</error>;
|
||||
o.<warning descr="Method invocation 'equals' may produce 'NullPointerException'">equals</warning><error descr="Expected 1 argument but found 0">()</error>;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.codeInsight.daemon;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
@@ -34,6 +34,7 @@ public class LightAdvHighlightingJdk8Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testLambdaExpressions() { doTest(false, true); }
|
||||
public void testUnsupportedFeatures() { doTest(false, false); }
|
||||
public void testModulesNotSupported() { doTest(false, false); }
|
||||
public void testWrongNumberOfArguments() { doTest(false, false); }
|
||||
|
||||
public void testTooManyVarargsPolyArguments() {
|
||||
doTest(true, false);
|
||||
|
||||
Reference in New Issue
Block a user