Don't leak sharpened bounds between implicit candidates#6308
Merged
retronym merged 2 commits intoscala:2.13.xfrom Mar 5, 2018
Merged
Don't leak sharpened bounds between implicit candidates#6308retronym merged 2 commits intoscala:2.13.xfrom
retronym merged 2 commits intoscala:2.13.xfrom
Conversation
The bounds propagation introduced in scala#6140 caused a regression in scala/scala-java8-compat#97 because bounds sharpened while ranking implicit candidates leaked from candidates tested earlier to those tested later. This commit fixes that by saving and restoring the infos of the symbols of the undetermined type parameters around the call to type check the implicit candidate which tests for it's applicability. Initially it seemed like this ought to be a job for undoLog or Context#savingUndeteriminedTypeParams, but neither of those do the right thing here. UndoLog doesn't help because it affects the constraint on the corresponding TypeVar rather than the info of the symbol; and savingUndeterminedTypeParams doesn't help because the relevant call to typedImplicit shares the enclosing ImplicitSearch#undetParams rather than looking at the context.
This was referenced Feb 3, 2018
Merged
retronym
reviewed
Feb 5, 2018
|
|
||
| val savedInfos = undetParams.map(_.info) | ||
| val typedFirstPending = typedImplicit(firstPending, ptChecked = true, isLocalToCallsite) | ||
| foreach2(undetParams, savedInfos){ (up, si) => up.setInfo(si) } |
Member
There was a problem hiding this comment.
Let's put this in a try/finally.
Contributor
Author
|
/synch |
Contributor
Author
|
/rebuild |
This was referenced Feb 19, 2018
retronym
approved these changes
Mar 5, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The bounds propagation introduced in #6140 caused a regression in scala/scala-java8-compat#97 because bounds sharpened while ranking implicit candidates leaked from candidates tested earlier to those tested later.
This commit fixes that by saving and restoring the infos of the symbols of the undetermined type parameters around the call to type check the implicit candidate which tests for it's applicability.
Initially it seemed like this ought to be a job for
undoLogorContext#savingUndeteriminedTypeParams,but neither of those do the right thing here.UndoLogdoesn't help because it affects the constraint onthe corresponding
TypeVarrather than the info of the symbol; andsavingUndeterminedTypeParamsdoesn't help because the relevant call totypedImplicitshares the enclosingImplicitSearch#undetParamsrather than looking at the context.Fixes scala/bug#10708.