Derek Peirce
10/12/2023, 7:02 AMin
or out
generics. For example, in RxJava, we have Single<T>
, which in Kotlin would have been represented as Single<out T>
.
Ideally, there'd be some directive like import io.reactivex.rxjava3.core.Single as Single<out T>
, which could be conveniently distributed through an entire project, perhaps by each file in the project importing from some file containing directives like this.
Would something like this be reasonable to add, or would the complications or the risk of someone importing a class that doesn't actually conform to out
be too great?CLOVIS
10/12/2023, 7:59 AMYoussef Shoaib [MOD]
10/12/2023, 2:13 PMtypealias Single<T> = io.reactivex.rxjava3.core.Single<out T>
Derek Peirce
10/13/2023, 3:01 AMtypealias
seems to work, so it would be a matter of having a way to configure the IDE to automatically import Single
without
import io.reactivex.rxjava3.core.Single
but instead
typealias Single<T> = io.reactivex.rxjava3.core.Single<out T>
so that it's the standard for the codebase. Would that be a reasonable feature for IntelliJ/Android Studio? I could run a massive find-replace, but then the system would decay over time as engineers still count on auto-imports, and in particular would cause conflicts in Dagger if not every file is on the same page about what Single
should mean.CLOVIS
10/13/2023, 7:59 AM