How does one go about creating a common version of optional and its actual implementation ?
I have tried this :
expect class Optional<T> {
open fun get() : T
open fun isPresent(): Boolean
companion object {
inline fun <reified T> empty() : Optional<T>
}
}
actual typealias Optional<V> = java.util.Optional<V>
but I get the following error:
Actual class ‘Optional’ has no corresponding members for expected class members:
public expect companion object
java.util.Optional does not have a companion object, so the best you can do for now is to define top-level expect fun <T> emptyOptional() and provide an actual implementation for it.