mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-03 12:10:37 +07:00
GitOrigin-RevId: 38acb417580fb33999bb607ca16b24b4fd04b04e
35 lines
1.7 KiB
Java
35 lines
1.7 KiB
Java
public class InstanceOfDeconstructionNameConflicts {
|
|
|
|
public interface Container {
|
|
}
|
|
|
|
public record ValueContainerA(Object value) implements Container {
|
|
}
|
|
|
|
public record ValueContainerB(Object value) implements Container {
|
|
}
|
|
|
|
public record ValueContainerC(Object value, Object value2) implements Container {
|
|
}
|
|
|
|
public static boolean firstDeconstruction(Container x) {
|
|
return (x instanceof ValueContainerA(Object value) && value.hashCode() == 0) ||
|
|
(x instanceof ValueContainerB(Object <error descr="Variable 'value' is already defined in the scope">value</error>) && value.hashCode() == 0);
|
|
}
|
|
|
|
public static boolean doubleDeconstruction(Container x) {
|
|
return (x instanceof ValueContainerA(Object value) && value.hashCode() == 0) ||
|
|
(x instanceof ValueContainerC(Object <error descr="Variable 'value1' is already defined in the scope">value1</error>, Object <error descr="Variable 'value1' is already defined in the scope">value1</error>));
|
|
}
|
|
|
|
public static boolean nestedDeconstruction(Container x) {
|
|
return (x instanceof ValueContainerA(ValueContainerA(Object value)) && value.hashCode() == 0) ||
|
|
(x instanceof ValueContainerB(ValueContainerB(Object <error descr="Variable 'value' is already defined in the scope">value</error>)) && value.hashCode() == 0);
|
|
}
|
|
|
|
public static boolean nestedDeconstructionDouble(Container x) {
|
|
return (x instanceof ValueContainerA(ValueContainerA(Object value2)) && value2.hashCode() == 0) ||
|
|
(x instanceof ValueContainerC(ValueContainerB(Object <error descr="Variable 'value' is already defined in the scope">value</error>), ValueContainerB(Object <error descr="Variable 'value' is already defined in the scope">value</error>)));
|
|
}
|
|
}
|