li'lfluf
08/29/2026, 11:22 AMvisitFunction with IrFunction bar and I want to access the property foo through IrProperty. For this concrete example, I can look through the parents and use thisReceiver. However, in a real scenario bar can be nested arbitrarily deep in various declarations. It could be in a non-inner class and have no access to foo. Is there a simple way to access it and tell if it is accessible?
class Foo {
val foo = "foo"
inner class Bar {
fun bar() {
foo // I want to access this
}
}
}
(What I'm trying to do is to see if I can write a simple compiler plugin, a logging thing that automatically provides the tag. So for this example a log entry could read, "bar was called in Foo[foo].Bar". Kotlin 2.4)Youssef Shoaib [MOD]
08/29/2026, 11:50 AMIrElementTransformerVoidWithContext and changing its scope tracking mechanism to keep track of properties for containing declarations.
I think you can use that to keep track manually of what dispatch receivers you have access to (i.e. by seeing what classes you're nested under, but stopping at the first non-inner outer class).li'lfluf
08/29/2026, 12:20 PMif (!parent.isInner) canReachReceiver = false
parent = parent.parent
While this works (and is sufficient for my use case—the plugin is only meant to be using in-house for now), it looks like a roundabout solution. Also, you can have non-inner classes that could access foo, for example you can have a class definition inside a method of Foo . Or maybe something else? It feels like there should be a better way.Youssef Shoaib [MOD]
08/29/2026, 12:22 PMIvan Kylchik
08/31/2026, 7:55 AMli'lfluf
09/05/2026, 1:51 PMouterScopesAreInvisible = owner _is_ IrClass && !owner.isInner && owner.visibility != DescriptorVisibilities._LOCAL,_ suggesting that the logic is sound. I see how I could use the scopes too.