import java.util.Objects;
import java.util.OptionalDouble;
import java.util.OptionalInt;

public class DeadStoreBug {

private final MyInterface value;

private DeadStoreBug(final MyInterface aValue) {
value = Objects.requireNonNull(aValue);
}

public OptionalInt getInt() {
if (value instanceof RecordWithInt(final int i)) {
return OptionalInt.of(i);
}
return OptionalInt.empty();
}

public OptionalDouble getDouble() {
if (value instanceof RecordWithDouble(final double d)) {
return OptionalDouble.of(d);
}
return OptionalDouble.empty();
}

public sealed interface MyInterface permits RecordWithInt, RecordWithDouble {
}

private record RecordWithInt(int i) implements MyInterface {
}

private record RecordWithDouble(double d) implements MyInterface {
}
} 