--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Jun 20 10:56:47 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Jun 20 20:36:54 2014 +0100
@@ -249,36 +249,30 @@
*/
Type check(final JCTree tree, final Type found, final int ownkind, final ResultInfo resultInfo) {
InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();
- Type owntype = found;
- if (!owntype.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) {
- if (allowPoly && inferenceContext.free(found)) {
- if ((ownkind & ~resultInfo.pkind) == 0) {
- owntype = resultInfo.check(tree, inferenceContext.asUndetVar(owntype));
- } else {
- log.error(tree.pos(), "unexpected.type",
- kindNames(resultInfo.pkind),
- kindName(ownkind));
- owntype = types.createErrorType(owntype);
- }
+ Type owntype;
+ if (!found.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) {
+ if ((ownkind & ~resultInfo.pkind) != 0) {
+ log.error(tree.pos(), "unexpected.type",
+ kindNames(resultInfo.pkind),
+ kindName(ownkind));
+ owntype = types.createErrorType(found);
+ } else if (allowPoly && inferenceContext.free(found)) {
+ //delay the check if there are inference variables in the found type
+ //this means we are dealing with a partially inferred poly expression
+ owntype = resultInfo.pt;
inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt), new FreeTypeListener() {
@Override
public void typesInferred(InferenceContext inferenceContext) {
ResultInfo pendingResult =
- resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
+ resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
check(tree, inferenceContext.asInstType(found), ownkind, pendingResult);
}
});
- return tree.type = resultInfo.pt;
} else {
- if ((ownkind & ~resultInfo.pkind) == 0) {
- owntype = resultInfo.check(tree, owntype);
- } else {
- log.error(tree.pos(), "unexpected.type",
- kindNames(resultInfo.pkind),
- kindName(ownkind));
- owntype = types.createErrorType(owntype);
- }
+ owntype = resultInfo.check(tree, found);
}
+ } else {
+ owntype = found;
}
tree.type = owntype;
return owntype;
@@ -2472,6 +2466,7 @@
currentTarget = infer.instantiateFunctionalInterface(that,
currentTarget, explicitParamTypes, resultInfo.checkContext);
}
+ currentTarget = types.removeWildcards(currentTarget);
lambdaType = types.findDescriptorType(currentTarget);
} else {
currentTarget = Type.recoveryType;
@@ -2894,7 +2889,7 @@
resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK &&
isSerializable(currentTarget);
if (currentTarget != Type.recoveryType) {
- currentTarget = targetChecker.visit(currentTarget, that);
+ currentTarget = types.removeWildcards(targetChecker.visit(currentTarget, that));
desc = types.findDescriptorType(currentTarget);
} else {
currentTarget = Type.recoveryType;