kevin.cianfarini
05/13/2025, 1:33 PM-Werror on my project and it instructed me to delete an else branch that was previously required for a when statement with an expect enum class as the subject.
I flagged in in the #C0B8H786P channel here, and after discussing, I think there’s two issues:
1. This code shouldn’t compile at all since expect enums can have less entries than their actual counterparts.
2. The else branch shouldn’t have been flagged as unnecessary by the compiler.
Does this seem like it’s an actual bug? Here’s the PR where I surfaced this inconsistency. cc @Anna Kozlovadmitriy.novozhilov
05/13/2025, 1:49 PMMonth from kotlinx.datetime, it actualy resolves to the actual enum class Month from kotlinx-datetime-jvm.jar (or any other platform), so the compiler reports this else branch as redundant.
But when you run buildCommonMetadata task, then your common code is analyzed against expect enum class Month from kotlinx-datetime-common.klib, so the else branch is required here.
There is no proper workaround here except suppressing the warning (@Suppress("REDUNDANT_ELSE_IN_WHEN")).dmitriy.novozhilov
05/13/2025, 1:51 PMkevin.cianfarini
05/13/2025, 1:55 PMexpect enum Month doesn’t have any additional entries in any of the actual class Month instances?dmitriy.novozhilov
05/13/2025, 1:55 PMkevin.cianfarini
05/13/2025, 1:55 PMkevin.cianfarini
05/13/2025, 1:57 PM