Currently it is impossible to use to
juc.atomic.AtomicReferenceFieldUpdater et al. with Scala classes, as even
@volatile var members are wrapped with getters + setters (the actual field has the name mangled and is set to private).
This has led to the unfortunate pattern of creating dummy Java base-classes for high-performance concurrent code, even within the Scala standard library (cf. for example
I propose a minimally intrusive change to support
inline var as syntax for telling the compiler to leave a variable unwrapped + unmangled. A demo implementation is available here: https://github.com/lampepfl/dotty/compare/master...elfprince13:support-java-util-concurrent-atomic-updaters?expand=1
It would also be possible to use a new annotation instead of
inline, but this would require modifying the standard library as well as the compiler, and I believe that “do not generate a wrapper method for this variable” is fairly close to the spirit of