Skip to content
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

Change Implicit Resolution Rules #5887

Merged
merged 6 commits into from Feb 18, 2019

Conversation

Projects
None yet
3 participants
@odersky
Copy link
Contributor

odersky commented Feb 9, 2019

This applies the following changes to implicit resolution:

  1. nested implicits always take precedence over outer ones
  2. no more shadowing checks
  3. package prefixes are not considered.

See #5881 for a discussion of these changes.

@odersky odersky added the stat:wip label Feb 9, 2019

@dotty-bot
Copy link

dotty-bot left a comment

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:

  1. Separate subject from body with a blank line
  2. When fixing an issue, start your commit message with Fix #<ISSUE-NBR>:
  3. Limit the subject line to 72 characters
  4. Capitalize the subject line
  5. Do not end the subject line with a period
  6. Use the imperative mood in the subject line ("Add" instead of "Added")
  7. Wrap the body at 80 characters
  8. Use the body to explain what and why vs. how

adapted from https://chris.beams.io/posts/git-commit

Have an awesome day! ☀️

@odersky

This comment has been minimized.

Copy link
Contributor Author

odersky commented Feb 10, 2019

test performance please

@dotty-bot

This comment has been minimized.

Copy link

dotty-bot commented Feb 10, 2019

performance test scheduled: 1 job(s) in queue, 0 running.

@dotty-bot

This comment has been minimized.

Copy link

dotty-bot commented Feb 10, 2019

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/5887/ to see the changes.

Benchmarks is based on merging with master (8cce121)

@odersky

This comment has been minimized.

Copy link
Contributor Author

odersky commented Feb 10, 2019

test performance please

@dotty-bot

This comment has been minimized.

Copy link

dotty-bot commented Feb 10, 2019

performance test scheduled: 1 job(s) in queue, 0 running.

@dotty-bot

This comment has been minimized.

Copy link

dotty-bot commented Feb 10, 2019

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/5887/ to see the changes.

Benchmarks is based on merging with master (8cce121)

@odersky

This comment has been minimized.

Copy link
Contributor Author

odersky commented Feb 10, 2019

test performance please

@dotty-bot

This comment has been minimized.

Copy link

dotty-bot commented Feb 10, 2019

performance test scheduled: 1 job(s) in queue, 0 running.

@odersky odersky force-pushed the dotty-staging:implicit-nested branch from 36cd9b5 to ac5bac0 Feb 10, 2019

@dotty-bot

This comment has been minimized.

Copy link

dotty-bot commented Feb 10, 2019

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/5887/ to see the changes.

Benchmarks is based on merging with master (8cce121)

@odersky odersky force-pushed the dotty-staging:implicit-nested branch from ac5bac0 to 6c32e0b Feb 11, 2019

This was referenced Feb 11, 2019

@odersky odersky changed the title Trial: Make implicit resolution block scoped Change Implicit Resolution Rules Feb 14, 2019

@odersky

This comment has been minimized.

Copy link
Contributor Author

odersky commented Feb 14, 2019

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.

@odersky odersky requested a review from milessabin Feb 14, 2019

@odersky odersky added stat:needs review and removed stat:wip labels Feb 14, 2019

odersky added some commits Feb 9, 2019

Trial: Make implicit resolution block scoped
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).
Drop logic which is now redundant
Since we always prefer inner implicits over outer ones, no need
to also consider levels when disambiguating.
Drop implicit shadowing checks
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
Don't consider implicits in package prefixes to be in the implicit
scope of a type unless under -language:Scala2.

@odersky odersky force-pushed the dotty-staging:implicit-nested branch from 6c32e0b to 4826b64 Feb 14, 2019

odersky added a commit to dotty-staging/dotty that referenced this pull request Feb 14, 2019

Update doc on implicit resolution changes
Update doc on implicit resolution changes to take the previous changes
in lampepfl#5887 into account.

odersky added a commit to dotty-staging/dotty that referenced this pull request Feb 14, 2019

Update doc on implicit resolution changes
Update doc on implicit resolution changes to take the previous changes
in lampepfl#5887 into account.
@milessabin
Copy link
Contributor

milessabin left a comment

This all looks good to me :-)

odersky added a commit to dotty-staging/dotty that referenced this pull request Feb 18, 2019

Update doc on implicit resolution changes
Update doc on implicit resolution changes to take the previous changes
in lampepfl#5887 into account.

@odersky odersky merged commit 4126f63 into lampepfl:master Feb 18, 2019

2 checks passed

CLA User signed CLA
Details
continuous-integration/drone/pr the build was successful
Details

@wafflebot wafflebot bot removed the stat:needs review label Feb 18, 2019

odersky added a commit to dotty-staging/dotty that referenced this pull request Feb 18, 2019

Update doc on implicit resolution changes
Update doc on implicit resolution changes to take the previous changes
in lampepfl#5887 into account.

@allanrenucci allanrenucci deleted the dotty-staging:implicit-nested branch Feb 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.