changeset 1225:97bec6ab1227

7151802: compiler update caused sqe test failed Summary: Fix regression caused by 7144506 Reviewed-by: jjg, dlsmith
author mcimadamore
date Fri, 09 Mar 2012 17:10:56 +0000
parents 83352b2e2ebc
children 08a3425f39f8 b14d9583ce92
files src/share/classes/com/sun/tools/javac/comp/Attr.java src/share/classes/com/sun/tools/javac/comp/Check.java src/share/classes/com/sun/tools/javac/comp/Infer.java test/tools/javac/6758789/T6758789b.out test/tools/javac/generics/7015430/T7015430.out test/tools/javac/generics/7151802/T7151802.java test/tools/javac/generics/7151802/T7151802.out
diffstat 7 files changed, 65 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Mar 08 08:19:58 2012 -0800
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Mar 09 17:10:56 2012 +0000
@@ -2725,6 +2725,8 @@
                                       useVarargs,
                                       noteWarner);
 
+        boolean unchecked = noteWarner.hasNonSilentLint(LintCategory.UNCHECKED);
+
         // If this fails, something went wrong; we should not have
         // found the identifier in the first place.
         if (owntype == null) {
@@ -2735,10 +2737,10 @@
                           Type.toString(pt().getParameterTypes()));
             owntype = types.createErrorType(site);
             return types.createErrorType(site);
-        } else if (owntype.getReturnType().tag == FORALL) {
+        } else if (owntype.getReturnType().tag == FORALL && !unchecked) {
             return owntype;
         } else {
-            return chk.checkMethod(owntype, sym, env, argtrees, argtypes, useVarargs);
+            return chk.checkMethod(owntype, sym, env, argtrees, argtypes, useVarargs, unchecked);
         }
     }
 
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Mar 08 08:19:58 2012 -0800
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Mar 09 17:10:56 2012 +0000
@@ -755,8 +755,8 @@
                             Env<AttrContext> env,
                             final List<JCExpression> argtrees,
                             List<Type> argtypes,
-                            boolean useVarargs) {
-        boolean warned = false;
+                            boolean useVarargs,
+                            boolean unchecked) {
         // System.out.println("call   : " + env.tree);
         // System.out.println("method : " + owntype);
         // System.out.println("actuals: " + argtypes);
@@ -770,7 +770,6 @@
             JCTree arg = args.head;
             Warner warn = convertWarner(arg.pos(), arg.type, formals.head);
             assertConvertible(arg, arg.type, formals.head, warn);
-            warned |= warn.hasNonSilentLint(LintCategory.UNCHECKED);
             args = args.tail;
             formals = formals.tail;
         }
@@ -780,7 +779,6 @@
                 JCTree arg = args.head;
                 Warner warn = convertWarner(arg.pos(), arg.type, varArg);
                 assertConvertible(arg, arg.type, varArg, warn);
-                warned |= warn.hasNonSilentLint(LintCategory.UNCHECKED);
                 args = args.tail;
             }
         } else if ((sym.flags() & VARARGS) != 0 && allowVarargs) {
@@ -792,7 +790,7 @@
                 log.warning(argtrees.last().pos(), "inexact.non-varargs.call",
                         types.elemtype(varParam), varParam);
         }
-        if (warned) {
+        if (unchecked) {
             warnUnchecked(env.tree.pos(),
                     "unchecked.meth.invocation.applied",
                     kindName(sym),
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Mar 08 08:19:58 2012 -0800
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Fri Mar 09 17:10:56 2012 +0000
@@ -385,7 +385,6 @@
                                   final Warner warn) throws InferenceException {
         //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG
         List<Type> undetvars = Type.map(tvars, fromTypeVarFun);
-        //final List<Type> capturedArgs = types.capture(argtypes);
 
         final List<Type> capturedArgs =
                 rs.checkRawArgumentsAcceptable(env, undetvars, argtypes, mt.getParameterTypes(),
@@ -451,11 +450,12 @@
                                        types.subst(getThrownTypes(), tvars, inferred),
                                        qtype.tsym);
                     // check that actuals conform to inferred formals
+                    warn.clear();
                     checkArgumentsAcceptable(env, capturedArgs, owntype.getParameterTypes(), allowBoxing, useVarargs, warn);
                     // check that inferred bounds conform to their bounds
                     checkWithinBounds(all_tvars,
                            types.subst(inferredTypes, tvars, inferred), warn);
-                    qtype = chk.checkMethod(owntype, msym, env, TreeInfo.args(env.tree), capturedArgs, useVarargs);
+                    qtype = chk.checkMethod(owntype, msym, env, TreeInfo.args(env.tree), capturedArgs, useVarargs, warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED));
                 }
             };
         }
