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

Coverage: mark case bodies as branches; don't ignore branches with synthetic spans #18437

Merged
merged 1 commit into from
Aug 22, 2023

Conversation

KacperFKorban
Copy link
Member

@KacperFKorban KacperFKorban commented Aug 21, 2023

Marking bodies of CaseDefs as branches seems like an uncontroversial
change, it was probably an oversight.

Not ignoring synthetic spans when creating coverage calls in branches seems like a good trade off. There might be some auto-generated else () interpreted as branches, but Scala introduces quite a lot of synthetic trees that wrap non-synthetic trees (e.g. implicit classes).
Also, it looks like Scala 2 includes those compiler-generated else branches in coverage. (Another possibility here would be to also check if the span is zero extent, but that approach would be different to the Scala 2 one)

partial fix for #16634

@KacperFKorban
Copy link
Member Author

sbt-scoverage-samples before these changes

image

After changes

3.x

image

@KacperFKorban KacperFKorban marked this pull request as ready for review August 22, 2023 09:56
…nthetic spans

Marking bodies of CaseDefs as branches seems like an uncontroversial
change, it was probably an oversight.

Not ignoring synthetic spans when creating coverage calls in branches
seems like a good trade off. There might be some auto-generated `else
()` interpreted as branches, but Scala introduces quite a lot of
synthetic trees that wrap non-synthetic trees (e.g. implicit classes).
Also, it looks like Scala 2 includes those compiler-generated `else`
branches in coverage. (Another possibility here would be to also check
if the span is zero extent, but that approach would be different to the
Scala 2 one)

partial fix for lampepfl#16634
@sjrd sjrd merged commit 4347d29 into scala:main Aug 22, 2023
17 checks passed
@sjrd sjrd deleted the coverage-case-branches branch August 22, 2023 15:58
Kordyjan added a commit that referenced this pull request Dec 13, 2023
…es with synthetic spans" to LTS (#19232)

Backports #18437 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
@Kordyjan Kordyjan added this to the 3.3.2 milestone Dec 14, 2023
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