What is the correct usage of @CheckReturnValue in RxJava?

Viewed 329

I decided to use @CheckReturnValue annotation to make sure, that in my code I always subscribe to the flowable object. But I noticed that in some cases it doesn't work. This looks like a Lint problem, but maybe I do smth wrong or don't get smth.

  1. Method being called.
    @CheckReturnValue
    fun insertTask(task: Groupie): Completable = Completable.fromAction { dao.insertTask(task) }
        .subscribeOn(Schedulers.io())

Screenshot 2020-03-27 at 18 05 27

  1. Code that calls the method:
    fun test(g: Groupie, obj: Any) {
        db.insertTask(g) // 1.
        when (obj) {
            is WebSocketMessage.GroupieUpdate -> {
                subs.add(db.getTask(g.id).map { oldGroupie -> g.copy(text = oldGroupie.text) }
                    .subscribe(
                        { t -> db.insertTask(t) }, // 2.
                        ::onError
                    )
                )
                db.insertTask(g) // 3.
            }
        }
    }

Screenshot 2020-03-27 at 18 06 53

QUESTION: Why exactly 1st call is marked as wrong by Lint in Android Studio, but 2nd and 3rd are not?

RxJava v2.2.19

Android Studio v3.6.1

0 Answers
Related