Skip to content

Fix #1895: Use proper validity period for extension methods #4613

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

Merged
merged 3 commits into from
Jun 4, 2018

Conversation

smarter
Copy link
Member

@smarter smarter commented Jun 1, 2018

When we create a symbol in a DenotationTransformer, we cannot safely
create it at phase thisPhase.next since this can lead to cycles. This
is why we created extension methods at phase thisPhase, but they're
not really valid at that point since they're only entered in their owner
once the transformer has been run. This lead to stale symbol errors
which were worked around in 51a458e but
the fix is incomplete and does not work with #4604 because that PR moves
the ExtensionMethods phase around.

This PR removes all the workarounds and uses a simpler solution:
create the symbols at phase thisPhase but set their validity
period to match the validity of the owner transformed denotation.

smarter added 3 commits June 1, 2018 18:57
Efficient arrays of value classes have been abandoned for now, see
scala#1558
This method was unused so far but will be used in the next commit. The
validity period of a transformed denotation starts at the phase after
the transformer has been run.
When we create a symbol in a DenotationTransformer, we cannot safely
create it at phase `thisPhase.next` since this can lead to cycles. This
is why we created extension methods at phase `thisPhase`, but they're
not really valid at that point since they're only entered in their owner
once the transformer has been run. This lead to stale symbol errors
which were worked around in 51a458e but
the fix is incomplete and does not work with scala#4604 because that PR moves
the ExtensionMethods phase around.

This commit removes all the workarounds and uses a simpler solution:
create the symbols at phase `thisPhase` but set their validity
period to match the validity of the owner transformed denotation.
@smarter
Copy link
Member Author

smarter commented Jun 1, 2018

test performance please

@dottybot
Copy link
Member

dottybot commented Jun 1, 2018

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

@smarter smarter requested a review from odersky June 1, 2018 17:23
@dottybot
Copy link
Member

dottybot commented Jun 1, 2018

Performance test finished successfully:

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

Benchmarks is based on merging with master (868d199)

def validFor(implicit ctx: Context): Period =
Period(ctx.runId, id, lastPhaseId)
Period(ctx.runId, id + 1, lastPhaseId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I was scared, because it looks really hard to see all the ramifications of this change. But then I found out that the method is in fact not used at all! So do we still want to keep it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's in fact used by the commit just after it as explained in the commit message: 7aa1ee2, see https://github.com/lampepfl/dotty/pull/4613/files#diff-093136d16584c89857e7cb09ec4f6518R75

@smarter smarter merged commit bd6f24c into scala:master Jun 4, 2018
@allanrenucci allanrenucci deleted the fix/denot-validity branch June 4, 2018 12:28
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.

3 participants