Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-22076

Incorrect code generated for implementing members of templated classes

    XMLWordPrintable

Details

    • 8ee97b1e0 (13.0)

    Description

      Consider a simple template class:
       

      namespace ns
      {
      template<typename T>
      class MyClass
      {
      public:
          void bar();
          void foo(T arg);
      };
      }
      

      When using refactoring on foo() to generate the implementation of the method outside the class the Qt Creator generates the following incorrect code:
       

      template<typename T>
      void MyClass::foo(ns::T arg)
      {
      }
      

      There are two problems with this:
      1) The template argument is missing in the class name. It should be

      MyClass<T>::

      2) The name of the namespace is being inserted as a qualifier for the template argument for some reason (this does not happen when the class is NOT in a namespace). It should be

      MyClass<T>::foo(T arg)

      Furthermore if I generate the implementation for bar() AFTER foo() the previous method's beginning is incorrectly detected and the template line ends up above the new definition like this:

      template<typename T>
      template<typename T>
      void MyClass::bar()
      {
      }
      
      void MyClass::foo(acore::T arg)
      { 
      }
      

      This requires a lot of manual fixing after generating the code.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kandeler Christian Kandeler
              resurr3ction Michael Vlach
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes