Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Judicious shadowing of implicits from scope #11052

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

Draft
wants to merge 1 commit into
base: 2.13.x
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented May 6, 2025

Fixes scala/bug#12351
Fixes scala/bug#9208

Retire both the old and new "implicit shadowing" mechanisms in favor of using ctx.lookupSymbol.

Tweak when ctx.implicitss collects implicits from a class by waiting to use owner.thisType.implicitMembers.

A notable improvement in correctness is that overloaded implicits are handled correctly (see neg/t729.scala). The spec for lexically scoped implicits is that the value must be "accessible without a prefix". (Probably a member was seen once in a nested context and then again as an overload in the class type, which was taken as shadowed.)

The shadowing test in isQualifyingImplicit is removed; further clean-up of removed code is still needed after more testing.

There are two test tweaks to address which are due to existing cyclic error handling: in one case (t712), where one implicit member causes a cycle, the other implicit member is not collected; in the other case (virtpatmat_typetag), an explicit type is spuriously required for a class tag, also due to an existing cyclic error.

Also 2509 switched order when reporting ambiguous, which is supposed to have "winner" first. Maybe benign or progress.

@scala-jenkins scala-jenkins added this to the 2.13.17 milestone May 6, 2025
@lrytz
Copy link
Member

lrytz commented May 6, 2025

sounds good! i'll need to find some time to look into it. want to run a community build on it early?

@som-snytt
Copy link
Contributor Author

@lrytz thanks, before late bedtime I almost gave you a heads up to ask if you'd like me to continue the PR.

Before spending electrons on CB, I'll try some projects locally. I expect to discover more behaviors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type inference affects on implicit parameters inside traits? Implicit lookup interacts with import order
3 participants