-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Change Implicit Resolution Rules #5887
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
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.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Commit Messages
We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).
Please stick to these guidelines for commit messages:
- Separate subject from body with a blank line
- When fixing an issue, start your commit message with
Fix #<ISSUE-NBR>:
- Limit the subject line to 72 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line ("Add" instead of "Added")
- Wrap the body at 80 characters
- Use the body to explain what and why vs. how
adapted from https://chris.beams.io/posts/git-commit
Have an awesome day! ☀️
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/5887/ to see the changes. Benchmarks is based on merging with master (8cce121) |
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/5887/ to see the changes. Benchmarks is based on merging with master (8cce121) |
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
36cd9b5
to
ac5bac0
Compare
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/5887/ to see the changes. Benchmarks is based on merging with master (8cce121) |
ac5bac0
to
6c32e0b
Compare
As discussed in #5881, there are more changes to consider. However, I believe the three changes in this PR are quite uncontroversial. So they can go in independently of the rest. I'll base further PR's on this one. |
So far, nesting was just one of several criteria for selecting a best implicit. What would happen if nesting was most significant? I.e. inner implicits would always win over outer ones? This has the potential to simplify the rules, gain effiviency, and solve the local consistency problem since we can disambiguate implicits using a local definition (see implicit-disambiguation.scala as a test case).
Since we always prefer inner implicits over outer ones, no need to also consider levels when disambiguating.
Since implicit selection is now inner to outer, shadowing checks are less important than before. Shadowing is necessary if we treat implicit search as a synthesis for untyped terms. I.e. come up with an untyped term and then check whether that term is typeable and refers to the original implicit. If there's a nested definition with the same name, that fails. This viewpoint is very easy to spec but a bit unnatural. In all other instances of meta programming we deal with typed terms. If we synthesize a typed term directly, then name resolution is already done and shadowing is immaterial. Besides, shadowing tests, if they fail, are almost always much more suprising than enlightening.
Don't consider implicits in package prefixes to be in the implicit scope of a type unless under -language:Scala2.
6c32e0b
to
4826b64
Compare
Update doc on implicit resolution changes to take the previous changes in scala#5887 into account.
Update doc on implicit resolution changes to take the previous changes in scala#5887 into account.
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.
This all looks good to me :-)
Update doc on implicit resolution changes to take the previous changes in scala#5887 into account.
Update doc on implicit resolution changes to take the previous changes in scala#5887 into account.
This applies the following changes to implicit resolution:
See #5881 for a discussion of these changes.