When you compile following Kotlin code:
<code>inline fun hello(s: Int) {
println("Hi")
}
</code>
<code>inline fun hello(s: Int) {
println("Hi")
}
</code>
inline fun hello(s: Int) {
println("Hi")
}
You get this bytecode:
<code>public final static hello(I)V
L0
ICONST_0
ISTORE 1
L1
LINENUMBER 6 L1
LDC "Hi"
GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
SWAP
INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/Object;)V
L2
LINENUMBER 7 L2
RETURN
L3
LOCALVARIABLE $i$f$hello I L1 L3 1
LOCALVARIABLE s I L0 L3 0
MAXSTACK = 2
MAXLOCALS = 2
</code>
<code>public final static hello(I)V
L0
ICONST_0
ISTORE 1
L1
LINENUMBER 6 L1
LDC "Hi"
GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
SWAP
INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/Object;)V
L2
LINENUMBER 7 L2
RETURN
L3
LOCALVARIABLE $i$f$hello I L1 L3 1
LOCALVARIABLE s I L0 L3 0
MAXSTACK = 2
MAXLOCALS = 2
</code>
public final static hello(I)V
L0
ICONST_0
ISTORE 1
L1
LINENUMBER 6 L1
LDC "Hi"
GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
SWAP
INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/Object;)V
L2
LINENUMBER 7 L2
RETURN
L3
LOCALVARIABLE $i$f$hello I L1 L3 1
LOCALVARIABLE s I L0 L3 0
MAXSTACK = 2
MAXLOCALS = 2
As you can see LOCALVARIABLE $i$f$hello I L1 L3 1
Kotlin creates a variable $i$f$hello for some reason and inserts it at the beginning L0 of the function with a value of 0 (boolean false probably). When you remove inline modifier the variable also disappears. The variable is never used. Why does it do it?