Skip to content

When expression is not covered for an enum with single element in Kotlin #1748

@shanshin

Description

@shanshin

For the following src/Example.kt

enum class SingleEnum {
    First
}



fun testEnum(p: SingleEnum) = when (p) {
    SingleEnum.First -> 1
}

fun main() {
    testEnum(SingleEnum.First)
}

execution of

kotlin-2.0.21/bin/kotlinc src -d classes
java -javaagent:jacoco-0.8.13-SNAPSHOT/lib/jacocoagent.jar -cp classes:kotlin-2.0.21/lib/kotlin-stdlib.jar ExampleKt
java -jar jacoco-0.8.13-SNAPSHOT/lib/jacococli.jar report jacoco.exec --classfiles classes --sourcefiles src --html report

produces report
Screenshot 2024-10-15 at 17 46 16
Screenshot 2024-10-15 at 17 46 23

Expected behaviour

All lines of when expression should be fully covered as single enum element was passed

Environment

  • JaCoCo version: actual master branch built locally
  • Kotlin 2.0.21
  • Operating system: MacOS 15
  • Tool integration: CLI

Metadata

Metadata

Assignees

Type

No type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions