Files
openide/java/java-tests/testData/refactoring/extractMethodNew/NullableCheckBreakDuplicate_after.java
Mikhail Pyltsin 2023228d8c [java-generation] IDEA-344399 generate annotation based on type_use option
- extracted new option
- reuse this option in MissortedModifiersInspection
- override uses this option too

GitOrigin-RevId: 39f3f72991240753c86c7f80df865728aa9743ad
2024-06-17 21:14:57 +00:00

39 lines
740 B
Java

import org.jetbrains.annotations.Nullable;
import java.util.List;
public class NullableCheckBreakDuplicate {
List<Pojo> things;
void foo() {
while (true) {
Pojo x = newMethod();
if (x == null) break;
System.out.println(x.it);
}
}
@Nullable
private NullableCheckBreakDuplicate.Pojo newMethod() {
Pojo x = things.get(0);
if (x.it > 0) return null;
things.remove(x);
return x;
}
void baz() {
while (true) {
Pojo x = newMethod();
if (x == null) break;
System.out.println(x.it);
}
}
static class Pojo {
double it;
Pojo(double w) { it = w; }
}
}