Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 574736 - [17] Refactor rename of local variable used in Pattern Matching for switch results in error
Summary: [17] Refactor rename of local variable used in Pattern Matching for switch re...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.21   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: BETA J17   Edit
Assignee: Sarika Sinha CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 573941
Blocks: 572061
  Show dependency tree
 
Reported: 2021-07-08 08:35 EDT by Vikas Chandra CLA
Modified: 2021-08-12 03:41 EDT (History)
1 user (show)

See Also:


Attachments
Problem shown in the image (39.43 KB, image/png)
2021-07-08 08:35 EDT, Vikas Chandra CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vikas Chandra CLA 2021-07-08 08:35:01 EDT
Created attachment 286757 [details]
Problem shown in the image

public static void main(String[] args) {

foo(Integer.valueOf(5));
foo(new Object());
}
private static void foo(Object o) {
 int local=0;
 switch (o) {
	case Integer i     : System.out.println("Integer:" + i);
	case String /*here*/str && local>0    : System.out.println("String:" + str + str);
	default       : System.out.println("Object" + o);
 	}
}
}



Try renaming  local to local2. You can see an error message and refactor-> rename is unsuccessful. See image
Comment 1 Kalyan Prasad Tatavarthi CLA 2021-08-12 03:39:50 EDT
fixed as a result of fix for bug 573941