--- a/test/tools/javac/6758789/T6758789b.out	Thu Mar 08 08:19:58 2012 -0800
+++ b/test/tools/javac/6758789/T6758789b.out	Fri Mar 09 17:10:56 2012 +0000
@@ -1,4 +1,4 @@
-T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<java.lang.Object>
+T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<X>
 T6758789b.java:16:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo<X>, T6758789a.Foo, kindname.class, T6758789a
 - compiler.err.warnings.and.werror
 1 error
--- a/test/tools/javac/generics/7015430/T7015430.out	Thu Mar 08 08:19:58 2012 -0800
+++ b/test/tools/javac/generics/7015430/T7015430.out	Fri Mar 09 17:10:56 2012 +0000
@@ -1,14 +1,14 @@
-T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.Exception>
+T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
 T7015430.java:41:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
 T7015430.java:50:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
 T7015430.java:50:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.Exception>
+T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
 T7015430.java:68:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
 T7015430.java:77:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
 T7015430.java:77:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
 T7015430.java:104:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
 T7015430.java:104:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.Exception>
+T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
 T7015430.java:113:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
 T7015430.java:41:14: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
 T7015430.java:68:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7151802/T7151802.java	Fri Mar 09 17:10:56 2012 +0000
@@ -0,0 +1,43 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     7151802
+ * @summary compiler update caused sqe test failed
+ * @compile/fail/ref=T7151802.out -Werror -Xlint:unchecked -XDrawDiagnostics T7151802.java
+ */
+class T7151802 {
+    static class Foo<X> { }
+
+    static class SubFoo<X> extends Foo<X> { }
+
+    //generic - bound - arg - non-slilent
+    <Z extends Foo<String>> void get1(Z fz) { }
+    void test1(Foo foo) { get1(foo); }
+
+    //generic - bound - arg - silent
+    <Z extends Foo<?>> void get2(Z fz) { }
+    void test2(Foo foo) { get2(foo); }
+
+    //generic - nobound - arg - non-slilent
+    <Z> void get3(Foo<Z> fz) { }
+    void test(Foo foo) { get3(foo); }
+
+    //generic - nobound - arg - slilent
+    <Z> void get4(Foo<?> fz) { }
+    void test4(Foo foo) { get4(foo); }
+
+    //generic - bound - ret - non-slilent
+    <Z extends Foo<String>> Z get5() { return null; }
+    void test5() { SubFoo sf = get5(); }
+
+    //generic - bound - ret - slilent
+    static <Z extends Foo<?>> Z get6() { return null; }
+    void test6() { SubFoo sf = get6(); }
+
+    //nogeneric - nobound - arg - non-slilent
+    void get7(Foo<String> fz) { }
+    void test7(Foo foo) { get7(foo); }
+
+    //nogeneric - nobound - arg - slilent
+    static void get8(Foo<?> fz) { }
+    void test8(Foo foo) { get8(foo); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7151802/T7151802.out	Fri Mar 09 17:10:56 2012 +0000
@@ -0,0 +1,9 @@
+T7151802.java:14:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get1, Z, T7151802.Foo, kindname.class, T7151802
+T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<Z>
+T7151802.java:22:30: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get3, T7151802.Foo<Z>, T7151802.Foo, kindname.class, T7151802
+T7151802.java:30:36: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get5, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T7151802
+T7151802.java:38:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<java.lang.String>
+T7151802.java:38:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get7, T7151802.Foo<java.lang.String>, T7151802.Foo, kindname.class, T7151802
+- compiler.err.warnings.and.werror
+1 error
+6 warnings