IDEA-383350 [java-intentions] fix 'Bind parameters to fields' producing red code when field is assigned indirectly

GitOrigin-RevId: 8879b800315a194e8e04e9e0e6f7ca1b5b5205bc
This commit is contained in:
Bartek Pacia
2025-12-12 15:39:43 +00:00
committed by intellij-monorepo-bot
parent 81c107b047
commit 485b1b4336
3 changed files with 43 additions and 0 deletions
@@ -0,0 +1,10 @@
// "Bind constructor parameters to fields" "false"
class Test {
private final String value;
Test(String <caret>input) {
String processed = input.toUpperCase();
this.value = processed;
}
}
@@ -0,0 +1,25 @@
// "Bind constructor parameters to fields" "false"
import java.util.Collections;
import java.util.LinkedHashSet;
class Person {
String name;
int age;
Person(String name, int age) {
this.name = name;
this.age = age;
}
}
class Interesting extends Person {
private final String[] hobbies;
Interesting(String name, int age, String... <caret>hobbies) {
super(name, age);
LinkedHashSet hobbySet = new LinkedHashSet<>();
Collections.addAll(hobbySet, hobbies);
this.hobbies = hobbySet.toArray(new String[hobbySet.size()]);
}
}