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

Backport "Improve asExprOf cast error formatting" to LTS #20787

Merged
merged 1 commit into from
Jun 26, 2024

Commits on Jun 25, 2024

  1. Improve asExprOf cast error formatting (#19195)

    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)
        ...
    ```
    
    Example from #19191
    
    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:...)
        ...
    ```
    [Cherry-picked 7480582]
    nicolasstucki authored and WojciechMazur committed Jun 25, 2024
    Configuration menu
    Copy the full SHA
    09061ce View commit details
    Browse the repository at this point in the history