JS: Interface function not compiled?


#1

After upgrading to 1.1.4 I experienced that a interface function was seemingly not compiled to JS. The code compiled OK, but at runtime in the browser the function was not found. Might have to do with name clash with property with same name. See example below.

interface ActionComponent : IElement {

    val action: Action 

    fun getAction(): Action {
        return action
    }
}

class Button : Element, ActionComponent

class Element : IElement {
    
    fun someDescendantTraversing() {
        if( descendant is ActionComponent ) {
            //descendant.getAction() // function not found in runtime, had to access property instead
            descendant.action
        }
    }
}

Not a big deal for me as I could remove the function from the ActionComponent interface and use the property instead.


#2

basically limitation of current implementation due to no consensus on good solution.
also function not found at runtime is definitely compiler bug :slight_smile:

You can not override Java methods with Kotlin properties at the moment. It would be nice if we could support it, but we don’t know how to do it consistently for mixed hierarchies – Andrey Breslav Mar 26 '15 at 21:27