Skip to content

Commit e192094

Browse files
authored
Allow non-void static setter methods when compiling with -opt (#1063)
1 parent bddd2e1 commit e192094

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

cppwinrt/component_writers.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,16 +498,18 @@ catch (...) { return winrt::to_hresult(); }
498498
{
499499
auto format = R"( % %::%(%)
500500
{
501-
return @::implementation::%::%(%);
501+
%@::implementation::%::%(%);
502502
}
503503
)";
504504

505+
bool ignore_return = is_put_overload(method) || !signature.return_signature();
505506

506507
w.write(format,
507508
signature.return_signature(),
508509
type_name,
509510
method_name,
510511
bind<write_consume_params>(signature),
512+
ignore_return ? "" : "return ",
511513
type_namespace,
512514
type_name,
513515
method_name,

test/test_component/Class.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,22 @@ namespace winrt::test_component::implementation
113113
Windows::Foundation::IAsyncOperation<int> RaiseDeferrableEventAsync();
114114

115115
static bool TestNoMakeDetection();
116+
117+
static int32_t StaticPropertyWithAsyncSetter()
118+
{
119+
return 0;
120+
}
121+
122+
static fire_and_forget StaticPropertyWithAsyncSetter(int32_t)
123+
{
124+
co_return;
125+
}
126+
127+
static fire_and_forget StaticMethodWithAsyncReturn()
128+
{
129+
co_return;
130+
}
131+
116132
private:
117133

118134
bool m_fail{};

test/test_component/test_component.idl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ namespace test_component
156156
Windows.Foundation.IAsyncOperation<Int32> RaiseDeferrableEventAsync();
157157

158158
static Boolean TestNoMakeDetection();
159+
static Int32 StaticPropertyWithAsyncSetter;
160+
static void StaticMethodWithAsyncReturn();
159161
}
160162

161163
namespace Structs

0 commit comments

Comments
 (0)