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

Inline only function

Open clickjamper opened this issue 2 years ago • 7 comments

In our project we use @kotlin.internal.InlineOnly functions like sortedBy but kover can't cover this lines. How can we do it?

clickjamper avatar Aug 15 '23 11:08 clickjamper

We have the same problem. I think this is a bug.

Vladimir43543 avatar Aug 18 '23 10:08 Vladimir43543

Hi, could you clarify the coverage of which functions you would like to measure? Are these custom functions marked as InlineOnly?

shanshin avatar Sep 11 '23 13:09 shanshin

We have this problem in sortedBy function even it was testing. It reproduce on Kotlin v. 1.7.10

clickjamper avatar Sep 13 '23 06:09 clickjamper

@clickjamper Could you please share a screenshot of an HTML report, where we can see what lines are uncovered? Also, a call point of the method would be helpful

zuevmaxim avatar Sep 13 '23 13:09 zuevmaxim

I made a minimal reproducible example here with Kotlin 1.9.24 and kover 0.8.0. I hope this is the same problem the issue creator and other reporters experienced.

One thing to note in advance: if the Iterable to be sorted with sortedBy only contains <= 1 elements Kotlin will not call the selector function passed to sortedBy. sortedBy calls sortedWith and sortedWith contains this logic here

Whether or not the selector is called, the table above the code shows 0% method coverage specifically for the inline functions.

image

E3FxGaming avatar May 18 '24 22:05 E3FxGaming

Depends on the Compiler task https://youtrack.jetbrains.com/issue/KT-68006/Full-debug-information-for-call-of-InlineOnly

shanshin avatar May 29 '24 10:05 shanshin

I have the same problem using Iterable.maxOf() from _Collections.kt wich is also declared inline and marked @kotlin.internal.InlineOnly - Kover reports only some of the 6 branches are covered and I have no branches in my code

aburmeis avatar Aug 19 '24 10:08 aburmeis