private void updateRefMethod(PsiElement psiResolved,
                               RefMethodImpl refMethod,
                               @NotNull UExpression uExpression,
                               final UElement uFrom) {
    UMethod uMethod = Objects.requireNonNull(UastContextKt.toUElement(psiResolved, UMethod.class));
    refMethod.initializeIfNeeded();
    if (uExpression instanceof UCallableReferenceExpression callableReference) {
      PsiType returnType = uMethod.getReturnType();
      if (!uMethod.isConstructor()) {
        final PsiType type = getFunctionalInterfaceType(callableReference);
        if (!PsiTypes.voidType().equals(LambdaUtil.getFunctionalInterfaceReturnType(type))) {
          refMethod.setReturnValueUsed(true);
          addTypeReference(uFrom, returnType, refMethod.getRefManager());
        }
      }
      refMethod.setParametersAreUnknown();
      return;
    }
    if (uExpression instanceof ULiteralExpression) { //references in literal expressions
      PsiType returnType = uMethod.getReturnType();
      if (!uMethod.isConstructor() && !PsiTypes.voidType().equals(returnType)) {
        refMethod.setReturnValueUsed(true);
        addTypeReference(uFrom, returnType, refMethod.getRefManager());
      }
      return;
    }

    PsiType returnType = uMethod.getReturnType();
    if (!uMethod.isConstructor() && !PsiTypes.voidType().equals(returnType)) {
      PsiExpression expression = ObjectUtils.tryCast(uExpression.getJavaPsi(), PsiExpression.class);
      if (expression == null || !ExpressionUtils.isVoidContext(expression)) {
        refMethod.setReturnValueUsed(true);
      }

      addTypeReference(uFrom, returnType, refMethod.getRefManager());
    }

    UCallExpression call = null;
    if (uExpression instanceof UCallExpression callExpression) {
      call = callExpression;
    }
    else if (uExpression instanceof UQualifiedReferenceExpression qualifiedReference) {
      call = ObjectUtils.tryCast(qualifiedReference.getSelector(), UCallExpression.class);
    }
    if (call != null) {
      refMethod.updateParameterValues(call, psiResolved);

      final PsiType usedType = call.getReceiverType();
      if (usedType != null) {
        UClass containingClass = UDeclarationKt.getContainingDeclaration(uMethod, UClass.class);
        if (containingClass != null) {
          final String fqName = containingClass.getQualifiedName();
          if (fqName != null) {
            final Project project = psiResolved.getProject();
            final PsiClassType methodOwnerType = JavaPsiFacade.getElementFactory(project)
              .createTypeByFQClassName(fqName, GlobalSearchScope.allScope(project));
            if (!usedType.equals(methodOwnerType)) {
              refMethod.setCalledOnSubClass(true);
            }
          }
        }
      }
    }
  }
private void updateRefMethod(PsiElement psiResolved,
                               RefMethodImpl refMethod,
                               @NotNull UExpression uExpression,
                               final UElement uFrom)