8043251: Bogus javac error: required: no arguments, found: no arguments
Reviewed-by: vromero
This commit is contained in:
parent
cd10c7278d
commit
679e485838
src/jdk.compiler/share/classes/com/sun/tools/javac
test/langtools/tools/javac
Diagnostics/8043251
diags/examples
@ -4173,17 +4173,34 @@ public class Resolve {
|
|||||||
|
|
||||||
Pair<Symbol, JCDiagnostic> c = errCandidate();
|
Pair<Symbol, JCDiagnostic> c = errCandidate();
|
||||||
Symbol ws = c.fst.asMemberOf(site, types);
|
Symbol ws = c.fst.asMemberOf(site, types);
|
||||||
return diags.create(dkind, log.currentSource(), pos,
|
|
||||||
"cant.apply.symbol",
|
// If the problem is due to type arguments, then the method parameters aren't relevant,
|
||||||
compactMethodDiags ?
|
// so use the error message that omits them to avoid confusion.
|
||||||
d -> MethodResolutionDiagHelper.rewrite(diags, pos, log.currentSource(), dkind, c.snd) : null,
|
switch (c.snd.getCode()) {
|
||||||
kindName(ws),
|
case "compiler.misc.wrong.number.type.args":
|
||||||
ws.name == names.init ? ws.owner.name : ws.name,
|
case "compiler.misc.explicit.param.do.not.conform.to.bounds":
|
||||||
methodArguments(ws.type.getParameterTypes()),
|
return diags.create(dkind, log.currentSource(), pos,
|
||||||
methodArguments(argtypes),
|
"cant.apply.symbol.noargs",
|
||||||
kindName(ws.owner),
|
compactMethodDiags ?
|
||||||
ws.owner.type,
|
d -> MethodResolutionDiagHelper.rewrite(diags, pos, log.currentSource(), dkind, c.snd) : null,
|
||||||
c.snd);
|
kindName(ws),
|
||||||
|
ws.name == names.init ? ws.owner.name : ws.name,
|
||||||
|
kindName(ws.owner),
|
||||||
|
ws.owner.type,
|
||||||
|
c.snd);
|
||||||
|
default:
|
||||||
|
return diags.create(dkind, log.currentSource(), pos,
|
||||||
|
"cant.apply.symbol",
|
||||||
|
compactMethodDiags ?
|
||||||
|
d -> MethodResolutionDiagHelper.rewrite(diags, pos, log.currentSource(), dkind, c.snd) : null,
|
||||||
|
kindName(ws),
|
||||||
|
ws.name == names.init ? ws.owner.name : ws.name,
|
||||||
|
methodArguments(ws.type.getParameterTypes()),
|
||||||
|
methodArguments(argtypes),
|
||||||
|
kindName(ws.owner),
|
||||||
|
ws.owner.type,
|
||||||
|
c.snd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -233,6 +233,11 @@ compiler.err.switch.expression.no.result.expressions=\
|
|||||||
compiler.err.call.must.be.first.stmt.in.ctor=\
|
compiler.err.call.must.be.first.stmt.in.ctor=\
|
||||||
call to {0} must be first statement in constructor
|
call to {0} must be first statement in constructor
|
||||||
|
|
||||||
|
# 0: symbol kind, 1: name, 2: symbol kind, 3: type, 4: message segment
|
||||||
|
compiler.err.cant.apply.symbol.noargs=\
|
||||||
|
{0} {1} in {2} {3} cannot be applied to given types;\n\
|
||||||
|
reason: {4}
|
||||||
|
|
||||||
# 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment
|
# 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment
|
||||||
compiler.err.cant.apply.symbol=\
|
compiler.err.cant.apply.symbol=\
|
||||||
{0} {1} in {4} {5} cannot be applied to given types;\n\
|
{0} {1} in {4} {5} cannot be applied to given types;\n\
|
||||||
|
10
test/langtools/tools/javac/Diagnostics/8043251/T8043251.java
Normal file
10
test/langtools/tools/javac/Diagnostics/8043251/T8043251.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* @test /nodynamiccopyright/
|
||||||
|
* @bug 8043251
|
||||||
|
* @summary Confusing error message with wrong number of type parameters
|
||||||
|
* @compile/fail/ref=T8043251.out -XDrawDiagnostics T8043251.java
|
||||||
|
*/
|
||||||
|
import java.util.function.Function;
|
||||||
|
class T8043251 {
|
||||||
|
Function<String, String> f = Function.<String, String>identity();
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
T8043251.java:9:42: compiler.err.cant.apply.symbol.noargs: kindname.method, identity, kindname.interface, java.util.function.Function<T,R>, (compiler.misc.wrong.number.type.args: 1)
|
||||||
|
1 error
|
@ -21,7 +21,7 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.cant.apply.symbol
|
// key: compiler.err.cant.apply.symbol.noargs
|
||||||
// key: compiler.misc.explicit.param.do.not.conform.to.bounds
|
// key: compiler.misc.explicit.param.do.not.conform.to.bounds
|
||||||
|
|
||||||
class ExplicitParamsDoNotConformToBounds {
|
class ExplicitParamsDoNotConformToBounds {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.cant.apply.symbol
|
// key: compiler.err.cant.apply.symbol.noargs
|
||||||
// key: compiler.misc.wrong.number.type.args
|
// key: compiler.misc.wrong.number.type.args
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user