@ApiStatus.Internal
  public @NotNull Runnable wrapCoroutineInvocation(final @NotNull Runnable runnable, @NotNull ModalityState modalityState) {
    return new Runnable() {
      @Override
      public void run() {
        if (isWriteSafeModality(modalityState)) {
          runWithWritingAllowed(runnable);
        }
        else {
          runnable.run();
        }
      }

      @Override
      public String toString() {
        return runnable.toString();
      }
    };
  }
@ApiStatus.Internal
  public @NotNull Runnable wrapCoroutineInvocation(final @NotNull Runnable runnable, @NotNull ModalityState modalityState)