Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 546302

Summary: [quick assist] Create getter/setter doesn't respect field access under some conditions when just one getter/setter is created
Product: [Eclipse Project] JDT Reporter: Roland Grunberg <rgrunber>
Component: UIAssignee: Kenneth Styrberg <kenneth>
Status: VERIFIED FIXED QA Contact: Roland Grunberg <rgrunber>
Severity: normal    
Priority: P3 CC: kenneth, tobias_widmer
Version: 4.12   
Target Milestone: 4.12 M3   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/140529
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=e4738e9a11af9e88998afc33430c33d179e103a0
Whiteboard:
Bug Depends on: 232920    
Bug Blocks:    

Description Roland Grunberg CLA 2019-04-10 10:51:51 EDT
1) Use the following snippet

package test;

public class Test {

	private String myField;
	
	public void test() {
		myField += 10;
	}

}

2) Trigger the quick-assist to 'create getter and setter for myField ...'
3) Disable setter creation via the checkbox, leaving the getter to be created, and ensure field access in declaring type is set to 'use getter and setter'. Then click ok. (Also if you click preview it generates an error but still allows you to apply the change)

The getter is created as expected, but 'myField += 10;' remains the same. It would be expected for that statement to change to 'myField = getMyField() + 10;'
Comment 1 Roland Grunberg CLA 2019-04-12 10:49:39 EDT
@Kenneth, could you have a look at this ? There are just some corner cases to address.
Comment 2 Kenneth Styrberg CLA 2019-04-12 11:08:05 EDT
I'll check
Comment 3 Eclipse Genie CLA 2019-04-13 03:08:14 EDT
New Gerrit change created: https://git.eclipse.org/r/140529
Comment 5 Roland Grunberg CLA 2019-04-24 16:26:37 EDT
Thanks again for taking this.
Comment 6 Roland Grunberg CLA 2019-05-22 14:05:30 EDT
Verified for 4.12 M3 using I20190522-0600 build
Comment 7 Noopur Gupta CLA 2019-06-17 08:38:38 EDT
*** Bug 86604 has been marked as a duplicate of this bug. ***