提交 4465f285 编写于 作者: M mcimadamore

7151802: compiler update caused sqe test failed

Summary: Fix regression caused by 7144506
Reviewed-by: jjg, dlsmith
上级 703816f5
......@@ -2725,6 +2725,8 @@ public class Attr extends JCTree.Visitor {
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 @@ public class Attr extends JCTree.Visitor {
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);
}
}
......
......@@ -755,8 +755,8 @@ public class Check {
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 @@ public class Check {
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 @@ public class Check {
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 @@ public class Check {
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),
......
......@@ -385,7 +385,6 @@ public class Infer {
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 @@ public class Infer {
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));
}
};
}
......
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
......
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
......
/*
* @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); }
}
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册