/** Check that a given type can be cast to a given target type. * Return the result of the cast. * @param pos Position to be used for error reporting. * @param found The type that is being cast. * @param req The target type of the cast. */ Type checkCastable(DiagnosticPosition pos, Type found, Type req) { if (found.tag == FORALL) { instantiatePoly(pos, (ForAll) found, req, castWarner(pos, found, req)); return req; } else if (types.isCastable(found, req, castWarner(pos, found, req))) { return req; } else { return typeError(pos, JCDiagnostic.fragment("inconvertible.types"), found, req); } } //where
/** Check that a given type can be cast to a given target type. * Return the result of the cast. * @param pos Position to be used for error reporting. * @param found The type that is being cast. * @param req The target type of the cast. */ Type checkCastable(DiagnosticPosition pos, Type found, Type req) { if (found.tag == FORALL) { instantiatePoly(pos, (ForAll) found, req, castWarner(pos, found, req)); return req; } else if (types.isCastable(found, req, castWarner(pos, found, req))) { return req; } else { return typeError(pos, JCDiagnostic.fragment("inconvertible.types"), found, req); } } //where
/** Check that a given type is assignable to a given proto-type. * If it is, return the type, otherwise return errType. * @param pos Position to be used for error reporting. * @param found The type that was found. * @param req The type that was required. */ Type checkType(DiagnosticPosition pos, Type found, Type req) { if (req.tag == ERROR) return req; if (found.tag == FORALL) return instantiatePoly(pos, (ForAll)found, req, convertWarner(pos, found, req)); if (req.tag == NONE) return found; if (types.isAssignable(found, req, convertWarner(pos, found, req))) return found; if (found.tag <= DOUBLE && req.tag <= DOUBLE) return typeError(pos, JCDiagnostic.fragment("possible.loss.of.precision"), found, req); if (found.isSuperBound()) { log.error(pos, "assignment.from.super-bound", found); return syms.errType; } if (req.isExtendsBound()) { log.error(pos, "assignment.to.extends-bound", req); return syms.errType; } return typeError(pos, JCDiagnostic.fragment("incompatible.types"), found, req); }
/** Check that a given type is assignable to a given proto-type. * If it is, return the type, otherwise return errType. * @param pos Position to be used for error reporting. * @param found The type that was found. * @param req The type that was required. */ Type checkType(DiagnosticPosition pos, Type found, Type req) { if (req.tag == ERROR) return req; if (found.tag == FORALL) return instantiatePoly(pos, (ForAll)found, req, convertWarner(pos, found, req)); if (req.tag == NONE) return found; if (types.isAssignable(found, req, convertWarner(pos, found, req))) return found; if (found.tag <= DOUBLE && req.tag <= DOUBLE) return typeError(pos, JCDiagnostic.fragment("possible.loss.of.precision"), found, req); if (found.isSuperBound()) { log.error(pos, "assignment.from.super-bound", found); return syms.errType; } if (req.isExtendsBound()) { log.error(pos, "assignment.to.extends-bound", req); return syms.errType; } return typeError(pos, JCDiagnostic.fragment("incompatible.types"), found, req); }
} else { JCDiagnostic d = ex.getDiagnostic(); return typeError(pos, JCDiagnostic.fragment("incompatible.types" + (d!=null ? ".1" : ""), d), t, pt);
} else { JCDiagnostic d = ex.getDiagnostic(); return typeError(pos, JCDiagnostic.fragment("incompatible.types" + (d!=null ? ".1" : ""), d), t, pt);
typeError(TreeInfo.diagnosticPositionFor(m, tree), JCDiagnostic.fragment("override.incompatible.ret", cannotOverride(m, other)),
typeError(TreeInfo.diagnosticPositionFor(m, tree), JCDiagnostic.fragment("override.incompatible.ret", cannotOverride(m, other)),