-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Change scheme to implement creator applications #10784
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
4babc9f
to
852b456
Compare
Will that affect the bytecode in any way? (new |
More importantly: can this change the meaning of existing programs?
All the previous discussions of this feature were based on the fact that it couldn't change the meaning of existing programs. Changing this premise invalidates all those discussions, including at the SIP meetings, where I recall that this was an important concern. |
No. If an apply method exists (with any type, in either the class itself or in any parent), no creator proxy is generated.
No, since creator proxies methods have lower precedence than anything else (note that the previous condition still allows overloads: An apply could be defined in trait
Yes. And there could be other priority inversions as well. For instance here is one I observed in catsEffect2, class `InstancesTests. AsyncTests[T1, T2] In the same package a monomorphic class We should look into what we can do to avoid breakage like that. Here, we got a type error, but we mighty also resolve to a different method which could change behavior. One possibility would be to try both old and new resolution schemes and issue an error if they are different. We could do that under -source 3.0-migration. |
a62a470
to
4d167e4
Compare
Here are the breakages observed in the community build:
I believe we should address the shadowing problems. We could demand that when resolving a constructor proxy identifier the same identifier does not already exist as a regular identifier in some outer scope. That would have caught each of the shadowing issues. We should also see what we can do to avoid the problem in zio. Overall I am quite positive now. The new scheme is much safer than the previous one, and it looks compatible enough with Scala 2 to be workable. |
3f2775f
to
d697007
Compare
The code so far can already be reviewed. |
I verified that the shadowing check catches and diagnoses the observed errors in the community build. |
From my point of view, this is ready to merge. We can figure out the problem observed in zio later. If someone still has the time to review this until tomorrow, this would be great. Otherwise we'll merge as is and deal with any possible improvements later. |
Use synthetic apply methods instead of a fallback in Typer to implement creator applications
This was interesting. It looks like we wanted the creator proxy since there was an explicit import. But we resolved to the outer apply before. Now we see that there's a conflict since we get the shadowing error.
dc36735
to
6a93525
Compare
The shapeless error was interesting. It looks like we wanted the creator proxy since there was an explicit |
Overall I am now quite convinced that the new scheme is better than the previous one, and that the previous one had hidden problems that would have only got worse with widespread adoption. So I am glad we can get it changed in time for 3.0. |
test performance please |
performance test scheduled: 20 job(s) in queue, 1 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/10784/ to see the changes. Benchmarks is based on merging with master (d7ecc34) |
before, I could I guess it's because is this considered desirable/acceptable? |
I concur. This is the cause of the failure in ScAS. I have opened an issue: #10862 |
Yes, that's intended. You don't get an apply for a type alias. I think this is what we want. To compare, if I write type S = scala.collection.immutable.Seq I still can't do val S = scala.collection.immutable.Seq For the new kind of apply methods, it's the same. |
(I guess let's discuss further on #10862) |
Use synthetic apply methods instead of a fallback in Typer to implement
creator applications.
Todo: