kotlinx-kover icon indicating copy to clipboard operation
kotlinx-kover copied to clipboard

Why some data class constructors show an missed branches?

Open klys-equinix opened this issue 2 years ago • 9 comments

Screenshot 2023-06-30 at 09 24 47

klys-equinix avatar Jun 30 '23 07:06 klys-equinix

Hi, to understand the causes of the problem, we need additional information.

May you provide a compiled class-file for DrawCapOptionWithPrice class? And give an example of the original source code of this class. Which version of the compiler was used?

shanshin avatar Jun 30 '23 11:06 shanshin

Source code:

data class DrawCapOptionWithPrice(
    val rating: BandRating,
    val cost: Cost,
    val top: Boolean = false,
)

Class attached DrawCapOptionWithPrice.class.zip

Compiler: Azul Zulu SDK 17

Kotlin: 1.7.22

klys-equinix avatar Jun 30 '23 11:06 klys-equinix

Thanks! Also XML report would be helpful

shanshin avatar Jun 30 '23 14:06 shanshin

<class name="com/example/scx/common/DrawCapOptionWithPrice" sourcefilename="CommonValueObjects.kt">
<method name="&lt;init&gt;" desc="(Lcom/example/scx/common/BandRating;Lcom/example/scx/common/Cost;Z)V">
<counter type="INSTRUCTION" missed="0" covered="28"/>
<counter type="BRANCH" missed="1" covered="1"/>
<counter type="LINE" missed="0" covered="4"/>
</method>

klys-equinix avatar Jul 03 '23 05:07 klys-equinix

Also, this is not an exception. It happens to many data classes. It seems to affect those data classes that have extension methods.

klys-equinix avatar Jul 03 '23 05:07 klys-equinix

@losiu97, is this for Kover version 0.7.2?

shanshin avatar Jul 03 '23 12:07 shanshin

yes

klys-equinix avatar Jul 03 '23 13:07 klys-equinix

@klys-equinix Unfortunately, I cannot reproduce your issue on my examples. Could you please share some more code? If your project is open-source, please share a link. Alternatively, it would be nice to have a small reproducer project. If it is impossible to reproduce with a small project, could you please share an example of an extension function for the class? (with bytecode preferably).

zuevmaxim avatar Jul 10 '23 12:07 zuevmaxim

I tried reproducing this in a reproducer project, but i have not been able to see the same problems. I am at a loss why it happens in our main project. Unfortunetely, it would be hard to share the bytecode from that

klys-equinix avatar Jul 13 '23 05:07 klys-equinix