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

Fix coverage serialization when encountering macro suspension #22303

Merged
merged 4 commits into from
Jan 10, 2025

Conversation

jchyb
Copy link
Contributor

@jchyb jchyb commented Jan 3, 2025

Fixes #22247

The fix is simple, as we mainly move the coverage object to a global ContextBase object, which persists it between runs. Initially I thought that appending the newly generated coverage indices would be enough, but if the macro suspends after the InstrumentCoverage phase runs, we end up with duplicate indices. For that reason, when generating indexes for a compilation unit, we also remove the previously generated ones for the same compilation unit.

To support having multiple scala files compiled in the coverage tests I had to slightly adjust the suite. While doing that, I noticed that some check files for run tests were ignored, as they were incorrectly named. I added an assertion that throws when .check do not exist and renamed the files appropriately (having to add some additional ones as well).

@jchyb jchyb changed the title Fix .coverage serialization when encountering macro suspension Fix coverage serialization when encountering macro suspension Jan 3, 2025
@jchyb jchyb marked this pull request as ready for review January 7, 2025 13:49
@jchyb jchyb requested a review from KacperFKorban January 7, 2025 13:49
Copy link
Member

@KacperFKorban KacperFKorban left a comment

Choose a reason for hiding this comment

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

Looks good overall. Added one question.

compiler/src/dotty/tools/dotc/core/Contexts.scala Outdated Show resolved Hide resolved
@KacperFKorban KacperFKorban assigned jchyb and unassigned KacperFKorban Jan 9, 2025
@jchyb jchyb requested a review from KacperFKorban January 10, 2025 12:20
@jchyb jchyb assigned KacperFKorban and unassigned jchyb Jan 10, 2025
@KacperFKorban KacperFKorban merged commit f06b95f into scala:main Jan 10, 2025
29 checks passed
@KacperFKorban KacperFKorban deleted the fix-i22247 branch January 10, 2025 12:39
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.

Macros lead to wrong coverage reports
2 participants