vmironov
11/27/2015, 10:54 AMpublic class Main {
public fun foo() {
"one".apply {
bar()
}
}
private fun bar() = Unit
}
Main.foo compiles to:
public final foo()V
L0
LINENUMBER 17 L0
LDC "one"
ASTORE 1
NOP
L1
LINENUMBER 25 L1
ALOAD 1
CHECKCAST java/lang/String
ASTORE 2
L2
LINENUMBER 18 L2
ALOAD 0
INVOKESTATIC com/github/vmironov/Main.access$bar (Lcom/github/vmironov/Main;)V
L3
L4
GETSTATIC kotlin/Unit.INSTANCE : Lkotlin/Unit;
POP
ALOAD 1
L5
POP
L6
LINENUMBER 20 L6
RETURN
Main.bar() can be invoked directly, so I don't understand why Main.access$bar is generated and used instead. Is there any particular reason for this behaviour? The same applies to private fields too.