-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Report code coverage correctly for Kotlin methods with default arguments #774
Conversation
Actually there is one branch that is impossible to cover, because synthetic method is not used for invocation without default arguments, i.e. when bit mask is zero:
The only idea that comes to my mind - is to exclude all branches. In this case instruction coverage still can be used to determine if all cases were covered or not. |
8ad85e9
to
12a9757
Compare
12a9757
to
8ff17aa
Compare
bdb5be3
to
45e2dbe
Compare
@marchof could you please review? |
org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SyntheticFilter.java
Outdated
Show resolved
Hide resolved
org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilter.java
Outdated
Show resolved
Hide resolved
org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilter.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Godin I wonder whether KotlinGeneratedFilter.isKotlinClass()
should also be used in the existing Kotlin filters as a shortcut before iterating through all instructions of a method. WDYT?
...core.test/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilterTest.java
Outdated
Show resolved
Hide resolved
org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinGeneratedFilter.java
Show resolved
Hide resolved
org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinGeneratedFilter.java
Show resolved
Hide resolved
org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilter.java
Outdated
Show resolved
Hide resolved
...on.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultArgumentsTarget.kt
Outdated
Show resolved
Hide resolved
If we want to use it in all Kotlin filters (your other question), then maybe better to introduce
This also raises question - shouldn't we exclude Kotlin classes from non-Kotlin filters such as one for And hence I would prefer to not do any changes regarding these two remaining points in this PR. |
64f74c7
to
5c1e744
Compare
5c1e744
to
081c49e
Compare
@Godin Sure, usage and re-location of After the builds are green I'll merge this. Thanks for addressing my remarks! |
As far as I understood
$default
that executes code to create default arguments and pass them to non-synthetic method that contains code of a methodint
that specifies which default arguments are used (bit mask), therefore introduces two branches per default argumentSee https://github.com/JetBrains/kotlin/blob/v1.2.71/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt
Since
I propose to simply stop filtering out such methods. And later we might think about first two branches that are not associated with any line number.
Fixes #773
After this change for the same example as in #773 :