-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
added to type mismatch reporting output of tree, which can't be typed #12717
Conversation
Looks plausible, but needs test coverage, yes? (In part because a test or two would help illustrate the purpose of the PR. Perhaps that's why it hasn't attracted reviewer attention so far.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, the intent seems reasonable to me, to help understand what went wrong in the expanded macro code. But we'd want to see some examples as tests to review and maintain this enhancement.
Just added tests. will rebase and squash now. package t12717
import scala.quoted._
object A:
def foo(x:Int): Int = ???
def bar(x:String): String = ???
object X:
inline def doSomething[T](inline x:T):Any = ${
doSomethingImpl('x)
}
def doSomethingImpl[T:Type](x:Expr[T])(using Quotes):Expr[Any] =
import quotes.reflect._
val aTerm = '{A}.asTerm
val xBar = Apply(Select.unique(aTerm,"bar"),List(x.asTerm))
Apply(Select.unique(aTerm,"foo"), List(xBar)).asExpr And usage: package t12717
object Test:
val x = X.doSomething("XXX") // error
The output is:
Without
it's hard to understand, why the type checking of macro result has failed. |
btw, also I'm not sure that I added the test in the right place: looks like a neg-custom-args check only the existence of error, not an exact output of the compiler. Maybe we need a new category for such test types (?) |
…in macros pos can point to complete other thing. added tests for hidden-compiler Co-authored-by: Dale Wijnand <dale.wijnand@gmail.com>
0fcbc9f
to
0913a90
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me. What I see missing is that Int
is expected because that tree is being passed to A.foo
, which is still only understandable from reading the macro. So it almost seems like a half improvement, but that's still an improvement over the status quo.
I wouldn't mind another maintainer weighing in with or against me, before merging.
added to type mismatch reporting output of tree, which can't be typed in -explain mode.
Because in macros, tree in sourcecode in position and a processed tree can be very different.