/// Allow a diagnostic to be converted to 'failure'.
operator LogicalResult() const;
+ /// Allow a diagnostic to be converted to FailureOr<T>. Always results in
+ /// 'failure' because this cast cannot possibly return an object of 'T'.
+ template <typename T>
+ operator FailureOr<T>() const {
+ return failure();
+ }
+
private:
Diagnostic(const Diagnostic &rhs) = delete;
Diagnostic &operator=(const Diagnostic &rhs) = delete;
/// 'success' if this is an empty diagnostic.
operator LogicalResult() const;
+ /// Allow an inflight diagnostic to be converted to FailureOr<T>. Always
+ /// results in 'failure' because this cast cannot possibly return an object of
+ /// 'T'.
+ template <typename T>
+ operator FailureOr<T>() const {
+ return failure();
+ }
+
private:
InFlightDiagnostic &operator=(const InFlightDiagnostic &) = delete;
InFlightDiagnostic &operator=(InFlightDiagnostic &&) = delete;