diff --git a/cppwinrt/code_writers.h b/cppwinrt/code_writers.h index 0ab93b334..65cc48b9c 100644 --- a/cppwinrt/code_writers.h +++ b/cppwinrt/code_writers.h @@ -3163,10 +3163,12 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable auto method_name = get_name(method); auto async_types_guard = w.push_async_types(signature.is_async()); + auto is_event = is_add_overload(method); + if (is_opt_type) { w.write(" %static % %(%);\n", - is_get_overload(method) ? "[[nodiscard]] " : "", + is_get_overload(method) || is_event ? "[[nodiscard]] " : "", signature.return_signature(), method_name, bind(signature)); @@ -3174,12 +3176,12 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable else { w.write(" %static auto %(%);\n", - is_get_overload(method) ? "[[nodiscard]] " : "", + is_get_overload(method) || is_event ? "[[nodiscard]] " : "", method_name, bind(signature)); } - if (is_add_overload(method)) + if (is_event) { { auto format = R"( using %_revoker = impl::factory_event_revoker<%, &impl::abi_t<%>::remove_%>;