7182350: Regression in wording of unchecked warning message
Reviewed-by: mcimadamore, jjg
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Aug 19 07:47:10 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Aug 20 17:34:06 2013 +0400
@@ -875,19 +875,23 @@
}
Type owntype = mtype;
List<Type> formals = owntype.getParameterTypes();
+ List<Type> nonInferred = sym.type.getParameterTypes();
+ if (nonInferred.length() != formals.length()) nonInferred = formals;
Type last = useVarargs ? formals.last() : null;
- if (sym.name == names.init &&
- sym.owner == syms.enumSym)
- formals = formals.tail.tail;
+ if (sym.name == names.init && sym.owner == syms.enumSym) {
+ formals = formals.tail.tail;
+ nonInferred = nonInferred.tail.tail;
+ }
List<JCExpression> args = argtrees;
if (args != null) {
//this is null when type-checking a method reference
while (formals.head != last) {
JCTree arg = args.head;
- Warner warn = convertWarner(arg.pos(), arg.type, formals.head);
+ Warner warn = convertWarner(arg.pos(), arg.type, nonInferred.head);
assertConvertible(arg, arg.type, formals.head, warn);
args = args.tail;
formals = formals.tail;
+ nonInferred = nonInferred.tail;
}
if (useVarargs) {
Type varArg = types.elemtype(last);
@@ -903,17 +907,17 @@
Type varParam = owntype.getParameterTypes().last();
Type lastArg = argtypes.last();
if (types.isSubtypeUnchecked(lastArg, types.elemtype(varParam)) &&
- !types.isSameType(types.erasure(varParam), types.erasure(lastArg)))
+ !types.isSameType(types.erasure(varParam), types.erasure(lastArg)))
log.warning(argtrees.last().pos(), "inexact.non-varargs.call",
- types.elemtype(varParam), varParam);
+ types.elemtype(varParam), varParam);
}
}
if (useVarargs) {
Type argtype = owntype.getParameterTypes().last();
if (!types.isReifiable(argtype) &&
- (!allowSimplifiedVarargs ||
- sym.attribute(syms.trustMeType.tsym) == null ||
- !isTrustMeAllowedOnMethod(sym))) {
+ (!allowSimplifiedVarargs ||
+ sym.attribute(syms.trustMeType.tsym) == null ||
+ !isTrustMeAllowedOnMethod(sym))) {
warnUnchecked(env.tree.pos(),
"unchecked.generic.array.creation",
argtype);
@@ -929,15 +933,15 @@
return owntype;
}
//where
- private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) {
- if (types.isConvertible(actual, formal, warn))
- return;
-
- if (formal.isCompound()
- && types.isSubtype(actual, types.supertype(formal))
- && types.isSubtypeUnchecked(actual, types.interfaces(formal), warn))
- return;
- }
+ private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) {
+ if (types.isConvertible(actual, formal, warn))
+ return;
+
+ if (formal.isCompound()
+ && types.isSubtype(actual, types.supertype(formal))
+ && types.isSubtypeUnchecked(actual, types.interfaces(formal), warn))
+ return;
+ }
/**
* Check that type 't' is a valid instantiation of a generic class
--- a/langtools/test/tools/javac/6758789/T6758789b.out Mon Aug 19 07:47:10 2013 -0700
+++ b/langtools/test/tools/javac/6758789/T6758789b.out Tue Aug 20 17:34:06 2013 +0400
@@ -1,5 +1,5 @@
T6758789b.java:16:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo<X>, T6758789a.Foo, kindname.class, T6758789a
-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>
- compiler.err.warnings.and.werror
1 error
2 warnings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7182350/T7182350.java Tue Aug 20 17:34:06 2013 +0400
@@ -0,0 +1,14 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 7182350
+ * @summary verify correct output of -Xlint:unchecked on methods with unchecked conversations in parameters
+ * @compile/ref=T7182350.out -XDrawDiagnostics -Xlint:unchecked T7182350.java
+ */
+
+import java.util.*;
+
+class T7182350 {
+ public static void quicksort(Vector vector, Comparator compare) {
+ Collections.sort(vector,compare);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7182350/T7182350.out Tue Aug 20 17:34:06 2013 +0400
@@ -0,0 +1,4 @@
+T7182350.java:12:25: compiler.warn.unchecked.meth.invocation.applied: kindname.method, sort, java.util.List<T>,java.util.Comparator<? super T>, java.util.Vector,java.util.Comparator, kindname.class, java.util.Collections
+T7182350.java:12:26: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.Vector, java.util.List<T>
+T7182350.java:12:33: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.Comparator, java.util.Comparator<? super T>
+3 warnings
--- a/langtools/test/tools/javac/generics/7015430/T7015430_1.out Mon Aug 19 07:47:10 2013 -0700
+++ b/langtools/test/tools/javac/generics/7015430/T7015430_1.out Tue Aug 20 17:34:06 2013 +0400
@@ -1,13 +1,13 @@
T7015430.java:42:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
T7015430.java:42:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
T7015430.java:51:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:51:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:51:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
T7015430.java:69:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
T7015430.java:69:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
T7015430.java:78:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:78:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:78:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
T7015430.java:105:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:105:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:105:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
T7015430.java:114:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
T7015430.java:114:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
T7015430.java:42:14: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
--- a/langtools/test/tools/javac/generics/7015430/T7015430_2.out Mon Aug 19 07:47:10 2013 -0700
+++ b/langtools/test/tools/javac/generics/7015430/T7015430_2.out Tue Aug 20 17:34:06 2013 +0400
@@ -1,15 +1,15 @@
T7015430.java:42:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:42:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:42:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
T7015430.java:51:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:51:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:51:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
T7015430.java:69:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:69:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:69:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
T7015430.java:78:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:78:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:78:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
T7015430.java:105:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:105:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:105:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
T7015430.java:114:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:114:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:114:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
T7015430.java:130:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
1 error
12 warnings
--- a/langtools/test/tools/javac/generics/7151802/T7151802.out Mon Aug 19 07:47:10 2013 -0700
+++ b/langtools/test/tools/javac/generics/7151802/T7151802.out Tue Aug 20 17:34:06 2013 +0400
@@ -1,6 +1,6 @@
T7151802.java:14:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get1, Z, T7151802.Foo, kindname.class, T7151802
T7151802.java:22:30: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get3, T7151802.Foo<Z>, T7151802.Foo, kindname.class, T7151802
-T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<java.lang.Object>
+T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<Z>
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:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get7, T7151802.Foo<java.lang.String>, T7151802.Foo, kindname.class, T7151802
T7151802.java:38:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<java.lang.String>
--- a/langtools/test/tools/javac/generics/inference/6718364/T6718364.out Mon Aug 19 07:47:10 2013 -0700
+++ b/langtools/test/tools/javac/generics/inference/6718364/T6718364.out Tue Aug 20 17:34:06 2013 +0400
@@ -1,3 +1,3 @@
T6718364.java:13:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6718364.X<T>,T, T6718364.X<T6718364.X<java.lang.Integer>>,T6718364.X, kindname.class, T6718364
-T6718364.java:13:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6718364.X, T6718364.X<java.lang.Integer>
+T6718364.java:13:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6718364.X, T
2 warnings
--- a/langtools/test/tools/javac/generics/inference/7177306/T7177306a.out Mon Aug 19 07:47:10 2013 -0700
+++ b/langtools/test/tools/javac/generics/inference/7177306/T7177306a.out Tue Aug 20 17:34:06 2013 +0400
@@ -1,5 +1,5 @@
T7177306a.java:13:33: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, java.util.List<E>, java.util.List, kindname.class, T7177306a
-T7177306a.java:13:34: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.List, java.util.List<java.lang.Object>
+T7177306a.java:13:34: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.List, java.util.List<E>
T7177306a.java:13:33: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7177306a, T7177306a<java.lang.Object>
- compiler.err.warnings.and.werror
1 error