// Test (5): if symbol is an instance method of a raw type, issue
// an unchecked warning if its argument types change under erasure.
if (allowGenerics &&
(sym.flags() & STATIC) == 0 &&
(site.tag == CLASS || site.tag == TYPEVAR)) {
Type s = types.asOuterSuper(site, sym.owner);
if (s != null && s.isRaw() &&
!types.isSameTypes(sym.type.getParameterTypes(),
sym.erasure(types).getParameterTypes())) {
chk.warnUnchecked(env.tree.pos(),
"unchecked.call.mbr.of.raw.type",
sym, s);
}
}
// Compute the identifier's instantiated type.
// For methods, we need to compute the instance type by
// Resolve.instantiate from the symbol's type as well as
// any type arguments and value arguments.
noteWarner.clear();
Type owntype = rs.instantiate(env,
site,
sym,
argtypes,
typeargtypes,
true,
useVarargs,
noteWarner);
boolean warned = noteWarner.hasNonSilentLint(LintCategory.UNCHECKED);
// If this fails, something went wrong; we should not have
// found the identifier in the first place.
if (owntype == null) {
if (!pt.isErroneous())
log.error(env.tree.pos(),
"internal.error.cant.instantiate",
sym, site,
Type.toString(pt.getParameterTypes()));
owntype = types.createErrorType(site);
} else {
// System.out.println("call : " + env.tree);
// System.out.println("method : " + owntype);
// System.out.println("actuals: " + argtypes);
List<Type> formals = owntype.getParameterTypes();
Type last = useVarargs ? formals.last() : null;
if (sym.name==names.init &&
sym.owner == syms.enumSym)
formals = formals.tail.tail;
List<JCExpression> args = argtrees;
while (formals.head != last) {
JCTree arg = args.head;
Warner warn = chk.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;
}
if (useVarargs) {
Type varArg = types.elemtype(last);
while (args.tail != null) {
JCTree arg = args.head;
Warner warn = chk.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) {
// non-varargs call to varargs method
Type varParam = owntype.getParameterTypes().last();
Type lastArg = argtypes.last();
if (types.isSubtypeUnchecked(lastArg, types.elemtype(varParam)) &&
!types.isSameType(types.erasure(varParam), types.erasure(lastArg)))
log.warning(argtrees.last().pos(), "inexact.non-varargs.call",
types.elemtype(varParam),
varParam);
}
if (warned && sym.type.tag == FORALL) {
chk.warnUnchecked(env.tree.pos(),
"unchecked.meth.invocation.applied",
kindName(sym),
sym.name,
rs.methodArguments(sym.type.getParameterTypes()),
rs.methodArguments(argtypes),
kindName(sym.location()),
sym.location());
owntype = new MethodType(owntype.getParameterTypes(),
types.erasure(owntype.getReturnType()),
types.erasure(owntype.getThrownTypes()),
syms.methodClass);
}
if (useVarargs) {
JCTree tree = env.tree;
Type argtype = owntype.getParameterTypes().last();
if (owntype.getReturnType().tag != FORALL || warned) {
chk.checkVararg(env.tree.pos(), owntype.getParameterTypes(), sym);
}
Type elemtype = types.elemtype(argtype);
switch (tree.getTag()) {
case JCTree.APPLY:
((JCMethodInvocation) tree).varargsElement = elemtype;
break;
case JCTree.NEWCLASS: