提交 f111fa28 编写于 作者: M mcimadamore

7166552: Inference: cleanup usage of Type.ForAll

Summary: Remove hack to callback into type-inference from assignment context
Reviewed-by: dlsmith, jjg
上级 3bd63bf0
......@@ -54,7 +54,7 @@ import static com.sun.tools.javac.code.TypeTags.*;
* package types (tag: PACKAGE, class: PackageType),
* type variables (tag: TYPEVAR, class: TypeVar),
* type arguments (tag: WILDCARD, class: WildcardType),
* polymorphic types (tag: FORALL, class: ForAll),
* generic method types (tag: FORALL, class: ForAll),
* the error type (tag: ERROR, class: ErrorType).
* </pre>
*
......@@ -1108,11 +1108,16 @@ public class Type implements PrimitiveType {
public boolean isErroneous() { return qtype.isErroneous(); }
}
/**
* The type of a generic method type. It consists of a method type and
* a list of method type-parameters that are used within the method
* type.
*/
public static class ForAll extends DelegatedType implements ExecutableType {
public List<Type> tvars;
public ForAll(List<Type> tvars, Type qtype) {
super(FORALL, qtype);
super(FORALL, (MethodType)qtype);
this.tvars = tvars;
}
......@@ -1131,34 +1136,6 @@ public class Type implements PrimitiveType {
return qtype.isErroneous();
}
/**
* Replaces this ForAll's typevars with a set of concrete Java types
* and returns the instantiated generic type. Subclasses should override
* in order to check that the list of types is a valid instantiation
* of the ForAll's typevars.
*
* @param actuals list of actual types
* @param types types instance
* @return qtype where all occurrences of tvars are replaced
* by types in actuals
*/
public Type inst(List<Type> actuals, Types types) {
return types.subst(qtype, tvars, actuals);
}
/**
* Get the type-constraints of a given kind for a given type-variable of
* this ForAll type. Subclasses should override in order to return more
* accurate sets of constraints.
*
* @param tv the type-variable for which the constraint is to be retrieved
* @param ck the constraint kind to be retrieved
* @return the list of types specified by the selected constraint
*/
public List<Type> undetvars() {
return List.nil();
}
public Type map(Mapping f) {
return f.apply(qtype);
}
......@@ -1168,7 +1145,7 @@ public class Type implements PrimitiveType {
}
public MethodType asMethodType() {
return qtype.asMethodType();
return (MethodType)qtype;
}
public void complete() {
......
......@@ -1529,7 +1529,7 @@ public class Attr extends JCTree.Visitor {
// ...and check that it is legal in the current context.
// (this will also set the tree's type)
Type mpt = newMethTemplate(argtypes, typeargtypes);
Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes);
checkId(tree.meth, site, sym, localEnv, new ResultInfo(MTH, mpt),
tree.varargsElement != null);
}
......@@ -1545,7 +1545,7 @@ public class Attr extends JCTree.Visitor {
// ... and attribute the method using as a prototype a methodtype
// whose formal argument types is exactly the list of actual
// arguments (this will also set the method symbol).
Type mpt = newMethTemplate(argtypes, typeargtypes);
Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes);
localEnv.info.varArgs = false;
Type mtype = attribExpr(tree.meth, localEnv, mpt);
......@@ -1608,8 +1608,8 @@ public class Attr extends JCTree.Visitor {
/** Obtain a method type with given argument types.
*/
Type newMethTemplate(List<Type> argtypes, List<Type> typeargtypes) {
MethodType mt = new MethodType(argtypes, null, null, syms.methodClass);
Type newMethodTemplate(Type restype, List<Type> argtypes, List<Type> typeargtypes) {
MethodType mt = new MethodType(argtypes, restype, null, syms.methodClass);
return (typeargtypes == null) ? mt : (Type)new ForAll(typeargtypes, mt);
}
......@@ -1883,25 +1883,23 @@ public class Attr extends JCTree.Visitor {
typeargtypes);
if (constructor.kind == MTH) {
clazztype = checkMethod(site,
try {
clazztype = rawCheckMethod(site,
constructor,
resultInfo,
localEnv,
tree.args,
argtypes,
typeargtypes,
localEnv.info.varArgs).getReturnType();
} else {
clazztype = syms.errType;
}
if (clazztype.tag == FORALL && !resultInfo.pt.isErroneous()) {
try {
clazztype = resultInfo.checkContext.rawInstantiatePoly((ForAll)clazztype, pt(), Warner.noWarnings);
} catch (Infer.InferenceException ex) {
} catch (Resolve.InapplicableMethodException ex) {
//an error occurred while inferring uninstantiated type-variables
resultInfo.checkContext.report(tree.clazz.pos(), clazztype, resultInfo.pt,
diags.fragment("cant.apply.diamond.1", diags.fragment("diamond", clazztype.tsym), ex.diagnostic));
clazztype = syms.errType;
}
} else {
clazztype = syms.errType;
}
return chk.checkClassType(tree.clazz.pos(), clazztype, true);
......@@ -2255,15 +2253,6 @@ public class Attr extends JCTree.Visitor {
sitesym != null &&
sitesym.name == names._super;
// If selected expression is polymorphic, strip
// type parameters and remember in env.info.tvars, so that
// they can be added later (in Attr.checkId and Infer.instantiateMethod).
if (tree.selected.type.tag == FORALL) {
ForAll pstype = (ForAll)tree.selected.type;
env.info.tvars = pstype.tvars;
site = tree.selected.type = pstype.qtype;
}
// Determine the symbol represented by the selection.
env.info.varArgs = false;
Symbol sym = selectSym(tree, sitesym, site, env, resultInfo);
......@@ -2347,7 +2336,6 @@ public class Attr extends JCTree.Visitor {
env.info.selectSuper = selectSuperPrev;
result = checkId(tree, site, sym, env, resultInfo, varArgs);
env.info.tvars = List.nil();
}
//where
/** Determine symbol referenced by a Select expression,
......@@ -2530,16 +2518,6 @@ public class Attr extends JCTree.Visitor {
? types.memberType(site, sym)
: sym.type;
if (env.info.tvars.nonEmpty()) {
Type owntype1 = new ForAll(env.info.tvars, owntype);
for (List<Type> l = env.info.tvars; l.nonEmpty(); l = l.tail)
if (!owntype.contains(l.head)) {
log.error(tree.pos(), "undetermined.type", owntype1);
owntype1 = types.createErrorType(owntype1);
}
owntype = owntype1;
}
// If the variable is a constant, record constant value in
// computed type.
if (v.getConstValue() != null && isStaticReference(tree))
......@@ -2551,9 +2529,10 @@ public class Attr extends JCTree.Visitor {
break;
case MTH: {
JCMethodInvocation app = (JCMethodInvocation)env.tree;
owntype = checkMethod(site, sym, env, app.args,
resultInfo.pt.getParameterTypes(), resultInfo.pt.getTypeArguments(),
env.info.varArgs);
owntype = checkMethod(site, sym,
new ResultInfo(VAL, resultInfo.pt.getReturnType(), resultInfo.checkContext),
env, app.args, resultInfo.pt.getParameterTypes(),
resultInfo.pt.getTypeArguments(), env.info.varArgs);
break;
}
case PCK: case ERR:
......@@ -2692,6 +2671,33 @@ public class Attr extends JCTree.Visitor {
**/
public Type checkMethod(Type site,
Symbol sym,
ResultInfo resultInfo,
Env<AttrContext> env,
final List<JCExpression> argtrees,
List<Type> argtypes,
List<Type> typeargtypes,
boolean useVarargs) {
try {
return rawCheckMethod(site, sym, resultInfo, env, argtrees, argtypes, typeargtypes, useVarargs);
} catch (Resolve.InapplicableMethodException ex) {
String key = ex.getDiagnostic() == null ?
"cant.apply.symbol" :
"cant.apply.symbol.1";
log.error(env.tree.pos, key,
Kinds.kindName(sym),
sym.name == names.init ? sym.owner.name : sym.name,
rs.methodArguments(sym.type.getParameterTypes()),
rs.methodArguments(argtypes),
Kinds.kindName(sym.owner),
sym.owner.type,
ex.getDiagnostic());
return types.createErrorType(site);
}
}
private Type rawCheckMethod(Type site,
Symbol sym,
ResultInfo resultInfo,
Env<AttrContext> env,
final List<JCExpression> argtrees,
List<Type> argtypes,
......@@ -2717,9 +2723,10 @@ public class Attr extends JCTree.Visitor {
// Resolve.instantiate from the symbol's type as well as
// any type arguments and value arguments.
noteWarner.clear();
Type owntype = rs.instantiate(env,
Type owntype = rs.rawInstantiate(env,
site,
sym,
resultInfo,
argtypes,
typeargtypes,
true,
......@@ -2728,22 +2735,8 @@ public class Attr extends JCTree.Visitor {
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) {
if (!pt().isErroneous())
log.error(env.tree.pos(),
"internal.error.cant.instantiate",
sym, site,
Type.toString(pt().getParameterTypes()));
owntype = types.createErrorType(site);
return types.createErrorType(site);
} else if (owntype.getReturnType().tag == FORALL && !unchecked) {
return owntype;
} else {
return chk.checkMethod(owntype, sym, env, argtrees, argtypes, useVarargs, unchecked);
}
}
/**
* Check that constructor arguments conform to its instantiation.
......@@ -2755,7 +2748,7 @@ public class Attr extends JCTree.Visitor {
List<Type> argtypes,
List<Type> typeargtypes,
boolean useVarargs) {
Type owntype = checkMethod(site, sym, env, argtrees, argtypes, typeargtypes, useVarargs);
Type owntype = checkMethod(site, sym, new ResultInfo(VAL, syms.voidType), env, argtrees, argtypes, typeargtypes, useVarargs);
chk.checkType(env.tree.pos(), owntype.getReturnType(), syms.voidType);
return owntype;
}
......
......@@ -58,10 +58,6 @@ public class AttrContext {
*/
boolean varArgs = false;
/** A list of type variables that are all-quantifed in current context.
*/
List<Type> tvars = List.nil();
/** A record of the lint/SuppressWarnings currently in effect
*/
Lint lint;
......@@ -80,7 +76,6 @@ public class AttrContext {
info.isSelfCall = isSelfCall;
info.selectSuper = selectSuper;
info.varArgs = varArgs;
info.tvars = tvars;
info.lint = lint;
info.enclVar = enclVar;
return info;
......
......@@ -423,10 +423,6 @@ public class Check {
* Is type 'found' compatible with type 'req' in given context
*/
boolean compatible(Type found, Type req, Warner warn);
/**
* Instantiate a ForAll type against a given target type 'req' in given context
*/
Type rawInstantiatePoly(ForAll found, Type req, Warner warn);
/**
* Report a check error
*/
......@@ -454,10 +450,6 @@ public class Check {
return enclosingContext.compatible(found, req, warn);
}
public Type rawInstantiatePoly(ForAll found, Type req, Warner warn) {
return enclosingContext.rawInstantiatePoly(found, req, warn);
}
public void report(DiagnosticPosition pos, Type found, Type req, JCDiagnostic details) {
enclosingContext.report(pos, found, req, details);
}
......@@ -482,12 +474,6 @@ public class Check {
return types.isAssignable(found, req, warn);
}
public Type rawInstantiatePoly(ForAll found, Type req, Warner warn) {
if (req.tag == NONE)
req = found.qtype.tag <= VOID ? found.qtype : syms.objectType;
return infer.instantiateExpr(found, req, warn);
}
public Warner checkWarner(DiagnosticPosition pos, Type found, Type req) {
return convertWarner(pos, found, req);
}
......@@ -506,11 +492,6 @@ public class Check {
Type checkType(final DiagnosticPosition pos, Type found, Type req, CheckContext checkContext) {
if (req.tag == ERROR)
return req;
if (found.tag == FORALL) {
ForAll fa = (ForAll)found;
Type owntype = instantiatePoly(pos, checkContext, fa, req, checkContext.checkWarner(pos, found, req));
return checkType(pos, owntype, req, checkContext);
}
if (req.tag == NONE)
return found;
if (checkContext.compatible(found, req, checkContext.checkWarner(pos, found, req))) {
......@@ -525,32 +506,6 @@ public class Check {
}
}
/** Instantiate polymorphic type to some prototype, unless
* prototype is `anyPoly' in which case polymorphic type
* is returned unchanged.
*/
Type instantiatePoly(DiagnosticPosition pos, CheckContext checkContext, ForAll t, Type pt, Warner warn) throws Infer.NoInstanceException {
try {
return checkContext.rawInstantiatePoly(t, pt, warn);
} catch (final Infer.NoInstanceException ex) {
JCDiagnostic d = ex.getDiagnostic();
if (d != null) {
if (ex.isAmbiguous) {
d = diags.fragment("undetermined.type", t, d);
}
}
checkContext.report(pos, t, pt, d);
return types.createErrorType(pt);
} catch (Infer.InvalidInstanceException ex) {
JCDiagnostic d = ex.getDiagnostic();
if (d != null) {
d = diags.fragment("invalid.inferred.types", t.tvars, d);
}
checkContext.report(pos, t, pt, d);
return types.createErrorType(pt);
}
}
/** Check that a given type can be cast to a given target type.
* Return the result of the cast.
* @param pos Position to be used for error reporting.
......@@ -561,10 +516,7 @@ public class Check {
return checkCastable(pos, found, req, basicHandler);
}
Type checkCastable(DiagnosticPosition pos, Type found, Type req, CheckContext checkContext) {
if (found.tag == FORALL) {
instantiatePoly(pos, basicHandler, (ForAll) found, req, castWarner(pos, found, req));
return req;
} else if (types.isCastable(found, req, castWarner(pos, found, req))) {
if (types.isCastable(found, req, castWarner(pos, found, req))) {
return req;
} else {
checkContext.report(pos, found, req, diags.fragment("inconvertible.types", found, req));
......
......@@ -214,16 +214,23 @@ public class Infer {
* If no instantiation exists, or if several incomparable
* best instantiations exist throw a NoInstanceException.
*/
public Type instantiateExpr(ForAll that,
Type to,
public List<Type> instantiateUninferred(DiagnosticPosition pos,
List<Type> undetvars,
List<Type> tvars,
MethodType mtype,
Attr.ResultInfo resultInfo,
Warner warn) throws InferenceException {
List<Type> undetvars = that.undetvars();
Type qtype1 = types.subst(that.qtype, that.tvars, undetvars);
Type to = resultInfo.pt;
if (to.tag == NONE) {
to = mtype.getReturnType().tag <= VOID ?
mtype.getReturnType() : syms.objectType;
}
Type qtype1 = types.subst(mtype.getReturnType(), tvars, undetvars);
if (!types.isSubtype(qtype1,
qtype1.tag == UNDETVAR ? types.boxedTypeOrType(to) : to)) {
throw unambiguousNoInstanceException
.setMessage("infer.no.conforming.instance.exists",
that.tvars, that.qtype, to);
tvars, mtype.getReturnType(), to);
}
List<Type> insttypes;
......@@ -232,32 +239,32 @@ public class Infer {
insttypes = List.nil();
for (Type t : undetvars) {
UndetVar uv = (UndetVar)t;
if (uv.inst == null && (uv.eq.nonEmpty() || !Type.containsAny(uv.hibounds, that.tvars))) {
if (uv.inst == null && (uv.eq.nonEmpty() || !Type.containsAny(uv.hibounds, tvars))) {
maximizeInst((UndetVar)t, warn);
stuck = false;
}
insttypes = insttypes.append(uv.inst == null ? uv.qtype : uv.inst);
}
if (!Type.containsAny(insttypes, that.tvars)) {
if (!Type.containsAny(insttypes, tvars)) {
//all variables have been instantiated - exit
break;
} else if (stuck) {
//some variables could not be instantiated because of cycles in
//upper bounds - provide a (possibly recursive) default instantiation
insttypes = types.subst(insttypes,
that.tvars,
instantiateAsUninferredVars(undetvars, that.tvars));
tvars,
instantiateAsUninferredVars(undetvars, tvars));
break;
} else {
//some variables have been instantiated - replace newly instantiated
//variables in remaining upper bounds and continue
for (Type t : undetvars) {
UndetVar uv = (UndetVar)t;
uv.hibounds = types.subst(uv.hibounds, that.tvars, insttypes);
uv.hibounds = types.subst(uv.hibounds, tvars, insttypes);
}
}
}
return that.inst(insttypes, types);
return insttypes;
}
/**
......@@ -296,18 +303,19 @@ public class Infer {
/** Instantiate method type `mt' by finding instantiations of
* `tvars' so that method can be applied to `argtypes'.
*/
public Type instantiateMethod(final Env<AttrContext> env,
public Type instantiateMethod(Env<AttrContext> env,
List<Type> tvars,
MethodType mt,
final Symbol msym,
final List<Type> argtypes,
final boolean allowBoxing,
final boolean useVarargs,
final Warner warn) throws InferenceException {
Attr.ResultInfo resultInfo,
Symbol msym,
List<Type> argtypes,
boolean allowBoxing,
boolean useVarargs,
Warner warn) throws InferenceException {
//-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG
final List<Type> undetvars = makeUndetvars(tvars);
List<Type> undetvars = makeUndetvars(tvars);
final List<Type> capturedArgs =
List<Type> capturedArgs =
rs.checkRawArgumentsAcceptable(env, undetvars, argtypes, mt.getParameterTypes(),
allowBoxing, useVarargs, warn, new InferenceCheckHandler(undetvars));
......@@ -344,39 +352,24 @@ public class Infer {
mt = (MethodType)types.subst(mt, tvars, insttypes.toList());
if (!restvars.isEmpty()) {
// if there are uninstantiated variables,
// quantify result type with them
final List<Type> inferredTypes = insttypes.toList();
final List<Type> all_tvars = tvars; //this is the wrong tvars
return new UninferredMethodType(env.tree.pos(), msym, mt, restvars.toList()) {
@Override
List<Type> undetvars() {
return restundet.toList();
}
@Override
void instantiateReturnType(Type restype, List<Type> inferred, Types types) throws NoInstanceException {
Type owntype = new MethodType(types.subst(getParameterTypes(), tvars, inferred),
restype,
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, undetvars,
types.subst(inferredTypes, tvars, inferred), warn);
qtype = chk.checkMethod(owntype, msym, env, TreeInfo.args(env.tree), capturedArgs, useVarargs, warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED));
if (!restvars.isEmpty() && resultInfo != null) {
List<Type> restInferred =
instantiateUninferred(env.tree.pos(), restundet.toList(), restvars.toList(), mt, resultInfo, warn);
checkWithinBounds(tvars, undetvars,
types.subst(insttypes.toList(), restvars.toList(), restInferred), warn);
mt = (MethodType)types.subst(mt, restvars.toList(), restInferred);
if (rs.verboseResolutionMode.contains(VerboseResolutionMode.DEFERRED_INST)) {
log.note(env.tree.pos, "deferred.method.inst", msym, mt, resultInfo.pt);
}
};
}
else {
if (restvars.isEmpty() || resultInfo != null) {
// check that actuals conform to inferred formals
checkArgumentsAcceptable(env, capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn);
}
// return instantiated version of method type
return mt;
}
}
//where
/** inference check handler **/
......@@ -404,60 +397,6 @@ public class Infer {
}
}
/**
* A delegated type representing a partially uninferred method type.
* The return type of a partially uninferred method type is a ForAll
* type - when the return type is instantiated (see Infer.instantiateExpr)
* the underlying method type is also updated.
*/
abstract class UninferredMethodType extends DelegatedType {
final List<Type> tvars;
final Symbol msym;
final DiagnosticPosition pos;
public UninferredMethodType(DiagnosticPosition pos, Symbol msym, MethodType mtype, List<Type> tvars) {
super(METHOD, new MethodType(mtype.argtypes, null, mtype.thrown, mtype.tsym));
this.tvars = tvars;
this.msym = msym;
this.pos = pos;
asMethodType().restype = new UninferredReturnType(tvars, mtype.restype);
}
@Override
public MethodType asMethodType() {
return qtype.asMethodType();
}
@Override
public Type map(Mapping f) {
return qtype.map(f);
}
abstract void instantiateReturnType(Type restype, List<Type> inferred, Types types);
abstract List<Type> undetvars();
class UninferredReturnType extends ForAll {
public UninferredReturnType(List<Type> tvars, Type restype) {
super(tvars, restype);
}
@Override
public Type inst(List<Type> actuals, Types types) {
Type newRestype = super.inst(actuals, types);
instantiateReturnType(newRestype, actuals, types);
if (rs.verboseResolutionMode.contains(VerboseResolutionMode.DEFERRED_INST)) {
log.note(pos, "deferred.method.inst", msym, UninferredMethodType.this.qtype, newRestype);
}
return UninferredMethodType.this.qtype.getReturnType();
}
@Override
public List<Type> undetvars() {
return UninferredMethodType.this.undetvars();
}
}
}
private void checkArgumentsAcceptable(Env<AttrContext> env, List<Type> actuals, List<Type> formals,
boolean allowBoxing, boolean useVarargs, Warner warn) {
try {
......
......@@ -224,12 +224,8 @@ public class Resolve {
JCDiagnostic getVerboseApplicableCandidateDiag(int pos, Symbol sym, Type inst) {
JCDiagnostic subDiag = null;
if (inst.getReturnType().tag == FORALL) {
Type diagType = types.createMethodTypeWithReturn(inst.asMethodType(),
((ForAll)inst.getReturnType()).qtype);
subDiag = diags.fragment("partial.inst.sig", diagType);
} else if (sym.type.tag == FORALL) {
subDiag = diags.fragment("full.inst.sig", inst.asMethodType());
if (sym.type.tag == FORALL) {
subDiag = diags.fragment("partial.inst.sig", inst);
}
String key = subDiag == null ?
......@@ -442,6 +438,7 @@ public class Resolve {
Type rawInstantiate(Env<AttrContext> env,
Type site,
Symbol m,
ResultInfo resultInfo,
List<Type> argtypes,
List<Type> typeargtypes,
boolean allowBoxing,
......@@ -454,11 +451,7 @@ public class Resolve {
// tvars is the list of formal type variables for which type arguments
// need to inferred.
List<Type> tvars = null;
if (env.info.tvars != null) {
tvars = types.newInstances(env.info.tvars);
mt = types.subst(mt, env.info.tvars, tvars);
}
List<Type> tvars = List.nil();
if (typeargtypes == null) typeargtypes = List.nil();
if (mt.tag != FORALL && typeargtypes.nonEmpty()) {
// This is not a polymorphic method, but typeargs are supplied
......@@ -499,6 +492,7 @@ public class Resolve {
return infer.instantiateMethod(env,
tvars,
(MethodType)mt,
resultInfo,
m,
argtypes,
allowBoxing,
......@@ -515,13 +509,14 @@ public class Resolve {
Type instantiate(Env<AttrContext> env,
Type site,
Symbol m,
ResultInfo resultInfo,
List<Type> argtypes,
List<Type> typeargtypes,
boolean allowBoxing,
boolean useVarargs,
Warner warn) {
try {
return rawInstantiate(env, site, m, argtypes, typeargtypes,
return rawInstantiate(env, site, m, resultInfo, argtypes, typeargtypes,
allowBoxing, useVarargs, warn);
} catch (InapplicableMethodException ex) {
return null;
......@@ -937,7 +932,7 @@ public class Resolve {
if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar;
Assert.check(sym.kind < AMBIGUOUS);
try {
Type mt = rawInstantiate(env, site, sym, argtypes, typeargtypes,
Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
allowBoxing, useVarargs, Warner.noWarnings);
if (!operator)
currentResolutionContext.addApplicableCandidate(sym, mt);
......@@ -1071,7 +1066,7 @@ public class Resolve {
private boolean signatureMoreSpecific(Env<AttrContext> env, Type site, Symbol m1, Symbol m2, boolean allowBoxing, boolean useVarargs) {
noteWarner.clear();
Type mtype1 = types.memberType(site, adjustVarargs(m1, m2, useVarargs));
Type mtype2 = instantiate(env, site, adjustVarargs(m2, m1, useVarargs),
Type mtype2 = instantiate(env, site, adjustVarargs(m2, m1, useVarargs), null,
types.lowerBoundArgtypes(mtype1), null,
allowBoxing, false, noteWarner);
return mtype2 != null &&
......
......@@ -419,9 +419,6 @@ compiler.err.incomparable.types=\
compiler.err.int.number.too.large=\
integer number too large: {0}
compiler.err.internal.error.cant.instantiate=\
internal error; cannot instantiate {0} at {1} to ({2})
compiler.err.intf.annotation.members.cant.have.params=\
@interface members may not have parameters
......@@ -783,11 +780,6 @@ compiler.err.io.exception=\
compiler.err.undef.label=\
undefined label: {0}
# 0: list of type, 1: message segment
compiler.misc.invalid.inferred.types=\
invalid inferred types for {0}\n\
reason: {1}
# 0: message segment, 1: unused
compiler.err.cant.apply.diamond=\
cannot infer type arguments for {0}
......@@ -1582,11 +1574,6 @@ compiler.misc.type.parameter=\
## The following are all possible strings for the last argument of all those
## diagnostics whose key ends in ".1"
# 0: type, 1: message segment
compiler.misc.undetermined.type=\
cannot infer type arguments for {0}\n\
reason: {1}
# 0: type, 1: list of type
compiler.misc.no.unique.maximal.instance.exists=\
no unique maximal instance exists for type variable {0} with upper bounds {1}
......@@ -1982,10 +1969,6 @@ compiler.misc.not.applicable.method.found=\
#{0} not applicable method found: {1}\n\
({2})
# 0: type
compiler.misc.full.inst.sig=\
fully instantiated to: {0}
# 0: type
compiler.misc.partial.inst.sig=\
partially instantiated to: {0}
......
T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<X>
T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<java.lang.Object>
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
......
......@@ -5,7 +5,6 @@ compiler.err.cant.apply.symbol
compiler.err.cant.read.file # (apt.JavaCompiler?)
compiler.err.cant.select.static.class.from.param.type
compiler.err.illegal.char.for.encoding
compiler.err.internal.error.cant.instantiate # Attr: should not happen
compiler.err.io.exception # (javah.JavahTask?)
compiler.err.limit.code # Code
compiler.err.limit.code.too.large.for.try.stmt # Gen
......
......@@ -23,7 +23,7 @@
// key: compiler.misc.applicable.method.found.1
// key: compiler.note.verbose.resolve.multi
// key: compiler.misc.full.inst.sig
// key: compiler.misc.partial.inst.sig
// options: -XDverboseResolution=applicable,success
class ApplicableMethodFound1 {
......
......@@ -23,7 +23,7 @@
// key: compiler.err.prob.found.req.1
// key: compiler.misc.cant.apply.diamond.1
// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.inferred.do.not.conform.to.upper.bounds
// key: compiler.misc.diamond
class CantApplyDiamond1<X> {
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// key: compiler.misc.applicable.method.found.1
// key: compiler.note.verbose.resolve.multi
// key: compiler.misc.full.inst.sig
// options: -XDverboseResolution=applicable,success
class FullInstSig {
<X> void m(X x) {}
{ m(1); }
}
......@@ -22,7 +22,7 @@
*/
// key: compiler.misc.infer.no.conforming.instance.exists
// key: compiler.err.prob.found.req.1
// key: compiler.err.cant.apply.symbol.1
class IncompatibleTypes1<V> {
<T> IncompatibleTypes1<Integer> m() {
......
......@@ -21,8 +21,7 @@
* questions.
*/
// key: compiler.misc.invalid.inferred.types
// key: compiler.err.prob.found.req.1
// key: compiler.err.cant.apply.symbol.1
// key: compiler.misc.inferred.do.not.conform.to.lower.bounds
import java.util.*;
......
/*
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// key: compiler.err.prob.found.req.1
// key: compiler.misc.invalid.inferred.types
// key: compiler.misc.inferred.do.not.conform.to.upper.bounds
import java.util.*;
class InvalidInferredTypes {
<S extends String> List<S> m() { return null; }
void test() {
List<Integer> li = m();
}
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -21,15 +21,11 @@
* questions.
*/
// key: compiler.err.prob.found.req.1
// key: compiler.misc.undetermined.type
// key: compiler.err.cant.apply.symbol.1
// key: compiler.misc.no.unique.maximal.instance.exists
class UndeterminedType1<V> {
<T extends Integer & Runnable> UndeterminedType1<T> m() {
return null;
}
class NoUniqueMaximalInstance {
<Z extends Integer> Z m() { return null; }
UndeterminedType1<? extends String> c2 = m();
{ String s = m(); }
}
......@@ -22,10 +22,9 @@
*/
// key: compiler.misc.where.fresh.typevar
// key: compiler.misc.where.description.typevar.1
// key: compiler.misc.where.typevar
// key: compiler.misc.invalid.inferred.types
// key: compiler.err.prob.found.req.1
// key: compiler.misc.where.description.typevar
// key: compiler.err.cant.apply.symbol.1
// key: compiler.misc.no.args
// key: compiler.misc.inferred.do.not.conform.to.upper.bounds
// options: -XDdiags=where,simpleNames
// run: simple
......
T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
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: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<E>
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: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<E>
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: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
......
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:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<java.lang.Object>
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>
......
T6315770.java:16:42: compiler.err.prob.found.req.1: (compiler.misc.undetermined.type: <T>T6315770<T>, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable))
T6315770.java:17:40: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer&java.lang.Runnable, java.lang.String))
T6315770.java:16:42: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T6315770<V>, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable)
T6315770.java:17:40: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T6315770<V>, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer&java.lang.Runnable, java.lang.String)
2 errors
T6638712b.java:14:21: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String,java.lang.Object))
T6638712b.java:14:21: compiler.err.cant.apply.symbol.1: kindname.method, m, I, T6638712b<java.lang.Integer>, kindname.class, T6638712b<X>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String,java.lang.Object)
1 error
T6638712e.java:17:27: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: X, (compiler.misc.no.conforming.assignment.exists: T6638712e.Foo<java.lang.Boolean,java.lang.Boolean>, T6638712e.Foo<? super java.lang.Object,? extends java.lang.Boolean>))
T6638712e.java:17:27: compiler.err.cant.apply.symbol.1: kindname.method, m, T6638712e.Foo<? super X,? extends A>, T6638712e.Foo<java.lang.Boolean,java.lang.Boolean>, kindname.class, T6638712e.Foo<A,B>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Object, java.lang.Boolean,java.lang.Object)
1 error
T6650759m.java:43:36: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: Z, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer, java.lang.String))
T6650759m.java:43:36: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List<? extends java.util.List<? super Z>>, java.util.ArrayList<java.util.ArrayList<java.lang.Integer>>, kindname.class, T6650759m, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer, java.lang.String)
1 error
T7154127.java:19:49: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: T,Y,U, (compiler.misc.inferred.do.not.conform.to.upper.bounds: Y, T7154127.D,T7154127.B<U>))
T7154127.java:19:49: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T7154127, (compiler.misc.inferred.do.not.conform.to.upper.bounds: Y, T7154127.D,T7154127.B<U>)
1 error
T6313164.java:12:8: compiler.err.cant.apply.symbol.1: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
T6313164.java:14:13: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164))
T6313164.java:15:13: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164))
T6313164.java:14:13: compiler.err.cant.apply.symbol.1: kindname.method, foo3, X[], compiler.misc.type.null,compiler.misc.type.null, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
T6313164.java:15:13: compiler.err.cant.apply.symbol.1: kindname.method, foo4, X[], compiler.misc.type.null,compiler.misc.type.null, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
- compiler.note.unchecked.filename: B.java
- compiler.note.unchecked.recompile
3 errors
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册