Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.1.2RC1
-
Fix Version/s: 2.5.0Release
-
Component/s: Refactoring
-
Labels:None
-
Number of attachments :
Description
Inside of this code:
class Result {
def val
def doOperation= {
val
}
}
Perform rename refactor on val. And after committing the refactoring change, the processor comes up with a warning:
The reference to val2 will be shadowed by a renamed declaration.
This is happening because we are visiting the closure expression twice when looking for references. The first time as part of the field declaration and the second time as part of the default constructor (groovy stuffs field initializers into the default constructor). So, we need to be more careful about visiting here.
Just to note, if the user clicks Continue the refactoring completes as expected with no errors.
I think the solution here is as simple as not visiting the field initializer directly from the inferencing engine. Let the visit happen indirectly when the default constructor is visited. However, I'm not confident enough yet that this won't fail under certain situations such as when there is an existing default constructor.