Bug 484613 - 'Extract local variable' refactoring on an lvalue expression should make the type of the extracted variable a reference
Summary: 'Extract local variable' refactoring on an lvalue expression should make the ...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: Next   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-17 18:20 EST by Nathan Ridge CLA
Modified: 2020-09-04 15:18 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Ridge CLA 2015-12-17 18:20:17 EST
Start with the following code:

  void test(bool cond) {
      int x, y;
      (cond ? x : y) = 1 + 2;
  }

select the expression '(cond ? x: y)' and perform the 'Extract local variable' refactoring.

The result is:

  void test(bool cond) {
      int x, y;
      int extracted = cond ? x : y;
      extracted = 1 + 2;
  }

which clearly loses the original intent of the code.

The type of 'extracted' should be 'int&' instead.