Kotlin / kotlinx-atomicfu

The idiomatic way to use atomic operations in Kotlin
Other
913 stars 58 forks source link

DCE for user-defined extensions in atomicfu #63

Closed qwwdfsad closed 5 years ago

qwwdfsad commented 5 years ago

Consider the following user-defined extension: private inline fun AtomicBoolean.tryAcquire(): Boolean = compareAndSet(false, true)

Currently, the postprocessor retains the original method in the bytecode. While it is okay for the Kotlin compiler to do so, it is not the case for atomicfu that should remove every trace of itself after post-processing. Otherwise, resulting classfiles are polluted with symbols that are missing from the classpath (and it may trigger warnings like https://github.com/Kotlin/kotlinx.coroutines/issues/1155).

Also, note that not only extensions but their access-bridges should be removed.

qwwdfsad commented 5 years ago

I think it is time to introduce a validation step to the postprocessor to avoid issues like that in the future

elizarov commented 5 years ago

Hm... I thought I did fix it in https://github.com/Kotlin/kotlinx.atomicfu/commit/ec234e4d92148c44aace086a4d6dced81e1b33ba I'll investigate what's going on there.

elizarov commented 5 years ago

Fixed in version 0.12.7