-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Eta-expansion competes with match type, contextual application #17210
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
Comments
Works with
I was hoping the rules about turning things into context functions would pop back in my head, but I'll get a coffee and re-read the docs. |
The thing that troubles me most is |
I wonder if it sees:
because it's eta-expanded due to expected type, not applied as one might expect.
I guess I would also expect the implicit application before eta expansion. |
The thing is, if one gets rid of the tuples and the mapper, it compiles just nicely: object BugReport:
trait Executor
trait Updatable[+A]
def run(task: Executor ?=> Unit): Unit = {}
def function(a: Int): Unit = {}
def normalSequence(f: Updatable[Int] => Unit): Unit = {}
def liftInThreads[A](f: A => Unit)(using e: Executor): Updatable[A] => Unit = ???
run {
normalSequence(liftInThreads(function))
} so this is I don't know what, a conflict of stages maybe, but not me misunderstanding the rules. |
Earlier, a timestamp made me think this was still 2024.
makes it work, so as noted in the previous comment, it's not just a competition between eta-expansion and implicit application, but match types. It's the expected type that makes the difference, so this fails:
The expansion looks "suspicious" just because the expected type determines the parameter type (but it keeps the name
so that is normal. The workaround noted above is
Another workaround is to make it
Maybe that is standard advice, if you want your match type to work under these constraints, make it inferred in typer using For completeness,
|
Notably, the pos test doesn't pass pickling test.
to wit
I don't know if that is a testing artifact. (Edit: there is an exclusion list for tests which don't pass pickling, including because match types.) (The explanation, that transparent inline is needed so that the match type is available for adaptation to the expected type, makes sense to me, but I don't know the details. Usually one hopes that the "order of operations" will fall out naturally and just work.) |
Compiler version
3.2.2
Minimized code
Output
Expectation
Two "run" sections are essentially the same, but the second compiles as expected, and the first fails.
The error message suggests that it swaps the argument of the returned function and the context bound.
The text was updated successfully, but these errors were encountered: