Report code coverage correctly for Kotlin methods with default arguments#774
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
...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
$defaultthat executes code to create default arguments and pass them to non-synthetic method that contains code of a methodintthat 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 :