8013222: Javac issues spurious raw type warnings when lambda has implicit parameter types
authormcimadamore
Wed, 15 May 2013 14:03:09 +0100
changeset 17584 3c4dfe34c2ec
parent 17583 91949b5f7651
child 17585 bf56a85f3897
8013222: Javac issues spurious raw type warnings when lambda has implicit parameter types Summary: Bad warnings and position for lambda inferred parameter types Reviewed-by: jjg, vromero
langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
langtools/test/tools/javac/lambda/NoWarnOnImplicitParams.java
langtools/test/tools/javac/lambda/NoWarnOnImplicitParams.out
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed May 15 14:02:37 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed May 15 14:03:09 2013 +0100
@@ -1056,7 +1056,10 @@
         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 @@
                     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 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/NoWarnOnImplicitParams.java	Wed May 15 14:03:09 2013 +0100
@@ -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 {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/NoWarnOnImplicitParams.out	Wed May 15 14:03:09 2013 +0100
@@ -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