-
Notifications
You must be signed in to change notification settings - Fork 263
Description
Version
2.0.240405.15
Summary
There is a compiler error due to code generated by cppwinrt when trying to use winrt::Windows::UI::Xaml::Controls::DataTemplateSelectorT as a base class.
Reproducible example
struct Example : DataTemplateSelectorT<Example>
{
};
Grab the project from https://github.com/dlech/BlankApp1, open in Visual Studio and build.
Code that causes the problem is here: https://github.com/dlech/BlankApp1/blob/d2869cb888d4d67534ba76643816a15bfa0274c8/BlankApp1/App.cpp#L16-L18
Expected behavior
cppwrint should generate code that doesn't cause a compile error.
Actual behavior
Build fails with the following error:
1>C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66450,9): error C2602: 'winrt::impl::consume_Windows_UI_Xaml_Controls_IDataTemplateSelectorOverrides<D>::SelectTemplateCore' is not a member of a base class of 'winrt::Windows::UI::Xaml::Controls::DataTemplateSelectorT<Example>'
1>C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66450,9): error C2602: with
1>C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66450,9): error C2602: [
1>C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66450,9): error C2602: D=Example
1>C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66450,9): error C2602: ]
1>(compiling source file '/App.cpp')
1> C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\impl\Windows.UI.Xaml.Controls.0.h(17492,14):
1> see declaration of 'winrt::impl::consume_Windows_UI_Xaml_Controls_IDataTemplateSelectorOverrides<D>::SelectTemplateCore'
1> with
1> [
1> D=Example
1> ]
1> C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66436,12):
1> see declaration of 'winrt::Windows::UI::Xaml::Controls::DataTemplateSelectorT<Example>'
1> C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66450,9):
1> the template instantiation context (the oldest one first) is
1> C:\Users\extra\source\repos\BlankApp1\BlankApp1\App.cpp(16,18):
1> see reference to class template instantiation 'winrt::Windows::UI::Xaml::Controls::DataTemplateSelectorT<Example>' being compiled
1>C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66451,9): error C2602: 'winrt::impl::consume_Windows_UI_Xaml_Controls_IDataTemplateSelectorOverrides2<D>::SelectTemplateCore' is not a member of a base class of 'winrt::Windows::UI::Xaml::Controls::DataTemplateSelectorT<Example>'
1>C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66451,9): error C2602: with
1>C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66451,9): error C2602: [
1>C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66451,9): error C2602: D=Example
1>C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66451,9): error C2602: ]
1>(compiling source file '/App.cpp')
1> C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\impl\Windows.UI.Xaml.Controls.0.h(17501,14):
1> see declaration of 'winrt::impl::consume_Windows_UI_Xaml_Controls_IDataTemplateSelectorOverrides2<D>::SelectTemplateCore'
1> with
1> [
1> D=Example
1> ]
1> C:\Users\extra\source\repos\BlankApp1\BlankApp1\Generated Files\winrt\Windows.UI.Xaml.Controls.h(66436,12):
1> see declaration of 'winrt::Windows::UI::Xaml::Controls::DataTemplateSelectorT<Example>'
Additional comments
I discovered this while working on the PyWinRT bindings. Using any other TypeT as a base class compiles fine. There seems to be something odd about winrt::Windows::UI::Xaml::Controls::DataTemplateSelectorT::SelectTemplateCore specially. It is likely the only type where it has two overloads with the same name and different parameters defined in two different interfaces.