* @param tree The tree whose kind and type is checked
* @param ownkind The computed kind of the tree
* @param resultInfo The expected result of the tree
*/
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.asFree(owntype));
} else {
log.error(tree.pos(), "unexpected.type",
kindNames(resultInfo.pkind),
kindName(ownkind));
owntype = types.createErrorType(owntype);
}
inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt), new FreeTypeListener() {
@Override
public void typesInferred(InferenceContext inferenceContext) {
ResultInfo pendingResult =
resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
check(tree, inferenceContext.asInstType(found), ownkind, pendingResult);
}
});
return tree.type = resultInfo.pt;
} else {
if ((ownkind & ~resultInfo.pkind) == 0) {