However if you call a method and that method gets overridden in a subclass you can’t really figure out if an access is safe or not.
Class Foo
cannot be subclassed as it isn’t open, so I don’t think your explanation applies to this case.
Here’s a modified version of that class, in which the NPE still happens:
private class Foo {
private val c: String
init {
bar()
c = ""
}
private inline fun bar() = c.length
}