7177386: Add attribution support for method references

Add type-checking/lookup routines for method references

Reviewed-by: jjg, dlsmith
This commit is contained in:
Maurizio Cimadamore 2012-10-06 10:35:38 +01:00
parent 83042670bb
commit 319150fde0
67 changed files with 1299 additions and 162 deletions

View file

@ -28,6 +28,7 @@ package com.sun.tools.javac.code;
import java.util.EnumSet;
import java.util.Locale;
import com.sun.source.tree.MemberReferenceTree;
import com.sun.tools.javac.api.Formattable;
import com.sun.tools.javac.api.Messages;
@ -85,11 +86,12 @@ public class Kinds {
public static final int AMBIGUOUS = ERRONEOUS+1; // ambiguous reference
public static final int HIDDEN = ERRONEOUS+2; // hidden method or field
public static final int STATICERR = ERRONEOUS+3; // nonstatic member from static context
public static final int ABSENT_VAR = ERRONEOUS+4; // missing variable
public static final int WRONG_MTHS = ERRONEOUS+5; // methods with wrong arguments
public static final int WRONG_MTH = ERRONEOUS+6; // one method with wrong arguments
public static final int ABSENT_MTH = ERRONEOUS+7; // missing method
public static final int ABSENT_TYP = ERRONEOUS+8; // missing type
public static final int MISSING_ENCL = ERRONEOUS+4; // missing enclosing class
public static final int ABSENT_VAR = ERRONEOUS+5; // missing variable
public static final int WRONG_MTHS = ERRONEOUS+6; // methods with wrong arguments
public static final int WRONG_MTH = ERRONEOUS+7; // one method with wrong arguments
public static final int ABSENT_MTH = ERRONEOUS+8; // missing method
public static final int ABSENT_TYP = ERRONEOUS+9; // missing type
public enum KindName implements Formattable {
ANNOTATION("kindname.annotation"),
@ -140,6 +142,14 @@ public class Kinds {
}
}
public static KindName kindName(MemberReferenceTree.ReferenceMode mode) {
switch (mode) {
case INVOKE: return KindName.METHOD;
case NEW: return KindName.CONSTRUCTOR;
default : throw new AssertionError("Unexpected mode: "+ mode);
}
}
/** A KindName representing a given symbol
*/
public static KindName kindName(Symbol sym) {

View file

@ -922,7 +922,12 @@ public abstract class Symbol implements Element {
/** Clone this symbol with new owner.
*/
public VarSymbol clone(Symbol newOwner) {
VarSymbol v = new VarSymbol(flags_field, name, type, newOwner);
VarSymbol v = new VarSymbol(flags_field, name, type, newOwner) {
@Override
public Symbol baseSymbol() {
return VarSymbol.this;
}
};
v.pos = pos;
v.adr = adr;
v.data = data;
@ -1049,7 +1054,12 @@ public abstract class Symbol implements Element {
/** Clone this symbol with new owner.
*/
public MethodSymbol clone(Symbol newOwner) {
MethodSymbol m = new MethodSymbol(flags_field, name, type, newOwner);
MethodSymbol m = new MethodSymbol(flags_field, name, type, newOwner) {
@Override
public Symbol baseSymbol() {
return MethodSymbol.this;
}
};
m.code = code;
return m;
}

View file

@ -43,7 +43,7 @@ import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.comp.Check.CheckContext;
import com.sun.source.tree.IdentifierTree;
import com.sun.source.tree.LambdaExpressionTree;
import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
import com.sun.source.tree.MemberSelectTree;
import com.sun.source.tree.TreeVisitor;
import com.sun.source.util.SimpleTreeVisitor;
@ -1034,7 +1034,8 @@ public class Attr extends JCTree.Visitor {
if (tree.init != null) {
if ((v.flags_field & FINAL) != 0 &&
!tree.init.hasTag(NEWCLASS) &&
!tree.init.hasTag(LAMBDA)) {
!tree.init.hasTag(LAMBDA) &&
!tree.init.hasTag(REFERENCE)) {
// In this case, `v' is final. Ensure that it's initializer is
// evaluated.
v.getConstValue(); // ensure initializer is evaluated
@ -1743,27 +1744,10 @@ public class Attr extends JCTree.Visitor {
if (restype.tag == WILDCARD)
throw new AssertionError(mtype);
// as a special case, array.clone() has a result that is
// the same as static type of the array being cloned
if (tree.meth.hasTag(SELECT) &&
allowCovariantReturns &&
methName == names.clone &&
types.isArray(((JCFieldAccess) tree.meth).selected.type))
restype = ((JCFieldAccess) tree.meth).selected.type;
// as a special case, x.getClass() has type Class<? extends |X|>
if (allowGenerics &&
methName == names.getClass && tree.args.isEmpty()) {
Type qualifier = (tree.meth.hasTag(SELECT))
Type qualifier = (tree.meth.hasTag(SELECT))
? ((JCFieldAccess) tree.meth).selected.type
: env.enclClass.sym.type;
restype = new
ClassType(restype.getEnclosingType(),
List.<Type>of(new WildcardType(types.erasure(qualifier),
BoundKind.EXTENDS,
syms.boundClass)),
restype.tsym);
}
restype = adjustMethodReturnType(qualifier, methName, argtypes, restype);
chk.checkRefTypes(tree.typeargs, typeargtypes);
@ -1777,6 +1761,27 @@ public class Attr extends JCTree.Visitor {
chk.validate(tree.typeargs, localEnv);
}
//where
Type adjustMethodReturnType(Type qualifierType, Name methodName, List<Type> argtypes, Type restype) {
if (allowCovariantReturns &&
methodName == names.clone &&
types.isArray(qualifierType)) {
// as a special case, array.clone() has a result that is
// the same as static type of the array being cloned
return qualifierType;
} else if (allowGenerics &&
methodName == names.getClass &&
argtypes.isEmpty()) {
// as a special case, x.getClass() has type Class<? extends |X|>
return new ClassType(restype.getEnclosingType(),
List.<Type>of(new WildcardType(types.erasure(qualifierType),
BoundKind.EXTENDS,
syms.boundClass)),
restype.tsym);
} else {
return restype;
}
}
/** Check that given application node appears as first statement
* in a constructor call.
* @param tree The application node
@ -2357,6 +2362,179 @@ public class Attr extends JCTree.Visitor {
return lambdaEnv;
}
@Override
public void visitReference(final JCMemberReference that) {
if (pt().isErroneous() || (pt().tag == NONE && pt() != Type.recoveryType)) {
if (pt().tag == NONE) {
//method reference only allowed in assignment or method invocation/cast context
log.error(that.pos(), "unexpected.mref");
}
result = that.type = types.createErrorType(pt());
return;
}
final Env<AttrContext> localEnv = env.dup(that);
try {
//attribute member reference qualifier - if this is a constructor
//reference, the expected kind must be a type
Type exprType = attribTree(that.expr,
env, new ResultInfo(that.getMode() == ReferenceMode.INVOKE ? VAL | TYP : TYP, Type.noType));
if (that.getMode() == JCMemberReference.ReferenceMode.NEW) {
exprType = chk.checkConstructorRefType(that.expr, exprType);
}
if (exprType.isErroneous()) {
//if the qualifier expression contains problems,
//give up atttribution of method reference
result = that.type = exprType;
return;
}
if (TreeInfo.isStaticSelector(that.expr, names) &&
(that.getMode() != ReferenceMode.NEW || !that.expr.type.isRaw())) {
//if the qualifier is a type, validate it
chk.validate(that.expr, env);
}
//attrib type-arguments
List<Type> typeargtypes = null;
if (that.typeargs != null) {
typeargtypes = attribTypes(that.typeargs, localEnv);
}
Type target = infer.instantiateFunctionalInterface(that, pt(), null, resultInfo.checkContext);
Type desc = (target == Type.recoveryType) ?
fallbackDescriptorType(that) :
types.findDescriptorType(target);
List<Type> argtypes = desc.getParameterTypes();
boolean allowBoxing =
resultInfo.checkContext.deferredAttrContext() == deferredAttr.emptyDeferredAttrContext ||
resultInfo.checkContext.deferredAttrContext().phase.isBoxingRequired();
Pair<Symbol, Resolve.ReferenceLookupHelper> refResult = rs.resolveMemberReference(that.pos(), localEnv, that,
that.expr.type, that.name, argtypes, typeargtypes, allowBoxing);
Symbol refSym = refResult.fst;
Resolve.ReferenceLookupHelper lookupHelper = refResult.snd;
if (refSym.kind != MTH) {
boolean targetError;
switch (refSym.kind) {
case ABSENT_MTH:
targetError = false;
break;
case WRONG_MTH:
case WRONG_MTHS:
case AMBIGUOUS:
case HIDDEN:
case STATICERR:
case MISSING_ENCL:
targetError = true;
break;
default:
Assert.error("unexpected result kind " + refSym.kind);
targetError = false;
}
JCDiagnostic detailsDiag = ((Resolve.ResolveError)refSym).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT,
that, exprType.tsym, exprType, that.name, argtypes, typeargtypes);
JCDiagnostic.DiagnosticType diagKind = targetError ?
JCDiagnostic.DiagnosticType.FRAGMENT : JCDiagnostic.DiagnosticType.ERROR;
JCDiagnostic diag = diags.create(diagKind, log.currentSource(), that,
"invalid.mref", Kinds.kindName(that.getMode()), detailsDiag);
if (targetError) {
resultInfo.checkContext.report(that, diag);
} else {
log.report(diag);
}
result = that.type = types.createErrorType(target);
return;
}
if (desc.getReturnType() == Type.recoveryType) {
// stop here
result = that.type = types.createErrorType(target);
return;
}
that.sym = refSym.baseSymbol();
that.kind = lookupHelper.referenceKind(that.sym);
ResultInfo checkInfo =
resultInfo.dup(newMethodTemplate(
desc.getReturnType().tag == VOID ? Type.noType : desc.getReturnType(),
lookupHelper.argtypes,
typeargtypes));
Type refType = checkId(that, lookupHelper.site, refSym, localEnv, checkInfo);
if (!refType.isErroneous()) {
refType = types.createMethodTypeWithReturn(refType,
adjustMethodReturnType(lookupHelper.site, that.name, checkInfo.pt.getParameterTypes(), refType.getReturnType()));
}
//go ahead with standard method reference compatibility check - note that param check
//is a no-op (as this has been taken care during method applicability)
boolean isSpeculativeRound =
resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
checkReferenceCompatible(that, desc, refType, resultInfo.checkContext, isSpeculativeRound);
if (!isSpeculativeRound) {
checkAccessibleFunctionalDescriptor(that, localEnv, resultInfo.checkContext.inferenceContext(), desc);
}
result = check(that, target, VAL, resultInfo);
} catch (Types.FunctionDescriptorLookupError ex) {
JCDiagnostic cause = ex.getDiagnostic();
resultInfo.checkContext.report(that, cause);
result = that.type = types.createErrorType(pt());
return;
}
}
@SuppressWarnings("fallthrough")
void checkReferenceCompatible(JCMemberReference tree, Type descriptor, Type refType, CheckContext checkContext, boolean speculativeAttr) {
Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType(), types);
Type resType;
switch (tree.getMode()) {
case NEW:
if (!tree.expr.type.isRaw()) {
resType = tree.expr.type;
break;
}
default:
resType = refType.getReturnType();
}
Type incompatibleReturnType = resType;
if (returnType.tag == VOID) {
incompatibleReturnType = null;
}
if (returnType.tag != VOID && resType.tag != VOID) {
if (resType.isErroneous() ||
new LambdaReturnContext(checkContext).compatible(resType, returnType, Warner.noWarnings)) {
incompatibleReturnType = null;
}
}
if (incompatibleReturnType != null) {
checkContext.report(tree, diags.fragment("incompatible.ret.type.in.mref",
diags.fragment("inconvertible.types", resType, descriptor.getReturnType())));
}
if (!speculativeAttr) {
List<Type> thrownTypes = checkContext.inferenceContext().asFree(descriptor.getThrownTypes(), types);
if (chk.unhandled(refType.getThrownTypes(), thrownTypes).nonEmpty()) {
log.error(tree, "incompatible.thrown.types.in.mref", refType.getThrownTypes());
}
}
}
public void visitParens(JCParens tree) {
Type owntype = attribTree(tree.expr, env, resultInfo);
result = check(tree, owntype, pkind(), resultInfo);
@ -2708,6 +2886,7 @@ public class Attr extends JCTree.Visitor {
} else {
// Check if type-qualified fields or methods are static (JLS)
if ((sym.flags() & STATIC) == 0 &&
!env.next.tree.hasTag(REFERENCE) &&
sym.name != names._super &&
(sym.kind == VAR || sym.kind == MTH)) {
rs.accessBase(rs.new StaticError(sym),
@ -3733,6 +3912,14 @@ public class Attr extends JCTree.Visitor {
that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol);
super.visitUnary(that);
}
@Override
public void visitReference(JCMemberReference that) {
super.visitReference(that);
if (that.sym == null) {
that.sym = new MethodSymbol(0, names.empty, syms.unknownType, syms.noSymbol);
}
}
}
// </editor-fold>
}

View file

@ -648,6 +648,22 @@ public class Check {
return t;
}
/** Check that type is a valid qualifier for a constructor reference expression
*/
Type checkConstructorRefType(DiagnosticPosition pos, Type t) {
t = checkClassType(pos, t);
if (t.tag == CLASS) {
if ((t.tsym.flags() & (ABSTRACT | INTERFACE)) != 0) {
log.error(pos, "abstract.cant.be.instantiated");
t = types.createErrorType(t);
} else if ((t.tsym.flags() & ENUM) != 0) {
log.error(pos, "enum.cant.be.instantiated");
t = types.createErrorType(t);
}
}
return t;
}
/** Check that type is a class or interface type.
* @param pos Position to be used for error reporting.
* @param t The type to be checked.
@ -842,29 +858,32 @@ public class Check {
List<JCExpression> args = argtrees;
DeferredAttr.DeferredTypeMap checkDeferredMap =
deferredAttr.new DeferredTypeMap(DeferredAttr.AttrMode.CHECK, sym, env.info.pendingResolutionPhase);
while (formals.head != last) {
JCTree arg = args.head;
Warner warn = convertWarner(arg.pos(), arg.type, formals.head);
assertConvertible(arg, arg.type, formals.head, warn);
args = args.tail;
formals = formals.tail;
}
if (useVarargs) {
Type varArg = types.elemtype(last);
while (args.tail != null) {
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, varArg);
assertConvertible(arg, arg.type, varArg, warn);
Warner warn = convertWarner(arg.pos(), arg.type, formals.head);
assertConvertible(arg, arg.type, formals.head, warn);
args = args.tail;
formals = formals.tail;
}
if (useVarargs) {
Type varArg = types.elemtype(last);
while (args.tail != null) {
JCTree arg = args.head;
Warner warn = convertWarner(arg.pos(), arg.type, varArg);
assertConvertible(arg, arg.type, varArg, warn);
args = args.tail;
}
} else if ((sym.flags() & VARARGS) != 0 && allowVarargs) {
// non-varargs call to varargs method
Type varParam = owntype.getParameterTypes().last();
Type lastArg = checkDeferredMap.apply(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);
}
} else if ((sym.flags() & VARARGS) != 0 && allowVarargs) {
// non-varargs call to varargs method
Type varParam = owntype.getParameterTypes().last();
Type lastArg = checkDeferredMap.apply(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 (unchecked) {
warnUnchecked(env.tree.pos(),
@ -899,6 +918,9 @@ public class Check {
case NEWCLASS:
((JCNewClass) tree).varargsElement = elemtype;
break;
case REFERENCE:
((JCMemberReference) tree).varargsElement = elemtype;
break;
default:
throw new AssertionError(""+tree);
}

View file

@ -40,6 +40,7 @@ import com.sun.tools.javac.comp.Resolve.MethodResolutionContext.Candidate;
import com.sun.tools.javac.jvm.*;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@ -98,10 +99,6 @@ public class Resolve {
varNotFound = new
SymbolNotFoundError(ABSENT_VAR);
wrongMethod = new
InapplicableSymbolError();
wrongMethods = new
InapplicableSymbolsError();
methodNotFound = new
SymbolNotFoundError(ABSENT_MTH);
typeNotFound = new
@ -133,8 +130,6 @@ public class Resolve {
/** error symbols, which are returned when resolution fails
*/
private final SymbolNotFoundError varNotFound;
private final InapplicableSymbolError wrongMethod;
private final InapplicableSymbolsError wrongMethods;
private final SymbolNotFoundError methodNotFound;
private final SymbolNotFoundError typeNotFound;
@ -454,8 +449,18 @@ public class Resolve {
boolean useVarargs,
Warner warn)
throws Infer.InferenceException {
if (useVarargs && (m.flags() & VARARGS) == 0)
throw inapplicableMethodException.setMessage();
if (useVarargs && (m.flags() & VARARGS) == 0) {
//better error recovery - if we stumbled upon a non-varargs method
//during varargs applicability phase, the method should be treated as
//not applicable; the reason for inapplicability can be found in the
//candidate for 'm' that was created during the BOX phase.
Candidate prevCandidate = currentResolutionContext.getCandidate(m, BOX);
JCDiagnostic details = null;
if (prevCandidate != null && !prevCandidate.isApplicable()) {
details = prevCandidate.details;
}
throw inapplicableMethodException.setMessage(details);
}
Type mt = types.memberType(site, m);
// tvars is the list of formal type variables for which type arguments
@ -1028,11 +1033,10 @@ public class Resolve {
currentResolutionContext.addInapplicableCandidate(sym, ex.getDiagnostic());
switch (bestSoFar.kind) {
case ABSENT_MTH:
return wrongMethod;
return new InapplicableSymbolError(currentResolutionContext);
case WRONG_MTH:
if (operator) return bestSoFar;
case WRONG_MTHS:
return wrongMethods;
bestSoFar = new InapplicableSymbolsError(currentResolutionContext);
default:
return bestSoFar;
}
@ -1181,7 +1185,8 @@ public class Resolve {
//is this a structural actual argument?
boolean isStructuralPoly = actual.tag == DEFERRED &&
((DeferredType)actual).tree.hasTag(LAMBDA);
(((DeferredType)actual).tree.hasTag(LAMBDA) ||
((DeferredType)actual).tree.hasTag(REFERENCE));
Type newFormal = f1;
@ -2210,7 +2215,7 @@ public class Resolve {
final JCDiagnostic details = errSym.kind == WRONG_MTH ?
((InapplicableSymbolError)errSym).errCandidate().details :
null;
errSym = new InapplicableSymbolError(errSym.kind, "diamondError") {
errSym = new InapplicableSymbolError(errSym.kind, "diamondError", currentResolutionContext) {
@Override
JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos,
Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
@ -2276,6 +2281,335 @@ public class Resolve {
return bestSoFar;
}
/**
* Resolution of member references is typically done as a single
* overload resolution step, where the argument types A are inferred from
* the target functional descriptor.
*
* If the member reference is a method reference with a type qualifier,
* a two-step lookup process is performed. The first step uses the
* expected argument list A, while the second step discards the first
* type from A (which is treated as a receiver type).
*
* There are two cases in which inference is performed: (i) if the member
* reference is a constructor reference and the qualifier type is raw - in
* which case diamond inference is used to infer a parameterization for the
* type qualifier; (ii) if the member reference is an unbound reference
* where the type qualifier is raw - in that case, during the unbound lookup
* the receiver argument type is used to infer an instantiation for the raw
* qualifier type.
*
* When a multi-step resolution process is exploited, it is an error
* if two candidates are found (ambiguity).
*
* This routine returns a pair (T,S), where S is the member reference symbol,
* and T is the type of the class in which S is defined. This is necessary as
* the type T might be dynamically inferred (i.e. if constructor reference
* has a raw qualifier).
*/
Pair<Symbol, ReferenceLookupHelper> resolveMemberReference(DiagnosticPosition pos,
Env<AttrContext> env,
JCMemberReference referenceTree,
Type site,
Name name, List<Type> argtypes,
List<Type> typeargtypes,
boolean boxingAllowed) {
//step 1 - bound lookup
ReferenceLookupHelper boundLookupHelper = name.equals(names.init) ?
new ConstructorReferenceLookupHelper(referenceTree, site, argtypes, typeargtypes, boxingAllowed) :
new MethodReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, boxingAllowed);
Env<AttrContext> boundEnv = env.dup(env.tree, env.info.dup());
Symbol boundSym = findMemberReference(boundEnv, boundLookupHelper);
//step 2 - unbound lookup
ReferenceLookupHelper unboundLookupHelper = boundLookupHelper.unboundLookup();
Env<AttrContext> unboundEnv = env.dup(env.tree, env.info.dup());
Symbol unboundSym = findMemberReference(unboundEnv, unboundLookupHelper);
//merge results
Pair<Symbol, ReferenceLookupHelper> res;
if (unboundSym.kind != MTH) {
res = new Pair<Symbol, ReferenceLookupHelper>(boundSym, boundLookupHelper);
env.info.pendingResolutionPhase = boundEnv.info.pendingResolutionPhase;
} else if (boundSym.kind == MTH) {
res = new Pair<Symbol, ReferenceLookupHelper>(ambiguityError(boundSym, unboundSym), boundLookupHelper);
env.info.pendingResolutionPhase = boundEnv.info.pendingResolutionPhase;
} else {
res = new Pair<Symbol, ReferenceLookupHelper>(unboundSym, unboundLookupHelper);
env.info.pendingResolutionPhase = unboundEnv.info.pendingResolutionPhase;
}
return res;
}
/**
* Helper for defining custom method-like lookup logic; a lookup helper
* provides hooks for (i) the actual lookup logic and (ii) accessing the
* lookup result (this step might result in compiler diagnostics to be generated)
*/
abstract class LookupHelper {
/** name of the symbol to lookup */
Name name;
/** location in which the lookup takes place */
Type site;
/** actual types used during the lookup */
List<Type> argtypes;
/** type arguments used during the lookup */
List<Type> typeargtypes;
LookupHelper(Name name, Type site, List<Type> argtypes, List<Type> typeargtypes) {
this.name = name;
this.site = site;
this.argtypes = argtypes;
this.typeargtypes = typeargtypes;
}
/**
* Search for a symbol under a given overload resolution phase - this method
* is usually called several times, once per each overload resolution phase
*/
abstract Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase);
/**
* Validate the result of the lookup
*/
abstract Symbol access(Env<AttrContext> env, Symbol symbol);
}
/**
* Helper class for member reference lookup. A reference lookup helper
* defines the basic logic for member reference lookup; a method gives
* access to an 'unbound' helper used to perform an unbound member
* reference lookup.
*/
abstract class ReferenceLookupHelper extends LookupHelper {
/** The member reference tree */
JCMemberReference referenceTree;
/** Max overload resolution phase handled by this helper */
MethodResolutionPhase maxPhase;
ReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
List<Type> argtypes, List<Type> typeargtypes, boolean boxingAllowed) {
super(name, site, argtypes, typeargtypes);
this.referenceTree = referenceTree;
this.maxPhase = boxingAllowed ? VARARITY : BASIC;
}
/**
* Returns an unbound version of this lookup helper. By default, this
* method returns an dummy lookup helper.
*/
ReferenceLookupHelper unboundLookup() {
//dummy loopkup helper that always return 'methodNotFound'
return new ReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, maxPhase.isBoxingRequired()) {
@Override
ReferenceLookupHelper unboundLookup() {
return this;
}
@Override
Symbol lookupReference(Env<AttrContext> env, MethodResolutionPhase phase) {
return methodNotFound;
}
@Override
ReferenceKind referenceKind(Symbol sym) {
Assert.error();
return null;
}
};
}
/**
* Get the kind of the member reference
*/
abstract JCMemberReference.ReferenceKind referenceKind(Symbol sym);
@Override
Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
return (env.info.pendingResolutionPhase.ordinal() > maxPhase.ordinal()) ?
methodNotFound : lookupReference(env, phase);
}
abstract Symbol lookupReference(Env<AttrContext> env, MethodResolutionPhase phase);
Symbol access(Env<AttrContext> env, Symbol sym) {
if (sym.kind >= AMBIGUOUS) {
MethodResolutionPhase errPhase = currentResolutionContext.firstErroneousResolutionPhase();
if (errPhase.ordinal() > maxPhase.ordinal()) {
errPhase = maxPhase;
}
env.info.pendingResolutionPhase = errPhase;
sym = currentResolutionContext.resolutionCache.get(errPhase);
}
return sym;
}
}
/**
* Helper class for method reference lookup. The lookup logic is based
* upon Resolve.findMethod; in certain cases, this helper class has a
* corresponding unbound helper class (see UnboundMethodReferenceLookupHelper).
* In such cases, non-static lookup results are thrown away.
*/
class MethodReferenceLookupHelper extends ReferenceLookupHelper {
MethodReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
List<Type> argtypes, List<Type> typeargtypes, boolean boxingAllowed) {
super(referenceTree, name, site, argtypes, typeargtypes, boxingAllowed);
}
protected Symbol lookupReferenceInternal(Env<AttrContext> env, MethodResolutionPhase phase) {
return findMethod(env, site, name, argtypes, typeargtypes,
phase.isBoxingRequired(), phase.isVarargsRequired(), syms.operatorNames.contains(name));
}
protected Symbol adjustLookupResult(Env<AttrContext> env, Symbol sym) {
return !TreeInfo.isStaticSelector(referenceTree.expr, names) ||
sym.kind != MTH ||
sym.isStatic() ? sym : new StaticError(sym);
}
@Override
final Symbol lookupReference(Env<AttrContext> env, MethodResolutionPhase phase) {
return adjustLookupResult(env, lookupReferenceInternal(env, phase));
}
@Override
ReferenceLookupHelper unboundLookup() {
if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
argtypes.nonEmpty() &&
types.isSubtypeUnchecked(argtypes.head, site)) {
return new UnboundMethodReferenceLookupHelper(referenceTree, name,
site, argtypes, typeargtypes, maxPhase.isBoxingRequired());
} else {
return super.unboundLookup();
}
}
@Override
ReferenceKind referenceKind(Symbol sym) {
if (sym.isStatic()) {
return TreeInfo.isStaticSelector(referenceTree.expr, names) ?
ReferenceKind.STATIC : ReferenceKind.STATIC_EVAL;
} else {
Name selName = TreeInfo.name(referenceTree.getQualifierExpression());
return selName != null && selName == names._super ?
ReferenceKind.SUPER :
ReferenceKind.BOUND;
}
}
}
/**
* Helper class for unbound method reference lookup. Essentially the same
* as the basic method reference lookup helper; main difference is that static
* lookup results are thrown away. If qualifier type is raw, an attempt to
* infer a parameterized type is made using the first actual argument (that
* would otherwise be ignored during the lookup).
*/
class UnboundMethodReferenceLookupHelper extends MethodReferenceLookupHelper {
UnboundMethodReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
List<Type> argtypes, List<Type> typeargtypes, boolean boxingAllowed) {
super(referenceTree, name,
site.isRaw() ? types.asSuper(argtypes.head, site.tsym) : site,
argtypes.tail, typeargtypes, boxingAllowed);
}
@Override
protected Symbol adjustLookupResult(Env<AttrContext> env, Symbol sym) {
return sym.kind != MTH || !sym.isStatic() ? sym : new StaticError(sym);
}
@Override
ReferenceLookupHelper unboundLookup() {
return this;
}
@Override
ReferenceKind referenceKind(Symbol sym) {
return ReferenceKind.UNBOUND;
}
}
/**
* Helper class for constructor reference lookup. The lookup logic is based
* upon either Resolve.findMethod or Resolve.findDiamond - depending on
* whether the constructor reference needs diamond inference (this is the case
* if the qualifier type is raw). A special erroneous symbol is returned
* if the lookup returns the constructor of an inner class and there's no
* enclosing instance in scope.
*/
class ConstructorReferenceLookupHelper extends ReferenceLookupHelper {
boolean needsInference;
ConstructorReferenceLookupHelper(JCMemberReference referenceTree, Type site, List<Type> argtypes,
List<Type> typeargtypes, boolean boxingAllowed) {
super(referenceTree, names.init, site, argtypes, typeargtypes, boxingAllowed);
if (site.isRaw()) {
this.site = new ClassType(site.getEnclosingType(), site.tsym.type.getTypeArguments(), site.tsym);
needsInference = true;
}
}
@Override
protected Symbol lookupReference(Env<AttrContext> env, MethodResolutionPhase phase) {
Symbol sym = needsInference ?
findDiamond(env, site, argtypes, typeargtypes, phase.isBoxingRequired(), phase.isVarargsRequired()) :
findMethod(env, site, name, argtypes, typeargtypes,
phase.isBoxingRequired(), phase.isVarargsRequired(), syms.operatorNames.contains(name));
return sym.kind != MTH ||
site.getEnclosingType().tag == NONE ||
hasEnclosingInstance(env, site) ?
sym : new InvalidSymbolError(Kinds.MISSING_ENCL, sym, null) {
@Override
JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
return diags.create(dkind, log.currentSource(), pos,
"cant.access.inner.cls.constr", site.tsym.name, argtypes, site.getEnclosingType());
}
};
}
@Override
ReferenceKind referenceKind(Symbol sym) {
return site.getEnclosingType().tag == NONE ?
ReferenceKind.TOPLEVEL : ReferenceKind.IMPLICIT_INNER;
}
}
/**
* Resolution step for member reference. This generalizes a standard
* method/constructor lookup - on each overload resolution step, a
* lookup helper class is used to perform the reference lookup; at the end
* of the lookup, the helper is used to validate the results.
*/
Symbol findMemberReference(Env<AttrContext> env, LookupHelper lookupHelper) {
MethodResolutionContext prevResolutionContext = currentResolutionContext;
try {
currentResolutionContext = new MethodResolutionContext();
Symbol sym = methodNotFound;
List<MethodResolutionPhase> steps = methodResolutionSteps;
while (steps.nonEmpty() &&
steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
sym.kind >= ERRONEOUS) {
currentResolutionContext.step = env.info.pendingResolutionPhase = steps.head;
sym = lookupHelper.lookup(env, steps.head);
currentResolutionContext.resolutionCache.put(steps.head, sym);
steps = steps.tail;
}
return lookupHelper.access(env, sym);
}
finally {
currentResolutionContext = prevResolutionContext;
}
}
/** Resolve constructor.
* @param pos The position to use for error reporting.
* @param env The environment current at the constructor invocation.
@ -2425,6 +2759,23 @@ public class Resolve {
Env<AttrContext> env,
Symbol member,
boolean isSuperCall) {
Symbol sym = resolveSelfContainingInternal(env, member, isSuperCall);
if (sym == null) {
log.error(pos, "encl.class.required", member);
return syms.errSymbol;
} else {
return accessBase(sym, pos, env.enclClass.sym.type, sym.name, true);
}
}
boolean hasEnclosingInstance(Env<AttrContext> env, Type type) {
Symbol encl = resolveSelfContainingInternal(env, type.tsym, false);
return encl != null && encl.kind < ERRONEOUS;
}
private Symbol resolveSelfContainingInternal(Env<AttrContext> env,
Symbol member,
boolean isSuperCall) {
Name name = names._this;
Env<AttrContext> env1 = isSuperCall ? env.outer : env;
boolean staticOnly = false;
@ -2435,8 +2786,7 @@ public class Resolve {
Symbol sym = env1.info.scope.lookup(name).sym;
if (sym != null) {
if (staticOnly) sym = new StaticError(sym);
return accessBase(sym, pos, env.enclClass.sym.type,
name, true);
return sym;
}
}
if ((env1.enclClass.sym.flags() & STATIC) != 0)
@ -2444,8 +2794,7 @@ public class Resolve {
env1 = env1.outer;
}
}
log.error(pos, "encl.class.required", member);
return syms.errSymbol;
return null;
}
/**
@ -2513,7 +2862,7 @@ public class Resolve {
* represent a different kinds of resolution error - as such they must
* specify how they map into concrete compiler diagnostics.
*/
private abstract class ResolveError extends Symbol {
abstract class ResolveError extends Symbol {
/** The name of the kind of error, for debugging only. */
final String debugName;
@ -2703,12 +3052,15 @@ public class Resolve {
*/
class InapplicableSymbolError extends ResolveError {
InapplicableSymbolError() {
super(WRONG_MTH, "inapplicable symbol error");
protected MethodResolutionContext resolveContext;
InapplicableSymbolError(MethodResolutionContext context) {
this(WRONG_MTH, "inapplicable symbol error", context);
}
protected InapplicableSymbolError(int kind, String debugName) {
protected InapplicableSymbolError(int kind, String debugName, MethodResolutionContext context) {
super(kind, debugName);
this.resolveContext = context;
}
@Override
@ -2746,7 +3098,7 @@ public class Resolve {
Candidate c = errCandidate();
Symbol ws = c.sym.asMemberOf(site, types);
return diags.create(dkind, log.currentSource(), pos,
"cant.apply.symbol" + (c.details != null ? ".1" : ""),
"cant.apply.symbol",
kindName(ws),
ws.name == names.init ? ws.owner.name : ws.name,
methodArguments(ws.type.getParameterTypes()),
@ -2763,13 +3115,13 @@ public class Resolve {
}
protected boolean shouldReport(Candidate c) {
MethodResolutionPhase errPhase = resolveContext.firstErroneousResolutionPhase();
return !c.isApplicable() &&
(((c.sym.flags() & VARARGS) != 0 && c.step == VARARITY) ||
(c.sym.flags() & VARARGS) == 0 && c.step == (boxingEnabled ? BOX : BASIC));
c.step == errPhase;
}
private Candidate errCandidate() {
for (Candidate c : currentResolutionContext.candidates) {
for (Candidate c : resolveContext.candidates) {
if (shouldReport(c)) {
return c;
}
@ -2786,8 +3138,8 @@ public class Resolve {
*/
class InapplicableSymbolsError extends InapplicableSymbolError {
InapplicableSymbolsError() {
super(WRONG_MTHS, "inapplicable symbols");
InapplicableSymbolsError(MethodResolutionContext context) {
super(WRONG_MTHS, "inapplicable symbols", context);
}
@Override
@ -2798,7 +3150,7 @@ public class Resolve {
Name name,
List<Type> argtypes,
List<Type> typeargtypes) {
if (currentResolutionContext.candidates.nonEmpty()) {
if (!resolveContext.candidates.isEmpty()) {
JCDiagnostic err = diags.create(dkind,
log.currentSource(),
pos,
@ -2816,7 +3168,7 @@ public class Resolve {
//where
List<JCDiagnostic> candidateDetails(Type site) {
List<JCDiagnostic> details = List.nil();
for (Candidate c : currentResolutionContext.candidates) {
for (Candidate c : resolveContext.candidates) {
if (!shouldReport(c)) continue;
JCDiagnostic detailDiag = diags.fragment("inapplicable.method",
Kinds.kindName(c.sym),
@ -2829,7 +3181,7 @@ public class Resolve {
}
private Name getName() {
Symbol sym = currentResolutionContext.candidates.head.sym;
Symbol sym = resolveContext.candidates.head.sym;
return sym.name == names.init ?
sym.owner.name :
sym.name;
@ -3023,6 +3375,7 @@ public class Resolve {
steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
sym.kind >= WRONG_MTHS) {
sym = resolutionCache.get(steps.head);
if (sym.kind == ABSENT_MTH) break; //ignore spurious empty entries
bestSoFar = steps.head;
steps = steps.tail;
}
@ -3031,8 +3384,7 @@ public class Resolve {
void addInapplicableCandidate(Symbol sym, JCDiagnostic details) {
Candidate c = new Candidate(currentResolutionContext.step, sym, details, null);
if (!candidates.contains(c))
candidates = candidates.append(c);
candidates = candidates.append(c);
}
void addApplicableCandidate(Symbol sym, Type mtype) {
@ -3040,6 +3392,16 @@ public class Resolve {
candidates = candidates.append(c);
}
Candidate getCandidate(Symbol sym, MethodResolutionPhase phase) {
for (Candidate c : currentResolutionContext.candidates) {
if (c.step == phase &&
c.sym.baseSymbol() == sym.baseSymbol()) {
return c;
}
}
return null;
}
/**
* This class represents an overload resolution candidate. There are two
* kinds of candidates: applicable methods and inapplicable methods;
@ -3067,9 +3429,9 @@ public class Resolve {
Symbol s1 = this.sym;
Symbol s2 = ((Candidate)o).sym;
if ((s1 != s2 &&
(s1.overrides(s2, s1.owner.type.tsym, types, false) ||
(s2.overrides(s1, s2.owner.type.tsym, types, false)))) ||
((s1.isConstructor() || s2.isConstructor()) && s1.owner != s2.owner))
(s1.overrides(s2, s1.owner.type.tsym, types, false) ||
(s2.overrides(s1, s2.owner.type.tsym, types, false)))) ||
((s1.isConstructor() || s2.isConstructor()) && s1.owner != s2.owner))
return true;
}
return false;

View file

@ -632,6 +632,11 @@ public class TransTypes extends TreeTranslator {
Assert.error("Translation of lambda expression not supported yet");
}
@Override
public void visitReference(JCMemberReference tree) {
Assert.error("Translation of method reference not supported yet");
}
public void visitParens(JCParens tree) {
tree.expr = translate(tree.expr, pt);
tree.type = erasure(tree.type);

View file

@ -638,10 +638,6 @@ public class JavaTokenizer {
lexError(pos, "unclosed.str.lit");
}
break loop;
case '#':
reader.scanChar();
tk = TokenKind.HASH;
break loop;
default:
if (isSpecial(reader.ch)) {
scanOperator();

View file

@ -1160,7 +1160,7 @@ public class JavacParser implements Parser {
case LT:
if ((mode & TYPE) == 0 && isUnboundMemberRef()) {
//this is an unbound method reference whose qualifier
//is a generic type i.e. A<S>#m
//is a generic type i.e. A<S>::m
int pos1 = token.pos;
accept(LT);
ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
@ -1178,7 +1178,8 @@ public class JavacParser implements Parser {
t = toP(F.at(token.pos).Select(t, ident()));
t = typeArgumentsOpt(t);
}
if (token.kind != HASH) {
t = bracketsOpt(t);
if (token.kind != COLCOL) {
//method reference expected here
t = illegal();
}
@ -1238,6 +1239,10 @@ public class JavacParser implements Parser {
nextToken();
t = bracketsOpt(t);
t = toP(F.at(pos1).TypeArray(t));
if (token.kind == COLCOL) {
mode = EXPR;
continue;
}
return t;
}
mode = oldmode;
@ -1270,10 +1275,10 @@ public class JavacParser implements Parser {
t = argumentsOpt(typeArgs, typeArgumentsOpt(t));
typeArgs = null;
}
} else if ((mode & EXPR) != 0 && token.kind == HASH) {
} else if ((mode & EXPR) != 0 && token.kind == COLCOL) {
mode = EXPR;
if (typeArgs != null) return illegal();
accept(HASH);
accept(COLCOL);
t = memberReferenceSuffix(pos1, t);
} else {
break;
@ -1312,9 +1317,11 @@ public class JavacParser implements Parser {
case GT:
depth--;
if (depth == 0) {
TokenKind nextKind = S.token(pos + 1).kind;
return
S.token(pos + 1).kind == TokenKind.DOT ||
S.token(pos + 1).kind == TokenKind.HASH;
nextKind == TokenKind.DOT ||
nextKind == TokenKind.LBRACKET ||
nextKind == TokenKind.COLCOL;
}
break;
default:
@ -1368,7 +1375,7 @@ public class JavacParser implements Parser {
nextToken();
if (token.kind == LPAREN || typeArgs != null) {
t = arguments(typeArgs, t);
} else if (token.kind == HASH) {
} else if (token.kind == COLCOL) {
if (typeArgs != null) return illegal();
t = memberReferenceSuffix(t);
} else {
@ -1579,20 +1586,22 @@ public class JavacParser implements Parser {
t = toP(F.at(pos).Select(t, names._class));
}
} else if ((mode & TYPE) != 0) {
mode = TYPE;
} else {
if (token.kind != COLCOL) {
mode = TYPE;
}
} else if (token.kind != COLCOL) {
syntaxError(token.pos, "dot.class.expected");
}
return t;
}
/**
* MemberReferenceSuffix = "#" [TypeArguments] Ident
* | "#" [TypeArguments] "new"
* MemberReferenceSuffix = "::" [TypeArguments] Ident
* | "::" [TypeArguments] "new"
*/
JCExpression memberReferenceSuffix(JCExpression t) {
int pos1 = token.pos;
accept(HASH);
accept(COLCOL);
return memberReferenceSuffix(pos1, t);
}

View file

@ -177,7 +177,7 @@ public class Tokens {
FALSE("false", Tag.NAMED),
NULL("null", Tag.NAMED),
ARROW("->"),
HASH("#"),
COLCOL("::"),
LPAREN("("),
RPAREN(")"),
LBRACE("{"),

View file

@ -148,13 +148,8 @@ compiler.err.break.outside.switch.loop=\
compiler.err.call.must.be.first.stmt.in.ctor=\
call to {0} must be first statement in constructor
compiler.err.cant.apply.symbol=\
{0} {1} in {4} {5} cannot be applied to given types\n\
required: {2}\n\
found: {3}
# 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment
compiler.err.cant.apply.symbol.1=\
compiler.err.cant.apply.symbol=\
{0} {1} in {4} {5} cannot be applied to given types;\n\
required: {2}\n\
found: {3}\n\
@ -164,6 +159,18 @@ compiler.err.cant.apply.symbol.1=\
compiler.err.cant.apply.symbols=\
no suitable {0} found for {1}({2})
# 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment
compiler.misc.cant.apply.symbol=\
{0} {1} in {4} {5} cannot be applied to given types\n\
required: {2}\n\
found: {3}\n\
reason: {6}
# 0: symbol kind, 1: name, 2: list of type
compiler.misc.cant.apply.symbols=\
no suitable {0} found for {1}({2})
# 0: type
compiler.err.cant.access.arg.type.in.functional.desc=\
cannot access parameter type {0} in target functional descriptor
@ -212,6 +219,14 @@ compiler.misc.descriptor.throws=\
compiler.misc.no.suitable.functional.intf.inst=\
cannot infer functional interface descriptor for {0}
# 0: symbol kind, 1: message segment
compiler.err.invalid.mref=\
invalid {0} reference; {1}
# 0: symbol kind, 1: message segment
compiler.misc.invalid.mref=\
invalid {0} reference; {1}
# 0: symbol
compiler.err.cant.assign.val.to.final.var=\
cannot assign a value to final variable {0}
@ -698,10 +713,19 @@ compiler.misc.incompatible.ret.type.in.lambda=\
bad return type in lambda expression\n\
{0}
# 0: type
compiler.misc.incompatible.ret.type.in.mref=\
bad return type in method reference\n\
{0}
# 0: list of type
compiler.err.incompatible.thrown.types.in.lambda=\
incompatible thrown types {0} in lambda expression
# 0: list of type
compiler.err.incompatible.thrown.types.in.mref=\
incompatible thrown types {0} in method reference
compiler.misc.incompatible.arg.types.in.lambda=\
incompatible parameter types in lambda expression
@ -727,6 +751,15 @@ compiler.err.not.annotation.type=\
compiler.err.not.def.access.class.intf.cant.access=\
{0} in {1} is defined in an inaccessible class or interface
# 0: symbol, 1: symbol
compiler.misc.not.def.access.class.intf.cant.access=\
{0} in {1} is defined in an inaccessible class or interface
# 0: symbol, 1: list of type, 2: type
compiler.misc.cant.access.inner.cls.constr=\
cannot access constructor {0}({1})\n\
an enclosing instance of type {2} is not in scope
# 0: symbol, 1: symbol
compiler.err.not.def.public.cant.access=\
{0} is not public in {1}; cannot be accessed from outside package
@ -825,7 +858,13 @@ compiler.err.recursive.ctor.invocation=\
# 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol
compiler.err.ref.ambiguous=\
reference to {0} is ambiguous, both {1} {2} in {3} and {4} {5} in {6} match
reference to {0} is ambiguous\n\
both {1} {2} in {3} and {4} {5} in {6} match
# 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol
compiler.misc.ref.ambiguous=\
reference to {0} is ambiguous\n\
both {1} {2} in {3} and {4} {5} in {6} match
compiler.err.repeated.annotation.target=\
repeated annotation target
@ -1818,6 +1857,10 @@ compiler.err.abstract.cant.be.accessed.directly=\
compiler.err.non-static.cant.be.ref=\
non-static {0} {1} cannot be referenced from a static context
# 0: symbol kind, 1: symbol
compiler.misc.non-static.cant.be.ref=\
non-static {0} {1} cannot be referenced from a static context
## Both arguments ({0}, {1}) are "kindname"s. {0} is a comma-separated list
## of kindnames (the list should be identical to that provided in source.
compiler.err.unexpected.type=\
@ -1828,6 +1871,9 @@ compiler.err.unexpected.type=\
compiler.err.unexpected.lambda=\
lambda expression not expected here
compiler.err.unexpected.mref=\
method reference not expected here
## The first argument {0} is a "kindname" (e.g. 'constructor', 'field', etc.)
## The second argument {1} is the non-resolved symbol
## The third argument {2} is a list of type parameters (non-empty if {1} is a method)
@ -1867,6 +1913,20 @@ compiler.err.cant.resolve.location.args.params=\
symbol: {0} <{2}>{1}({3})\n\
location: {4}
### Following are replicated/used for method reference diagnostics
# 0: symbol kind, 1: name, 2: unused, 3: list of type, 4: message segment
compiler.misc.cant.resolve.location.args=\
cannot find symbol\n\
symbol: {0} {1}({3})\n\
location: {4}
# 0: symbol kind, 1: name, 2: list of type, 3: list, 4: message segment
compiler.misc.cant.resolve.location.args.params=\
cannot find symbol\n\
symbol: {0} <{2}>{1}({3})\n\
location: {4}
##a location subdiagnostic is composed as follows:
## The first argument {0} is the location "kindname" (e.g. 'constructor', 'field', etc.)
## The second argument {1} is the location name

View file

@ -1810,11 +1810,46 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
*/
public static class JCMemberReference extends JCExpression implements MemberReferenceTree {
public ReferenceMode mode;
public ReferenceKind kind;
public Name name;
public JCExpression expr;
public List<JCExpression> typeargs;
public Type targetType;
public Symbol sym;
public Type varargsElement;
/**
* Javac-dependent classification for member references, based
* on relevant properties w.r.t. code-generation
*/
public enum ReferenceKind {
/** super # instMethod */
SUPER(ReferenceMode.INVOKE, false),
/** Type # instMethod */
UNBOUND(ReferenceMode.INVOKE, true),
/** Type # staticMethod */
STATIC(ReferenceMode.INVOKE, false),
/** Expr # instMethod */
BOUND(ReferenceMode.INVOKE, false),
/** Expr # staticMethod */
STATIC_EVAL(ReferenceMode.INVOKE, false),
/** Inner # new */
IMPLICIT_INNER(ReferenceMode.NEW, false),
/** Toplevel # new */
TOPLEVEL(ReferenceMode.NEW, false);
ReferenceMode mode;
boolean unbound;
private ReferenceKind(ReferenceMode mode, boolean unbound) {
this.mode = mode;
this.unbound = unbound;
}
public boolean isUnbound() {
return unbound;
}
}
protected JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
this.mode = mode;
@ -1843,6 +1878,9 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
public Tag getTag() {
return REFERENCE;
}
public boolean hasKind(ReferenceKind kind) {
return this.kind == kind;
}
}
/**

View file

@ -282,6 +282,7 @@ public class TreeInfo {
return isStaticSym(base) &&
isStaticSelector(((JCFieldAccess)base).selected, names);
case TYPEAPPLY:
case TYPEARRAY:
return true;
default:
return false;

View file

@ -210,6 +210,7 @@ public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter
case PARENS:
return expr2String(((JCParens)tree).expr);
case LAMBDA:
case REFERENCE:
case CONDEXPR:
return Pretty.toSimpleString(tree);
default:

View file

@ -1,3 +1,3 @@
T6758789a.java:14:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch)
T6758789a.java:15:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch)
T6758789a.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch)
T6758789a.java:15:9: compiler.err.cant.apply.symbol: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch)
2 errors

View file

@ -1,2 +1,2 @@
T6840059.java:15:9: compiler.err.cant.apply.symbol.1: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
T6840059.java:15:9: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
1 error

View file

@ -1,4 +1,4 @@
T7132880.java:23:12: compiler.err.cant.apply.symbol.1: kindname.method, m1, java.lang.Integer, java.lang.String, kindname.class, Outer.Inner1, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
T7132880.java:23:12: compiler.err.cant.apply.symbol: kindname.method, m1, java.lang.Integer, java.lang.String, kindname.class, Outer.Inner1, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
T7132880.java:33:12: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.String,{(compiler.misc.inapplicable.method: kindname.method, Outer.Inner2, m1(java.lang.Double), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Double))),(compiler.misc.inapplicable.method: kindname.method, Outer.Inner2, m1(java.lang.Integer), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer)))}
T7132880.java:43:12: compiler.err.ref.ambiguous: m2, kindname.method, m2(java.lang.Object,int), Outer.Inner3, kindname.method, m2(int,java.lang.Object), Outer.Inner3
3 errors

View file

@ -1,2 +1,2 @@
T6722234a.java:12:9: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1))
T6722234a.java:12:9: compiler.err.cant.apply.symbol: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1))
1 error

View file

@ -1,3 +1,3 @@
T6722234a.java:12:9: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1))
T6722234a.java:12:9: compiler.err.cant.apply.symbol: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1))
- compiler.misc.where.description.typevar.1: compiler.misc.type.var: T, 1,compiler.misc.type.var: T, 2,{(compiler.misc.where.typevar: compiler.misc.type.var: T, 1, java.lang.String, kindname.class, T6722234a),(compiler.misc.where.typevar: compiler.misc.type.var: T, 2, java.lang.Integer, kindname.method, <compiler.misc.type.var: T, 2>test(compiler.misc.type.var: T, 2))}
1 error

View file

@ -1,2 +1,2 @@
T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List<T>,List<T>, List<compiler.misc.type.captureof: 1, ? extends T6722234b>,List<compiler.misc.type.captureof: 2, ? extends T6722234b>, kindname.class, T6722234b, (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 2, ? extends T6722234b, compiler.misc.type.captureof: 2, ? extends T6722234b,compiler.misc.type.captureof: 1, ? extends T6722234b)
T6722234b.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, List<T>,List<T>, List<compiler.misc.type.captureof: 1, ? extends T6722234b>,List<compiler.misc.type.captureof: 2, ? extends T6722234b>, kindname.class, T6722234b, (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 2, ? extends T6722234b, compiler.misc.type.captureof: 2, ? extends T6722234b,compiler.misc.type.captureof: 1, ? extends T6722234b)
1 error

View file

@ -1,4 +1,4 @@
T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List<T>,List<T>, List<compiler.misc.captured.type: 1>,List<compiler.misc.captured.type: 2>, kindname.class, T6722234b, (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.captured.type: 2, compiler.misc.captured.type: 2,compiler.misc.captured.type: 1)
T6722234b.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, List<T>,List<T>, List<compiler.misc.captured.type: 1>,List<compiler.misc.captured.type: 2>, kindname.class, T6722234b, (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.captured.type: 2, compiler.misc.captured.type: 2,compiler.misc.captured.type: 1)
- compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, Object, kindname.method, <T>m(List<T>,List<T>))}
- compiler.misc.where.description.captured.1: compiler.misc.captured.type: 1,compiler.misc.captured.type: 2,{(compiler.misc.where.captured.1: compiler.misc.captured.type: 1, T6722234b, compiler.misc.type.null, ? extends T6722234b),(compiler.misc.where.captured.1: compiler.misc.captured.type: 2, T6722234b, compiler.misc.type.null, ? extends T6722234b)}
1 error

View file

@ -1,2 +1,2 @@
T6722234c.java:14:9: compiler.err.cant.apply.symbol.1: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.lang.String, T6722234c.String))
T6722234c.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.lang.String, T6722234c.String))
1 error

View file

@ -1,3 +1,3 @@
T6862608a.java:19:33: compiler.err.cant.apply.symbol.1: kindname.method, compound, java.lang.Iterable<? extends java.util.Comparator<? super T>>, java.util.List<java.util.Comparator<?>>, kindname.class, T6862608a, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<java.util.Comparator<?>>, java.lang.Iterable<? extends java.util.Comparator<? super T>>))
T6862608a.java:19:33: compiler.err.cant.apply.symbol: kindname.method, compound, java.lang.Iterable<? extends java.util.Comparator<? super T>>, java.util.List<java.util.Comparator<?>>, kindname.class, T6862608a, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<java.util.Comparator<?>>, java.lang.Iterable<? extends java.util.Comparator<? super T>>))
- compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, java.lang.Object, kindname.method, <T>compound(java.lang.Iterable<? extends java.util.Comparator<? super T>>))}
1 error

View file

@ -1,3 +1,3 @@
T6862608b.java:11:7: compiler.err.cant.apply.symbol.1: kindname.method, test, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T66862608b<compiler.misc.type.var: T, 1,compiler.misc.type.var: S, 2>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1))
T6862608b.java:11:7: compiler.err.cant.apply.symbol: kindname.method, test, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T66862608b<compiler.misc.type.var: T, 1,compiler.misc.type.var: S, 2>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1))
- compiler.misc.where.description.typevar.1: compiler.misc.type.var: T, 1,compiler.misc.type.var: T, 2,compiler.misc.type.var: S, 1,compiler.misc.type.var: S, 2,{(compiler.misc.where.typevar: compiler.misc.type.var: T, 1, java.lang.String, kindname.class, T66862608b),(compiler.misc.where.typevar: compiler.misc.type.var: T, 2, compiler.misc.type.var: S, 1, kindname.method, <compiler.misc.type.var: S, 1,compiler.misc.type.var: T, 2>foo(compiler.misc.type.var: T, 2)),(compiler.misc.where.typevar: compiler.misc.type.var: S, 1, java.lang.Object, kindname.method, <compiler.misc.type.var: S, 1,compiler.misc.type.var: T, 2>foo(compiler.misc.type.var: T, 2)),(compiler.misc.where.typevar: compiler.misc.type.var: S, 2, java.lang.Object, kindname.class, T66862608b)}
1 error

View file

@ -1,7 +1,7 @@
T6326754.java:44:12: compiler.err.name.clash.same.erasure: TestConstructor(T), TestConstructor(K)
T6326754.java:52:17: compiler.err.name.clash.same.erasure: setT(K), setT(T)
T6326754.java:64:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T, T)
T6326754.java:70:11: compiler.err.cant.apply.symbol.1: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC<T>, (compiler.misc.arg.length.mismatch)
T6326754.java:70:11: compiler.err.cant.apply.symbol: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC<T>, (compiler.misc.arg.length.mismatch)
- compiler.note.unchecked.filename: T6326754.java
- compiler.note.unchecked.recompile
4 errors

View file

@ -185,6 +185,8 @@ public class CheckResourceKeys {
"compiler.err.cant.resolve.args.params",
"compiler.err.cant.resolve.location.args",
"compiler.err.cant.resolve.location.args.params",
"compiler.misc.cant.resolve.location.args",
"compiler.misc.cant.resolve.location.args.params",
// JavaCompiler, reports #errors and #warnings
"compiler.misc.count.error",
"compiler.misc.count.error.plural",

View file

@ -1,7 +1,6 @@
compiler.err.already.annotated # internal compiler error?
compiler.err.already.defined.this.unit # seems to be masked by compiler.err.duplicate.class
compiler.err.annotation.value.not.allowable.type # cannot happen: precluded by complete type-specific tests
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

View file

@ -0,0 +1,40 @@
/*
* 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
* 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
// key: compiler.misc.cant.access.inner.cls.constr
// key: compiler.misc.invalid.mref
// options: -XDallowMethodReferences
class CantAccessInnerClsConstructor {
interface SAM {
Outer m();
}
class Outer { }
static void test() {
SAM s = Outer::new;
}
}

View file

@ -0,0 +1,42 @@
/*
* 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
* 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
// key: compiler.misc.inconvertible.types
// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.cant.apply.symbol
// key: compiler.misc.invalid.mref
// options: -XDallowMethodReferences
class CantApplySymbolFragment {
interface SAM {
void m(Integer u);
}
static void f(String s) { }
void test() {
SAM s = CantApplySymbolFragment::f;
}
}

View file

@ -0,0 +1,46 @@
/*
* 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
* 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
// key: compiler.misc.inconvertible.types
// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.arg.length.mismatch
// key: compiler.misc.inapplicable.method
// key: compiler.misc.cant.apply.symbols
// key: compiler.misc.invalid.mref
// options: -XDallowMethodReferences
class CantApplySymbolsFragment {
interface SAM {
void m(Integer u);
}
static void f() { }
static void f(String s) { }
void test() {
SAM s = CantApplySymbolsFragment::f;
}
}

View file

@ -0,0 +1,38 @@
/*
* 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
* 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.cant.resolve.location.args
// key: compiler.misc.location
// key: compiler.err.invalid.mref
// options: -XDallowMethodReferences
class CantResolveLocationArgsFragment {
interface SAM {
void m(Integer u);
}
void test() {
SAM s = CantResolveLocationArgsFragment::f;
}
}

View file

@ -0,0 +1,38 @@
/*
* 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
* 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.cant.resolve.location.args.params
// key: compiler.misc.location
// key: compiler.err.invalid.mref
// options: -XDallowMethodReferences
class CantResolveLocationArgsParamsFragment {
interface SAM {
void m(Integer u);
}
void test() {
SAM s = CantResolveLocationArgsParamsFragment::<String>f;
}
}

View file

@ -21,7 +21,7 @@
* questions.
*/
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.cyclic.inference
// options: -XDallowLambda -XDallowPoly

View file

@ -21,7 +21,7 @@
* questions.
*/
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.explicit.param.do.not.conform.to.bounds
class ExplicitParamsDoNotConformToBounds {

View file

@ -22,7 +22,7 @@
*/
// key: compiler.misc.inaccessible.varargs.type
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
import p1.B;

View file

@ -21,7 +21,7 @@
* questions.
*/
//key: compiler.err.cant.apply.symbol.1
//key: compiler.err.cant.apply.symbol
//key: compiler.misc.incompatible.eq.upper.bounds
import java.util.List;

View file

@ -0,0 +1,37 @@
/*
* 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
* 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
// key: compiler.misc.inconvertible.types
// key: compiler.misc.incompatible.ret.type.in.mref
// options: -XDallowMethodReferences -XDallowPoly
class IncompatibleRetTypeInMref {
interface SAM {
Integer m();
}
static String f() { }
SAM s = IncompatibleRetTypeInMref::f;
}

View file

@ -0,0 +1,35 @@
/*
* 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
* 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.incompatible.thrown.types.in.mref
// options: -XDallowMethodReferences
class IncompatibleThrownTypesInMref {
interface SAM {
void m();
}
static void f() throws Exception { }
SAM s = IncompatibleThrownTypesInMref::f;
}

View file

@ -21,7 +21,7 @@
* questions.
*/
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.infer.arg.length.mismatch
class InferArgsLengthMismatch {

View file

@ -21,7 +21,7 @@
* questions.
*/
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.inconvertible.types
// key: compiler.misc.infer.no.conforming.assignment.exists

View file

@ -21,7 +21,7 @@
* questions.
*/
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.infer.varargs.argument.mismatch
// key: compiler.misc.inconvertible.types

View file

@ -21,7 +21,7 @@
* questions.
*/
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.inferred.do.not.conform.to.eq.bounds
import java.util.*;

View file

@ -21,7 +21,7 @@
* questions.
*/
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.inferred.do.not.conform.to.upper.bounds
import java.util.*;

View file

@ -23,7 +23,7 @@
// key: compiler.misc.kindname.constructor
// key: compiler.misc.kindname.class
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.inconvertible.types
// key: compiler.misc.count.error

View file

@ -25,5 +25,5 @@
// options: -source 7 -Xlint:-options
class MethodReferencesNotSupported {
S s = A#foo;
S s = A::foo;
}

View file

@ -22,7 +22,7 @@
*/
// key: compiler.misc.no.args
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.arg.length.mismatch
// run: simple

View file

@ -0,0 +1,40 @@
/*
* 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
* 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
// key: compiler.misc.non-static.cant.be.ref
// key: compiler.misc.invalid.mref
// options: -XDallowMethodReferences
class NonStaticCantBeRefFragment {
interface SAM {
void m(Integer u);
}
void f(Integer i) { }
static void test() {
SAM s = NonStaticCantBeRefFragment::f;
}
}

View file

@ -23,7 +23,7 @@
// key: compiler.misc.not.applicable.method.found
// key: compiler.note.verbose.resolve.multi.1
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.inconvertible.types
// options: -XDverboseResolution=inapplicable,failure

View file

@ -0,0 +1,47 @@
/*
* 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
* 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
// key: compiler.misc.not.def.access.class.intf.cant.access
// key: compiler.misc.invalid.mref
// options: -XDallowMethodReferences
class NotDefAccessClassIntfCantAccessFragment {
private class Private {
void m() { }
}
Private getPrivate() { return new Private(); }
}
class NotDefAccessClassIntfCantAccessFragmentTest {
interface SAM {
void m();
}
static void test() {
SAM s = new NotDefAccessClassIntfCantAccessFragment().getPrivate()::m;
}
}

View file

@ -0,0 +1,41 @@
/*
* 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
* 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
// key: compiler.misc.ref.ambiguous
// key: compiler.misc.invalid.mref
// options: -XDallowMethodReferences
class RefAmbiguousFragment {
interface SAM {
void m(Integer i1, Integer i2);
}
void f(Number n, Integer i) { }
void f(Integer i, Number n) { }
void test() {
SAM s = RefAmbiguousFragment::f;
}
}

View file

@ -0,0 +1,29 @@
/*
* 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
* 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.unexpected.mref
// options: -XDallowMethodReferences
class UnexpectedLambda {
{ (Foo::bar)++; }
}

View file

@ -21,7 +21,7 @@
* questions.
*/
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.varargs.argument.mismatch
// key: compiler.misc.inconvertible.types

View file

@ -23,7 +23,7 @@
// key: compiler.misc.not.applicable.method.found
// key: compiler.note.verbose.resolve.multi.1
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.inconvertible.types
// options: -XDverboseResolution=inapplicable,failure

View file

@ -25,7 +25,7 @@
// key: compiler.misc.where.description.captured.1
// key: compiler.misc.where.description.typevar
// key: compiler.misc.where.typevar
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.inferred.do.not.conform.to.eq.bounds
// key: compiler.misc.captured.type
// options: -XDdiags=where,simpleNames

View file

@ -25,7 +25,7 @@
// key: compiler.misc.where.description.captured.1
// key: compiler.misc.where.description.typevar
// key: compiler.misc.where.typevar
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.inferred.do.not.conform.to.eq.bounds
// key: compiler.misc.captured.type
// key: compiler.misc.type.null

View file

@ -24,7 +24,7 @@
// key: compiler.misc.where.typevar
// key: compiler.misc.where.description.typevar.1
// key: compiler.misc.type.var
// key: compiler.err.cant.apply.symbol.1
// key: compiler.err.cant.apply.symbol
// key: compiler.misc.no.conforming.assignment.exists
// key: compiler.misc.inconvertible.types
// options: -XDdiags=where,disambiguateTvars

View file

@ -1,2 +1,2 @@
T7034511a.java:18:14: compiler.err.cant.apply.symbol.1: kindname.method, foo, compiler.misc.type.captureof: 1, ?[], java.lang.String[], kindname.interface, T7034511a.A<T>, (compiler.misc.no.conforming.assignment.exists: java.lang.String[], compiler.misc.type.captureof: 1, ?[])
T7034511a.java:18:14: compiler.err.cant.apply.symbol: kindname.method, foo, compiler.misc.type.captureof: 1, ?[], java.lang.String[], kindname.interface, T7034511a.A<T>, (compiler.misc.no.conforming.assignment.exists: java.lang.String[], compiler.misc.type.captureof: 1, ?[])
1 error

View file

@ -1,2 +1,2 @@
T7034511b.java:14:11: compiler.err.cant.apply.symbol.1: kindname.method, toArray, compiler.misc.type.captureof: 1, ?[], java.lang.Object[], kindname.class, T7034511b.MyList<E>, (compiler.misc.no.conforming.assignment.exists: java.lang.Object[], compiler.misc.type.captureof: 1, ?[])
T7034511b.java:14:11: compiler.err.cant.apply.symbol: kindname.method, toArray, compiler.misc.type.captureof: 1, ?[], java.lang.Object[], kindname.class, T7034511b.MyList<E>, (compiler.misc.no.conforming.assignment.exists: java.lang.Object[], compiler.misc.type.captureof: 1, ?[])
1 error

View file

@ -1,5 +1,5 @@
T6611449.java:18:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S))}
T6611449.java:19:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.infer.arg.length.mismatch: T))}
T6611449.java:20:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, T, int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)
T6611449.java:21:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, T,T, int,int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)
T6611449.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m1, T, int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)
T6611449.java:21:9: compiler.err.cant.apply.symbol: kindname.method, m2, T,T, int,int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)
4 errors

View file

@ -1,2 +1,2 @@
T6638712a.java:16:33: compiler.err.cant.apply.symbol.1: kindname.method, compound, java.lang.Iterable<? extends java.util.Comparator<? super T>>, java.util.List<java.util.Comparator<?>>, kindname.class, T6638712a, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<java.util.Comparator<?>>, java.lang.Iterable<? extends java.util.Comparator<? super T>>))
T6638712a.java:16:33: compiler.err.cant.apply.symbol: kindname.method, compound, java.lang.Iterable<? extends java.util.Comparator<? super T>>, java.util.List<java.util.Comparator<?>>, kindname.class, T6638712a, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<java.util.Comparator<?>>, java.lang.Iterable<? extends java.util.Comparator<? super T>>))
1 error

View file

@ -1,2 +1,2 @@
T6638712c.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, sort, T[],java.util.Comparator<? super T>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>, kindname.class, T6638712c, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.Comparator<java.lang.Enum<?>>, java.util.Comparator<? super java.lang.Enum>))
T6638712c.java:16:9: compiler.err.cant.apply.symbol: kindname.method, sort, T[],java.util.Comparator<? super T>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>, kindname.class, T6638712c, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.Comparator<java.lang.Enum<?>>, java.util.Comparator<? super java.lang.Enum>))
1 error

View file

@ -1,2 +1,2 @@
T6638712d.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.String, java.lang.Integer)
T6638712d.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.String, java.lang.Integer)
1 error

View file

@ -1,2 +1,2 @@
T6838943.java:13:14: compiler.err.cant.apply.symbol.1: kindname.method, m, T6838943.A<Z>,Z, T6838943.A<T6838943.B>,T6838943.B, kindname.class, T6838943.C<X>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: T6838943.A<T6838943.B>, T6838943.A<Z>))
T6838943.java:13:14: compiler.err.cant.apply.symbol: kindname.method, m, T6838943.A<Z>,Z, T6838943.A<T6838943.B>,T6838943.B, kindname.class, T6838943.C<X>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: T6838943.A<T6838943.B>, T6838943.A<Z>))
1 error

View file

@ -1,5 +1,5 @@
T7086586.java:14:20: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
T7086586.java:15:20: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
T7086586.java:16:23: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
T7086586.java:17:9: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
T7086586.java:14:20: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
T7086586.java:15:20: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
T7086586.java:16:23: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
T7086586.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
4 errors

View file

@ -1,2 +1,2 @@
T7177306b.java:15:9: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List<? super T>,S,java.lang.Class<java.lang.Object>, java.util.List<java.lang.Integer>,java.util.List<java.lang.String>,java.lang.Class, kindname.class, T7177306b, (compiler.misc.incompatible.eq.upper.bounds: T, java.lang.String, java.lang.Integer,java.lang.Object)
T7177306b.java:15:9: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>,S,java.lang.Class<java.lang.Object>, java.util.List<java.lang.Integer>,java.util.List<java.lang.String>,java.lang.Class, kindname.class, T7177306b, (compiler.misc.incompatible.eq.upper.bounds: T, java.lang.String, java.lang.Integer,java.lang.Object)
1 error

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -42,14 +42,14 @@ public class MethodReferenceParserTest {
static int checkCount = 0;
enum ReferenceKind {
METHOD_REF("#Q##Gm"),
CONSTRUCTOR_REF("#Q##Gnew"),
METHOD_REF("#Q::#Gm"),
CONSTRUCTOR_REF("#Q::#Gnew"),
FALSE_REF("min < max"),
ERR_SUPER("#Q##Gsuper"),
ERR_METH0("#Q##Gm()"),
ERR_METH1("#Q##Gm(X)"),
ERR_CONSTR0("#Q##Gnew()"),
ERR_CONSTR1("#Q##Gnew(X)");
ERR_SUPER("#Q::#Gsuper"),
ERR_METH0("#Q::#Gm()"),
ERR_METH1("#Q::#Gm(X)"),
ERR_CONSTR0("#Q::#Gnew()"),
ERR_CONSTR1("#Q::#Gnew(X)");
String referenceTemplate;
@ -110,6 +110,8 @@ public class MethodReferenceParserTest {
METHOD("m()"),
FIELD("a.f"),
UBOUND_SIMPLE("A"),
UNBOUND_ARRAY1("int[]"),
UNBOUND_ARRAY2("A<G>[][]"),
UNBOUND_GENERIC1("A<X>"),
UNBOUND_GENERIC2("A<X, Y>"),
UNBOUND_GENERIC3("A<? extends X, ? super Y>"),
@ -125,7 +127,7 @@ public class MethodReferenceParserTest {
}
enum ExprKind {
NONE("#R#S"),
NONE("#R::S"),
SINGLE_PAREN1("(#R#S)"),
SINGLE_PAREN2("(#R)#S"),
DOUBLE_PAREN1("((#R#S))"),

View file

@ -1,4 +1,4 @@
T6999438.java:8:8: compiler.err.expected: token.identifier
T6999438.java:8:9: compiler.err.illegal.char: 35
T6999438.java:8:10: compiler.err.illegal.start.of.type
T6999438.java:8:25: compiler.err.expected: token.identifier
T6999438.java:8:26: compiler.err.expected: ';'

View file

@ -1,4 +1,4 @@
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:12:8: compiler.err.cant.apply.symbol: 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: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
T6313164.java:15:13: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
- compiler.note.unchecked.filename: B.java