1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

AK+Everywhere: Disallow constructing Functions from incompatible types

Previously, AK::Function would accept _any_ callable type, and try to
call it when called, first with the given set of arguments, then with
zero arguments, and if all of those failed, it would simply not call the
function and **return a value-constructed Out type**.
This lead to many, many, many hard to debug situations when someone
forgot a `const` in their lambda argument types, and many cases of
people taking zero arguments in their lambdas to ignore them.
This commit reworks the Function interface to not include any such
surprising behaviour, if your function instance is not callable with
the declared argument set of the Function, it can simply not be
assigned to that Function instance, end of story.
This commit is contained in:
Ali Mohammad Pur 2021-06-05 23:04:31 +04:30 committed by Ali Mohammad Pur
parent 104dc93220
commit 51c2c69357
28 changed files with 99 additions and 92 deletions

View file

@ -30,16 +30,16 @@ void TLSv12WebSocketConnectionImpl::connect(ConnectionInfo const& connection)
m_socket->on_tls_error = [this](TLS::AlertDescription) {
on_connection_error();
};
m_socket->on_tls_ready_to_read = [this] {
m_socket->on_tls_ready_to_read = [this](auto&) {
on_ready_to_read();
};
m_socket->on_tls_ready_to_write = [this] {
m_socket->on_tls_ready_to_write = [this](auto&) {
on_connected();
};
m_socket->on_tls_finished = [this] {
on_connection_error();
};
m_socket->on_tls_certificate_request = [this](auto&) {
m_socket->on_tls_certificate_request = [](auto&) {
// FIXME : Once we handle TLS certificate requests, handle it here as well.
};
bool success = m_socket->connect(connection.url().host(), connection.url().port());