Judicious shadowing of implicits from scope #11052
Draft
+243
−107
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 useowner.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.