Applying SL:Declare on separated line refactoring breaks the code

Please provide

  • Operating system: Ubuntu Linux
  • SonarLint plugin version:
  • Programming language you’re coding in: Java
  • Is connected mode used: No
    • Connected to SonarCloud or SonarQube (and which version):

And a thorough description of the problem / question:
Given code:

package proof;
class SLRefTest {
    public static void main(String... args) {
        Provider mesh = new Provider();
        int from[] = mesh.from, to[] =, last = -1;

    public static class Provider {
        int[] from;
        int[] to;


Set caret on to variable declaration and invoke Declare on separated lines refactoring
line converts to invalid:

        int from[] = mesh.from;
        int from[] = mesh.from, to[] to[] =;
        int last = -1;

Hello @Maks_Khramov ,

Thanks for the report and the excellent reproducer. Indeed, there seems to be a bug here − I’ve created a ticket to track the issue.