Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/makeVarEffectivelyFinal/beforeIfUsedInCondition.java
Tagir Valeev 0d5ea1d59e [java-intentions] Disable 'convert to if' when if-condition refers to the variable
Also: fix for var types
Fixes IDEA-374029 "Make effectively final" generates uncompilable code

GitOrigin-RevId: 17932aefe036dec167aabaf2066c4cdff11947da
2025-06-17 13:31:39 +00:00

31 lines
645 B
Java

// "Make 'companies' effectively final by moving initializer to the 'if' statement" "false"
import java.util.List;
class Abc {
private void method(X x, List<Integer> list) {
var companies = x.getCompanies();
if (companies.isEmpty()) {
companies = List.of(x.getCompanyId());
}
list.forEach(w -> something(comp<caret>anies));
}
private void something(List<Integer> companies) {
}
static public class X {
private int companyId;
private List<Integer> companies;
public int getCompanyId() {
return companyId;
}
public List<Integer> getCompanies() {
return companies;
}
}
}