private static boolean canCoerceImpl(@NotNull PsiType targetType, @NotNull PsiClass fromClass, @NotNull PsiElement context,
                                       @NotNull BiConsumer<? super String, ? super Validator.ValidationHost.ErrorType> messageConsumer) {
    if (targetType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) ||
        targetType.equalsToText(CommonClassNames.JAVA_LANG_STRING) ||
        targetType.isAssignableFrom(PsiTypesUtil.getClassType(fromClass))) {
      return true;
    }
    final PsiClassType boxedTargetClass =
      targetType instanceof PsiPrimitiveType ? ((PsiPrimitiveType)targetType).getBoxedType(context) : null;
    if (boxedTargetClass != null && InheritanceUtil.isInheritor(boxedTargetClass, CommonClassNames.JAVA_LANG_NUMBER) ||
        InheritanceUtil.isInheritor(targetType, CommonClassNames.JAVA_LANG_NUMBER)) {
      if (Comparing.strEqual(fromClass.getQualifiedName(), CommonClassNames.JAVA_LANG_STRING) ||
          InheritanceUtil.isInheritor(fromClass, CommonClassNames.JAVA_LANG_NUMBER)) {
        return true;
      }
      return unrelatedTypesWarning(targetType, fromClass, messageConsumer);
    }
    final PsiMethod valueOfMethod = findValueOfMethod(targetType);
    final PsiType valueOfParameterType = valueOfMethod != null && valueOfMethod.getParameterList().getParametersCount() == 1 ?
                                         valueOfMethod.getParameterList().getParameters()[0].getType() : null;
    if (valueOfParameterType != null && valueOfParameterType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
      return true;
    }
    if (Comparing.strEqual(fromClass.getQualifiedName(), CommonClassNames.JAVA_LANG_STRING)) {
      if (isPrimitiveOrBoxed(targetType) ||
          valueOfParameterType != null && valueOfParameterType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
        return true;
      }
    }
    if (valueOfMethod != null) {
      return unrelatedTypesWarning(targetType, fromClass, messageConsumer);
    }
    return unableToCoerceError(targetType, fromClass, messageConsumer);
  }
private static boolean canCoerceImpl(@NotNull PsiType targetType, @NotNull PsiClass fromClass, @NotNull PsiElement context,
                                       @NotNull BiConsumer<? super String, ? super Validator.ValidationHost.ErrorType> messageConsumer)