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

Moving definition outside of a template class works wrong under some circumstances

    XMLWordPrintable

Details

    • Linux/X11

    Description

      When "if constexpr" contains some function call or a variable as condition and its body contains nested scope, it's not possible to move a function definition outside of the class correctly.

       

      Repro steps:

      1) Launch Qt Creator

      2) Use the following code snippet:

      template <class Bar, class Baz>
      class Foo
      {
      public:
          void doSmth()
          {
              if constexpr (someCondition()) {
                  for (int i = 0; i <10; ++i) {
                  }
              }
          }   
      
          void doSmthElse()
          {
              // ...
          }    
      
          static constexpr bool someCondition() { return std::is_base_of<int, Bar>{}; }
      };

      3) Move the definition of doSmth() function outside of the class using standard refactoring option

       

      Actual: the last curly brace is not moved (at all)

      Expected: the function moved outside correctly

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            vitaly.fanaskov Vitaly Fanaskov
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes