Bug 507614 - [encapsulate field] A behavior preserving transformation (Encapsulate Field Refactoring) is rejected. [Cannot convert postfix expression. It is used inside another expression.]
Summary: [encapsulate field] A behavior preserving transformation (Encapsulate Field R...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-16 09:36 EST by Melina Mongiovi CLA
Modified: 2023-07-17 19:11 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Melina Mongiovi CLA 2016-11-16 09:36:04 EST
Behavior Preserving Transformation is rejected.

Reproducible: Always

Steps to Reproduce:
1. Create the following program
public class TestPostfixExpression {
	int field;
	
	public void foo() {
		int i;
		i= field++;
	}
}



2. Encapsulate Field field

3. The tool does not apply the transformation and warn the following message:
Cannot convert postfix expression. It is used inside another expression.

4. However, the following possible resulting program compiles and the transformation preserves the program behavior, which indicates that some refactoring conditions may be overly strong. 

public class TestPostfixExpression {
	int field;
	
	public void foo() {
		int i;
		i= field++;
	}
	
	public int getField() {
		return field;
	}
	public void setField(int field) {
		this.field = field;
	}
}
Comment 1 Kenneth Styrberg CLA 2019-08-05 13:17:32 EDT
After Bug 232920 was merged, the behaviour changed and now the tool indeed do the transform. It does however issue a warning that it cannot transform the expression "i= field++;" when transforming using setter and getters, the transformation is still performed but keeping the expression.
When used with the setting "keep field reference", no warning is issued.
Comment 2 Eclipse Genie CLA 2021-07-26 11:06:14 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 3 Eclipse Genie CLA 2023-07-17 19:11:54 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.