Sonar returns a false positive for “Two branches in a conditional structure should not have exactly the same implementation” when scanning code samples similar to the following:
sealed interface Base
data class A(val value: String) : Base
data class B(val value: String) : Base
fun unwrap(obj: Base): String {
return when (obj) {
is A -> obj.value
is B -> obj.value
}
}
fun main() {
println(unwrap(A("foo")))
}
It reports the implementation for the object being A or B as the same, but does not identify that they are semantically different