# Properties that act as aliases for other properties generate unnecessary getters and setters

**URL:** <https://discuss.kotlinlang.org/t/properties-that-act-as-aliases-for-other-properties-generate-unnecessary-getters-and-setters/7534>\
**Category:** Language Design\
**Created:** [April 23, 2018, 12:53pm UTC](https://discuss.kotlinlang.org/t/properties-that-act-as-aliases-for-other-properties-generate-unnecessary-getters-and-setters/7534 "2018-04-23T12:53:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joshua.Bradbury](https://avatars.discourse-cdn.com/v4/letter/j/c77e96/32.png) [@Joshua.Bradbury](https://discuss.kotlinlang.org/u/Joshua.Bradbury)\
**Post date:** [April 23, 2018, 12:53pm UTC](https://discuss.kotlinlang.org/t/properties-that-act-as-aliases-for-other-properties-generate-unnecessary-getters-and-setters/7534/1 "2018-04-23T12:53:14Z")

</div>

Say I have an example data class called Vec2f that looks like this:

```auto
data class Vec2f(var x: Float, var y: Float) {
    inline var r: Float get() = x; set(value) { x = value }
    inline var g: Float get() = y; set(value) { y = value }
}

```

In the decompiled bytecode for this class it creates methods called getR(), getS() and the relevant setters, which just call the getX() and Y respectively, as well for the setters. However whenever I use the properties r and g in normal code (e.g. vec.r) instead of showing as getR() it will call getX(), this is to do with how it inlines the property I assume, however this means there are redundant methods defined in the Vec2f that coverage tests will always mark as missed, as well as it adds unnecessary bytecode and methods. I couldn’t find much about this so if this is by design then fair enough but I thought it was interesting enough to inquire.

---

<div class="post-metadata">

**Author:** ![Wasabi375](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wasabi375/32/4741_2.png) [@Wasabi375](https://discuss.kotlinlang.org/u/Wasabi375)\
**Post date:** [April 24, 2018, 9:35pm UTC](https://discuss.kotlinlang.org/t/properties-that-act-as-aliases-for-other-properties-generate-unnecessary-getters-and-setters/7534/2 "2018-04-24T21:35:21Z")

</div>

I might be wrong, but I think this has to do with java interop. If you use r from within kotlin the compiler knows to inline it and everything will be fine, but I think there will still be a getter and a setter generated so you can call them from Java. I can’t find any official reference to this though.
