private Object @NotNull [] resizeIfNecessary(int size) {
    Object[] array = asArray();
    int oldCapacity = array.length;
    if (size >= oldCapacity) {
      // have to resize
      int newCapacity = Math.max(oldCapacity * 3 / 2 + 1, size + 1);
      myElem = array = ArrayUtil.realloc(array, newCapacity, Object[]::new);
    }
    return array;
  }
private Object @NotNull [] resizeIfNecessary(int size)