How to call outer class' super method from inner class in Kotlin?

Viewed 9003

What is the Kotlin equivalent of Java's OuterClass.super.method()?

Example (in Java):

class Outer {
    class Inner {
        void someMethod() {
            Outer.super.someOtherMethod();
        }
    }

    @Override
    public String someOtherMethod() {
        // This is not called...
    }
}
3 Answers

According to this section on inner classes, you can simply call outer method:

class Outer {

    inner class Inner {
        fun foo() { 
            bar() 
        }
    }

    private fun bar() {}
}
Related