Files
openide/java/java-tests/testData/refactoring/extractMethodNew/NotNullArgumentTooComplexCode_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

34 lines
1016 B
Java

import org.jetbrains.annotations.NotNull;
class TooComplexCode {
static class X { @NotNull X get() { return this; }}
static class A extends X { @NotNull X get() { return new B(); }}
static class B extends X { @NotNull X get() { return new C(); }}
static class C extends X { @NotNull X get() { return new A(); }}
void tooComplex(@NotNull X x) {
if (x instanceof A) {
X y = newMethod(x);
if (y instanceof A) {
System.out.println("A A "+x+' '+y);
}
if (y instanceof B) {
System.out.println("A B "+x+' '+y);
}
}
if (x instanceof B) {
X y = newMethod(x);
if (y instanceof A) {
System.out.println("B A "+x+' '+y);
}
if (y instanceof B) {
System.out.println("B B "+x+' '+y);
}
}
}
@NotNull
private TooComplexCode.X newMethod(@NotNull X x) {
return x.get();
}
}