1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:07:44 +00:00

LibCore: Fix compilation of infallible Promise::when_resolved handlers

This overload is currently unused. When used, it doesn't compile due to
mismatched return types in the handler provided to the function and the
type of `on_resolution`.
This commit is contained in:
Timothy Flynn 2023-12-31 09:40:43 -05:00 committed by Andreas Kling
parent 75e60d3a68
commit c190294a76
2 changed files with 24 additions and 7 deletions

View file

@ -82,13 +82,10 @@ public:
template<CallableAs<void, Result&> F>
Promise& when_resolved(F handler)
{
on_resolution = [handler = move(handler)](Result& result) { return handler(result); };
if (is_resolved()) {
auto handler_result = on_resolution(m_result_or_rejection->value());
possibly_handle_rejection(handler_result);
}
return *this;
return when_resolved([handler = move(handler)](Result& result) -> ErrorOr<void> {
handler(result);
return {};
});
}
template<CallableAs<ErrorOr<void>, Result&> F>