Hi there, can anyone help me resolve this Intellij...
# codereview
c
Hi there, can anyone help me resolve this Intellij warning?
Type mismatch: inferred type is (Mutable)List<Task!>? but MutableList<Task> was expected
I’m writing a Kotlin class implementing this interface method:
Copy code
List<Task> getTasksReport(@NonNull String filter);
The Kotlin implementation is:
Copy code
override fun getTasksReport(filter: String): MutableList<Task> {
        val response = todoistRestClient.getTasks(TODAY_FILTER)
        val tasks = response.body
        println(tasks)
        return tasks
    }
Would changing the Kotlin by adding the cast to the return to the following be the best implementation?:
Copy code
override fun getTasksReport(filter: String): MutableList<Task> {
        val response = todoistRestClient.getTasks(TODAY_FILTER)
        val tasks = response.body
        println(tasks)
        return tasks as MutableList<Task>
    }
m
the warning is caused by the compiler not being able to determine the nullability of Java types, so I guess casting is the only option