Skip to content

Rename property refactoring produces invalid code in @CompileStatic classes #1396

@mauromol

Description

@mauromol

Using Greclipse 4.7.0.v202209190834-e2206.

Consider the following Java class:

package testrefactoring;

public class MyPojo {
	private String foo;
	
	public String getFoo() {
		return foo;
	}
	
	public void setFoo(String foo) {
		this.foo = foo;
	}
}

And the following Groovy class:

package testrefactoring

import groovy.transform.CompileStatic

@CompileStatic
class GClass {

	void foobar() {
		def pojo = new MyPojo()
		println pojo.foo
	}
}

Now, rename MyPojo.foo to MyPojo.bar, ensuring the getter and the setter are renamed as well.
After the renaming occurs, in GClass I see:
println pojo.getBar
which is of course invalid.

The problem goes away if I remove @CompileStatic from GClass.
I'm pretty sure this used to work correctly in the past.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions