mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8013222: Javac issues spurious raw type warnings when lambda has implicit parameter types
Bad warnings and position for lambda inferred parameter types Reviewed-by: jjg, vromero
This commit is contained in:
parent
fc9e870275
commit
4b1aa379e5
3 changed files with 35 additions and 2 deletions
|
@ -1056,7 +1056,10 @@ public class Attr extends JCTree.Visitor {
|
|||
Lint prevLint = chk.setLint(lint);
|
||||
|
||||
// Check that the variable's declared type is well-formed.
|
||||
chk.validate(tree.vartype, env);
|
||||
boolean isImplicitLambdaParameter = env.tree.hasTag(LAMBDA) &&
|
||||
((JCLambda)env.tree).paramKind == JCLambda.ParameterKind.IMPLICIT &&
|
||||
(tree.sym.flags() & PARAMETER) != 0;
|
||||
chk.validate(tree.vartype, env, !isImplicitLambdaParameter);
|
||||
deferredLintHandler.flush(tree.pos());
|
||||
|
||||
try {
|
||||
|
@ -2344,7 +2347,7 @@ public class Attr extends JCTree.Visitor {
|
|||
Type argType = arityMismatch ?
|
||||
syms.errType :
|
||||
actuals.head;
|
||||
params.head.vartype = make.Type(argType);
|
||||
params.head.vartype = make.at(params.head).Type(argType);
|
||||
params.head.sym = null;
|
||||
actuals = actuals.isEmpty() ?
|
||||
actuals :
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8013222
|
||||
* @summary Javac issues spurious raw type warnings when lambda has implicit parameter types
|
||||
* @compile/fail/ref=NoWarnOnImplicitParams.out -Xlint:rawtypes -Werror -XDrawDiagnostics NoWarnOnImplicitParams.java
|
||||
*/
|
||||
import java.util.List;
|
||||
|
||||
class NoWarnOnImplicitParams {
|
||||
|
||||
public void testRawMerge(List<String> ls) {
|
||||
R12 r12_1 = l->"Foo";
|
||||
R12 r12_2 = (List l)->"Foo";
|
||||
}
|
||||
|
||||
interface R1 {
|
||||
Object m(List<String> ls);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
interface R2 {
|
||||
String m(List l);
|
||||
}
|
||||
|
||||
interface R12 extends R1, R2 {}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
NoWarnOnImplicitParams.java:13:22: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
|
||||
- compiler.err.warnings.and.werror
|
||||
1 error
|
||||
1 warning
|
Loading…
Add table
Add a link
Reference in a new issue