# Lateinit modifier is not allowed on custom setter

**URL:** <https://discuss.kotlinlang.org/t/lateinit-modifier-is-not-allowed-on-custom-setter/1999>\
**Category:** Language Design\
**Created:** [September 29, 2016, 8:10am UTC](https://discuss.kotlinlang.org/t/lateinit-modifier-is-not-allowed-on-custom-setter/1999 "2016-09-29T08:10:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dimezis](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/dimezis/32/1856_2.png) [@dimezis](https://discuss.kotlinlang.org/u/dimezis)\
**Post date:** [September 29, 2016, 8:10am UTC](https://discuss.kotlinlang.org/t/lateinit-modifier-is-not-allowed-on-custom-setter/1999/1 "2016-09-29T08:10:58Z")

</div>

Can someone please explain, what is the reason for such lateinit behavior:

`lateinit var bla: Any set(value) {}`

Which results in compilation error: “Lateinit modifier is not allowed on properties with a custom getter or setter”

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [October 10, 2016, 7:59am UTC](https://discuss.kotlinlang.org/t/lateinit-modifier-is-not-allowed-on-custom-setter/1999/2 "2016-10-10T07:59:17Z")

</div>

This limitation is there to simplify the rules: lateinit properties are treated specially, and specifying a custom accessor makes their semantics less clear. But I agree that custom setter could be allowed. Feel free to file an issue in our YouTrack

---

<div class="post-metadata">

**Author:** ![ilya.gorbunov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/ilya.gorbunov/32/1645_2.png) [@ilya.gorbunov](https://discuss.kotlinlang.org/u/ilya.gorbunov)\
**Post date:** [October 10, 2016, 6:28pm UTC](https://discuss.kotlinlang.org/t/lateinit-modifier-is-not-allowed-on-custom-setter/1999/3 "2016-10-10T18:28:56Z")

</div>

AFAIK custom setter is prohibited because `lateinit` properties expose their backing fields, unless they have a private setter.

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [October 12, 2016, 5:56am UTC](https://discuss.kotlinlang.org/t/lateinit-modifier-is-not-allowed-on-custom-setter/1999/4 "2016-10-12T05:56:47Z")

</div>

Good point. We could still have custom setters for private lateinit var’s though
