- Type: Design proposal
- Author: Andrey Breslav
- Status: Accepted
- Prototype: Implemented
Discussion of this proposal is held in this issue.
Support inline
modifier for properties that don't have a backing field and accessors of such properties.
- Enable
@InlineOnly
properties whose signatures can be changed without affecting the binary compatiblity of a library - Make reified type parameters available for property accessors
We propose to allow the inline
modifier on properties that do not have a backing field.
It may be used on the sole accessor of a val
:
val foo: Foo
inline get() = Foo()
Or one or both accessors of a var
:
var bar: Bar
inline get() = ...
inline set(v) { ... }
At the call site the accessors are inlined as normal functions.
The inline
modifier may also be used on the property itself:
inline var bar: Bar
get() = ...
set(v) { ... }
In such a case, all accessors are marked inline
automatically.
Applying inline
to a property that has a backing field, or its accessor, results in a compile-time error.