Hello everyone, when calling ReceiveChannel<T&g...
# coroutines
z
Hello everyone, when calling ReceiveChannel<T>::receiveCatching i get an object of type ChannelResult<ChannelResult<T>> back. But when i call ReceiveChannel<T>::receive i get an object of type T. Is this a bug or did i miss something in the API? Thanks in advance!
d
receive
will throw an exception if the channel is closed.
receiveCatching
doesn't throw, it returns you a failed
ChannelResult
instead.
z
Yes, but as far as i understood the documentation of receiveCatching it should return a ChannelResult<T>, not a ChannelResult<ChannelResult<T>>
d
Oops, I completely skipped that part of your question... Yes it should not do that as far as I can tell
e
Can you post the body of the particular function (plus context)? I used those apis and cannot see the same issue
j
If you make heavy use of smart casting and generics, you may have accidentally specified a generic type to be
ChannelResult<T>
instead of
T
. Create a temporary variable
val tempVariable = {yourChannelVariable}
and set it to the channel in question, then have the IDE add the explicit type. It’s likely that your channel’s type is
ChannelResult<T>
and not
T
z
After testing around i decided to make a bugreport. This behaviour just occurs with JVM, but on with JS.