# KMutableProperty0\<\*\> from an interface variable

**URL:** <https://discuss.kotlinlang.org/t/kmutableproperty0-from-an-interface-variable/13884>\
**Category:** Support\
**Created:** [August 15, 2019, 11:05am UTC](https://discuss.kotlinlang.org/t/kmutableproperty0-from-an-interface-variable/13884 "2019-08-15T11:05:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrew.kuryan](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@andrew.kuryan](https://discuss.kotlinlang.org/u/andrew.kuryan)\
**Post date:** [August 15, 2019, 11:05am UTC](https://discuss.kotlinlang.org/t/kmutableproperty0-from-an-interface-variable/13884/1 "2019-08-15T11:05:19Z")

</div>

Good day. I ran into the following problem. I have an extension function for type KMutableProperty0\<T\>, that trying to get delegate of this property by calling a method getDelegate()

```auto
@Suppress("UNCHECKED_CAST")
fun <T> KMutableProperty0<T>.getObservableVarDelegate(): ObservableVar<T> {
    isAccessible = true
    val delegate = getDelegate()
    isAccessible = false
    if (delegate == null || delegate !is ObservableVar<*>) {
        throw UnsupportedDelegateException("Property ${this.name} is not an ObservableVar")
    } else {
        return delegate as ObservableVar<T>
    }
}

```

In other place i run the following code:

```auto
class EntityImpl {
     val amount by ObservableVar(0)
}
val entity = EntityImpl()
entity::amount.getObservableVarDelegate()

```

This code works fine. But if i get a property from an interface variable pointing to the same object, method getDelegate() returns null.

```auto
interface Entity {
     val amount: Int
}
class EntityImpl: Entity {
     override val amount by ObservableVar(0)
}
val entity: Entity = EntityImpl()

// throws an Exception because the method getDelegate() returns null
entity::amount.getObservableVarDelegate() 

```

Do you know any available way to solve this problem?
