masteramyx
01/13/2024, 10:09 PMmasteramyx
01/13/2024, 10:09 PMinterface TestType
interface NonTestType
//sealed class NonTestType() {
// data class NonTestTypeImpl(val test: Int = 1): NonTestType()
//}
class TestType1() : TestType
class TestType2() : TestType
class TestType3() : TestType
class NonTestTypeImpl(): NonTestType
fun main() {
println("Hello, world!!!")
val testTypeFlow = MutableSharedFlow<TestType>(replay = 1)
val nonTestTypeFlow: Flow<NonTestType> = testTypeFlow.map {
when (it) {
is TestType1 -> {
println("Hello, TestType1!!!")
NonTestTypeImpl()
}
is TestType2 -> {
println("Hello, TestType2!!!")
NonTestTypeImpl()
}
is TestType3 -> {
println("Hello, TestType3!!!")
NonTestTypeImpl()
}
is NonTestType -> {
println("Hello, NonTestType!!!")
it
}
else -> {
NonTestTypeImpl()
}
}
}
}
masteramyx
01/13/2024, 10:11 PMTypeTest
and one of the when conditions is checking if the value is of type NonTypeTest
which is could not be. These are 2 interfaces which have no common parent entity.
I would expect an incompatible error heredmitriy.novozhilov
01/13/2024, 10:30 PM