Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]
- Loading branch information