android / android-ktx

A set of Kotlin extensions for Android app development.
https://android.github.io/android-ktx/core-ktx/
7.47k stars 563 forks source link

inline extension properties can't be used in SAM lambda functions due to compiler bug #583

Closed technoir42 closed 6 years ago

technoir42 commented 6 years ago

Kotlin compiler (1.2.50) crashes if we use extension property like View.isVisible marked inline inside a SAM-converted lambda function. Sample code:

Observable.just(true)
    .subscribe { b ->
        view.isVisible = b
    }

Can we remove the inline modifier for now until this bug is fixed in the compiler?

JakeWharton commented 6 years ago

We can lobby them to fix it in 1.2.60 which will be out before our 1.0.0. I don't really want to change the API, especially in this way, to work around bugs in the Kotlin compiler. We have tens of inline extension properties and there's surely thousands or more across the entire Kotlin library ecosystem and it's infeasible to change them all.