Skip to content

When expression is not covered for the logical type in Kotlin  #1747

@shanshin

Description

@shanshin

For the following src/Example.kt

fun testBool(p: Boolean) = when (p) {
    true -> 1
    false -> 2
}

fun main() {
    testBool(true)
    testBool(false)
}

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 35 46
Screenshot 2024-10-15 at 17 36 03

Expected behaviour

All lines of when expression should be fully covered as both boolean values 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