dambakk
08/24/2020, 1:58 PMsealed class OptionalProperty<out T> {
object NotPresent : OptionalProperty<Nothing>()
data class Present<T>(val value: T) : OptionalProperty<T>()
}
that is used as a type for other properties, e.g. data class Holder(val maybeThere: OptionalProperty<String>)
. When trying to reference the NotPresent
object or instantiating it (if we let it be a class and not an object) from swift we get an error saying Cannot convert return expression of type 'OptionalProperty<KotlinNothing>' to return type 'OptionalProperty<NSString>'
. Instantiating OptionalProperty.Present
works fine.
So my question is; Are sealed classes even supported/usable in native? If so, how can we use it? What are we doing wrong?