Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cppwinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2718,9 +2718,11 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable<T, D, %>

auto depends = [](writer& w, complex_struct const& left, complex_struct const& right)
{
auto right_type = w.write_temp("%", right.type);
std::string right_as_ref = std::string("winrt::Windows::Foundation::IReference<") + right_type + ">";
for (auto&& field : left.fields)
{
if (w.write_temp("%", right.type) == field.second)
if (right_type == field.second || right_as_ref == field.second)
{
return true;
}
Expand Down
20 changes: 20 additions & 0 deletions test/test_component/test_component.idl
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,26 @@ namespace test_component
Int32 OuterValue;
};
}

// structs can contain nullable types (IReference<>) as well as strings. These are the only non-POD types
// Alphabetical sorting of names below is important to validate sort order in generated code. Metadata will
// sort to alphabetical order. cppwinrt needs to re-establish dependencies in the IReference types to produce
// correct output.
struct NullableC
{
Single a1;
Windows.Foundation.IReference<Single> a2;
};

struct NullableB
{
Windows.Foundation.IReference<NullableC> a1;
};

struct NullableA
{
Windows.Foundation.IReference<NullableB> a1;
};
}

namespace Parent
Expand Down