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

Conversation

WojciechMazur
Copy link
Contributor

Backports #19195 to the LTS branch.

PR submitted by the release tooling.
[skip ci]

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]
Base automatically changed from lts-19190 to lts-3.3 June 26, 2024 09:22
@WojciechMazur
Copy link
Contributor Author

No regressions detected in the community build up to lts-19356.

Reference

@WojciechMazur WojciechMazur merged commit 3c46a50 into lts-3.3 Jun 26, 2024
19 checks passed
@WojciechMazur WojciechMazur deleted the lts-19195 branch June 26, 2024 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants