-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #5144: Avoid Expr of method type #5154
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
Conversation
2a2a4fd
to
10b2965
Compare
Change the type of lifted method references to function types and allow method references in Holes.
10b2965
to
757bb1e
Compare
You could enforce this invariant by adding |
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.
Otherwise, LGTM
def eval1(ff: Expr[Int => Int]): Expr[Int] = '((~ff)(42)) | ||
|
||
def peval1(): Expr[Unit] = '{ | ||
def f(x: Int): Int = ~eval1('(f)) |
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.
Just a curiosity: we do eta-expansion for methods when the expected type is a function, so that a method is always applied. In this case of quotes, it seems it breaks this invariant.
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.
It is unrelated with the eta-expansion. This is about lifting a tree that represents a reference to a method that is outside the quote. It could not come from eta-expansion the code above could be def f(x: Int): Int = ~eval1('{ f(1); 2 })
where f
also needs lifting.
@smarter I dont see the relation with |
I see, so there's a typeapply where the argument is a methodtype? There could be an assertion to check for that too |
Yes. I will add an assertion. |
The conditions for the assertion in |
Change the type of lifted method references to function types and
allow method references in Holes.