Hello all, has anyone else been running into `java...
# android
a
Hello all, has anyone else been running into
java.lang.ClassCastException: java.util.ArrayList cannot be cast to kotlin.Resul
? Should I report this as a bug? I’m able to use the Kotlin result library without issue for many result types, but weirdly not with lists. I’m simply trying to return a result from an API request as a list, but having trouble doing so. My method looks like this
Copy code
suspend inline fun <reified T> get(route: String,
                                       block: RequestBuilder.() -> Unit = {}): Result<T> {
        if (networkReachability.isNetworkAvailable) {
            return try {
                val options = RequestBuilder().apply(block)
                val response = client.get<T>("$baseUrl$route") {
                    headers {
                        sessionId.value?.also {
                            append("API-KEY", it)
                        }
                    }
                    if (options.requestPerms.isNotEmpty()) {
                        options.requestPerms.forEach {
                            // this sets the URL query parameters
                            this.parameter(it.first, it.second)
                        }
                    }
                }
                Result.success(response)
            } catch (e: Exception) {
                return handleError(e)
            }
        } else {
            return Result.failure(NetworkNotReachable)
        }
    }
my
T
type in this case is a List
e
similar things often are reported with Result, the compiler uses Result for its own purposes and gets confused when the user uses in certain positions too
👍 1
a
That's rough, but glad to know my case is not unique
e
yeah it's definitely a bug but it's not surprising to hit them :-/