Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve asExprOf cast error formatting #19195

Merged

Commits on Dec 5, 2023

  1. Improve asExprOf cast error formatting

    The intention of this change is to make it simpler to read the error
    message.
    
    List the expected type and actual type before the expression. This
    is usually the most important information and simpler to parse as the
    expression can get quite long. For the expected type, the actual type
    and the expression, we print the value in the same line if its String
    representation has only one line. Otherwise we print it in the next line
    with an indentation and extra new line at the end.
    
    Before:
    ```
    java.lang.Exception: Expr cast exception: ((a: scala.Int) => ({
      val v: scala.Int = a
      Binding.apply[scala.Unit](())
    }: Binding[scala.Unit]))
    of type: scala.Function1[scala.Int, scala.Unit]
    did not conform to type: scala.Function1[scala.Int, Binding[scala.Unit]]
    
        at scala.quoted.runtime.impl.QuotesImpl.asExprOf(QuotesImpl.scala:76)
        ...
    ```
    
    After:
    ```
    scala.quoted.runtime.impl.ExprCastException:
      Expected type: scala.Function1[scala.Int, scala.Unit]
      Actual type: scala.Function1[scala.Int, Binding[scala.Unit]]
      Expression:
        ((a: scala.Int) => ({
          val v: scala.Int = a
          Binding.apply[scala.Unit](())
        }: Binding[scala.Unit]))
    
        at scala.quoted.runtime.impl.QuotesImpl.asExprOf(QuotesImpl.scala:...)
        ...
    ```
    nicolasstucki committed Dec 5, 2023
    Configuration menu
    Copy the full SHA
    2fc7aae View commit details
    Browse the repository at this point in the history