Martin Brehovsky
07/08/2021, 10:16 PMclass Foo<T: Any?> {
abstract fun returnValue(): T
abstract fun returnValueAsNonNullable(): T!! // this doesn't work
}
The problem is I need to define the T type as either nullable or non-nullable, but I'm trying to bridge semantics of reactive streams, which are always non-nullable and represent null by empty stream state, and futures which are possibly nullable. However I need to differentiate between a nullable and non-nullable future, therefore decide whether to allow the reactive stream to return empty value (as null) or fail.Matthias Geisler
07/08/2021, 10:19 PMclass Foo<T: Any> {
abstract fun returnValue(): T?
abstract fun returnValueAsNonNullable(): T
}Martin Brehovsky
07/08/2021, 10:21 PMreturnValue() always nullable, which is not what I want. I want the this function to be either nullable or non-nullable based on the developer desire. However need to return always non-nullable from returnValueAsNonNullableSourabh Rawat
07/08/2021, 11:01 PMT: Any? is same as TMartin Brehovsky
07/08/2021, 11:14 PMMartin Brehovsky
07/08/2021, 11:15 PMT as non-nullable version of itselfudalov
T!! will be possible since Kotlin 1.6Martin Brehovsky
07/08/2021, 11:30 PMFleshgrinder
07/09/2021, 6:29 AMFoo<A : Any, B : A?>