private static @NonNls String coerceType(@NonNls String replaceByArg, PsiType from, PsiClassType to, PsiElement context) {
    if (PsiUtil.isLanguageLevel5OrHigher(context)) {
      if (from instanceof PsiPrimitiveType) {
        final PsiPrimitiveType unboxed = PsiPrimitiveType.getUnboxedType(to.getParameters()[0]);
        if (unboxed != null && !from.equals(unboxed)) {
          if (PsiTypes.longType().equals(unboxed)) {
            String result = longLiteralText(context, replaceByArg);
            if (result != null) return result;
          }
          return context instanceof PsiExpression expression &&
                 PsiPrecedenceUtil.getPrecedence(expression) > PsiPrecedenceUtil.TYPE_CAST_PRECEDENCE
                 ? "(" + unboxed.getCanonicalText() + ")(" + replaceByArg + ")"
                 : "(" + unboxed.getCanonicalText() + ")" + replaceByArg;
        }
      }
      return replaceByArg;
    }
    return from instanceof PsiPrimitiveType
           ? "new " + ((PsiPrimitiveType)from).getBoxedTypeName() + "(" + replaceByArg + ")"
           : replaceByArg;
  }
private static @NonNls String coerceType(@NonNls String replaceByArg, PsiType from, PsiClassType to, PsiElement context)