{"action":"closed","issue":{"url":"https://api.github.com/repos/Microsoft/cppwinrt/issues/310","repository_url":"https://api.github.com/repos/Microsoft/cppwinrt","labels_url":"https://api.github.com/repos/Microsoft/cppwinrt/issues/310/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/cppwinrt/issues/310/comments","events_url":"https://api.github.com/repos/Microsoft/cppwinrt/issues/310/events","html_url":"https://github.com/Microsoft/cppwinrt/issues/310","id":289889374,"number":310,"title":"Compilation error: 'winrt::impl::produce_dispatch_to_super'","user":{"login":"Alovchin91","id":8490695,"avatar_url":"https://avatars1.githubusercontent.com/u/8490695?v=4","gravatar_id":"","url":"https://api.github.com/users/Alovchin91","html_url":"https://github.com/Alovchin91","followers_url":"https://api.github.com/users/Alovchin91/followers","following_url":"https://api.github.com/users/Alovchin91/following{/other_user}","gists_url":"https://api.github.com/users/Alovchin91/gists{/gist_id}","starred_url":"https://api.github.com/users/Alovchin91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alovchin91/subscriptions","organizations_url":"https://api.github.com/users/Alovchin91/orgs","repos_url":"https://api.github.com/users/Alovchin91/repos","events_url":"https://api.github.com/users/Alovchin91/events{/privacy}","received_events_url":"https://api.github.com/users/Alovchin91/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2018-01-19T07:49:39Z","updated_at":"2018-02-05T04:39:32Z","closed_at":"2018-02-05T04:39:32Z","author_association":"NONE","body":"Hi @kennykerr,\r\n\r\nI've been playing further with the abilities of C++/WinRT and found a bug in cppwinrt.exe compiler.\r\n\r\n#### Repro:\r\nConsider having this kind of IDL:\r\n```\r\nnamespace WinRtComponent.Composables\r\n{\r\n    runtimeclass NativeComposable;\r\n\r\n    [version(2.0)]\r\n    [uuid(2ac58481-96b8-526f-bde4-340f055b25d4)]\r\n    [exclusiveto(NativeComposable)]\r\n    interface INativeComposable : IInspectable\r\n    {\r\n        HRESULT DoSomething();\r\n    }\r\n\r\n    [version(2.0)]\r\n    [uuid(bef63057-1984-5536-87c2-eaf8dcd01791)]\r\n    [exclusiveto(NativeComposable)]\r\n    interface INativeComposableFactory : IInspectable\r\n    {\r\n        HRESULT CreateInstance([in] IInspectable* outer, [out] IInspectable** inner, [out, retval] NativeComposable** instance);\r\n    }\r\n\r\n    [version(2.0)]\r\n    [uuid(4223486f-6471-5630-99d2-3ce994306826)]\r\n    [exclusiveto(NativeComposable)]\r\n    interface INativeComposableOverrides : IInspectable\r\n    {\r\n        HRESULT YouCanOverrideThis([in] HSTRING input);\r\n    }\r\n\r\n    [version(2.0)]\r\n    [composable(INativeComposableFactory, public, 2.0)]\r\n    [marshaling_behavior(agile)]\r\n    [threading(both)]\r\n    runtimeclass NativeComposable\r\n    {\r\n        [default] interface INativeComposable;\r\n        [overridable] interface INativeComposableOverrides;\r\n    }\r\n}\r\n```\r\nWhen the cppwinrt.exe compiler invokes, it produces a `module.g.h` file that contains the following definition:\r\n```cpp\r\nnamespace winrt::impl {\r\n// ...\r\ntemplate <typename T, typename D>\r\nstruct WINRT_EBO produce_dispatch_to_super<T, D, WinRtComponent::Composables::INativeComposableOverrides>\r\n    : produce_dispatch_to_super_base<T, D, WinRtComponent::Composables::INativeComposableOverrides>\r\n{\r\n    void YouCanOverrideThis(hstring const& input)\r\n    {\r\n        WinRtComponent::Composables::INativeComposableOverrides super = this->shim_super();\r\n        if (super)\r\n        {\r\n            return super.YouCanOverrideThis(input);\r\n        }\r\n        return this->shim().YouCanOverrideThis(input);\r\n    }\r\n};\r\n}\r\n```\r\nNow the compilation of the project fails because the compiler can't find the definition of `INativeComposableOverrides`:\r\n```\r\n1>module.g.cpp\r\n1>d:\\lab\\winrtcomponent\\winrtcomponent\\generated files\\module.g.h(14): error C2653: 'WinRtComponent': is not a class or namespace name\r\n1>d:\\lab\\winrtcomponent\\winrtcomponent\\generated files\\module.g.h(14): error C2065: 'INativeComposableOverrides': undeclared identifier\r\n1>d:\\lab\\winrtcomponent\\winrtcomponent\\generated files\\module.g.h(15): error C2923: 'winrt::impl::produce_dispatch_to_super': 'INativeComposableOverrides' is not a valid template type argument for parameter 'I'\r\n1>d:\\lab\\winrtcomponent\\winrtcomponent\\generated files\\module.g.h(26): error C2976: 'winrt::impl::produce_dispatch_to_super': too few template arguments\r\n1>d:\\lab\\winrtcomponent\\winrtcomponent\\generated files\\module.g.h(15): note: see declaration of 'winrt::impl::produce_dispatch_to_super'\r\n```\r\nOn the other hand, there is a `WinRtComponent.Composables.2.h` file that contains an empty namespace definition:\r\n```cpp\r\nnamespace winrt::impl {\r\n\r\n}\r\n```\r\nIf I move the above `produce_dispatch_to_super` class definition to this empty space (removing it from `module.g.h`), everything compiles fine and works as expected. So I believe that:\r\n\r\n#### Expected behavior:\r\n`produce_dispatch_to_super` class should be defined in `WinRtComponent.Composables.2.h` file. Project compiles.\r\n\r\n#### Actual behavior:\r\n`produce_dispatch_to_super` class is defined in `module.g.h` file. Project does not compile."}}
{"actor":{"display_login":"kennykerr"}}