Skip to content

nonStaticOuterClasses

Returns the enclosing classes that this element can access an outer instance of, from innermost to outermost.

Example:

Given targetFunction representing target in:

class Outer {
    class Boundary {
        inner class Inner {
            fun target() {}
        }
    }
}

targetFunction.nonStaticOuterClasses().mapNotNull { it.name }.toList() returns listOf("Inner", "Boundary"). The sequence stops at Boundary because it is not an inner class, so its instances do not retain an Outer instance.