private static <TRef, TResult> void cache(@NotNull TRef ref, @NotNull Map<? super TRef, TResult> map, TResult result, @NotNull Computable<? extends TResult> doResolve) {
    // optimization: less contention
    TResult cached = map.get(ref);
    if (cached != null) {
      if (cached == result) {
        return;
      }
      IdempotenceChecker.checkEquivalence(cached, result, ref.getClass(), doResolve);
    }
    map.put(ref, result);
  }
private static <TRef, TResult> void cache(@NotNull TRef ref, @NotNull Map<? super TRef, TResult> map, TResult result, @NotNull Computable<? extends TResult> doResolve)