inline函数展开lambda,但是不展开函数引用.
kotlin:
funmain(args:Array){? ? println("Hello World!")varm =1;// Try adding program arguments via Run/Debug configuration.// Learn more about running applications: https://www.jetbrains.com/help/idea/running-applications.html.? test(args, ::test3)// test3()}privatefuntest3(i:Int){? ? println("test3 Program arguments:${1in3downTo1}")}privateinlinefuntest(args:Array, test3P: (Int)->Unit){valj =1println("Program arguments:${j}${args.joinToString()}")? ? test3P(j)}
java:
import kotlin.Metadata;
import kotlin.collections.ArraysKt;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlin.ranges.RangesKt;
import org.jetbrains.annotations.NotNull;
@Metadata(
? mv = {1, 9, 0},
? k = 2,
? d1 = {"\u0000 \n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0010\b\n\u0002\b\u0004\u001a\u0019\u0010\u0000\u001a\u00020\u00012\f\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003¢\u0006\u0002\u0010\u0005\u001a0\u0010\u0006\u001a\u00020\u00012\f\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u00032\u0012\u0010\u0007\u001a\u000e\u0012\u0004\u0012\u00020\t\u0012\u0004\u0012\u00020\u00010\bH\u0082\b¢\u0006\u0002\u0010\n\u001a\u0010\u0010\u000b\u001a\u00020\u00012\u0006\u0010\f\u001a\u00020\tH\u0002¨\u0006\r"},
? d2 = {"main", "", "args", "", "", "([Ljava/lang/String;)V", "test", "test3P", "Lkotlin/Function1;", "", "([Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V", "test3", "i", "untitled2"}
)
@SourceDebugExtension({"SMAP\nMain.kt\nKotlin\n*S Kotlin\n*F\n+ 1 Main.kt\nMainKt\n*L\n1#1,22:1\n16#1,4:23\n*S KotlinDebug\n*F\n+ 1 Main.kt\nMainKt\n*L\n6#1:23,4\n*E\n"})
public final class MainKt {
? public static final void main(@NotNull String[] args) {
? ? ? Intrinsics.checkNotNullParameter(args, "args");
? ? ? String var1 = "Hello World!";
? ? ? System.out.println(var1);
? ? ? int m = true;
? ? ? int $i$f$test = false;
? ? ? int j$iv = 1;
? ? ? String var4 = "Program arguments:" + j$iv + "? " + ArraysKt.joinToString$default(args, (CharSequence)null, (CharSequence)null, (CharSequence)null, 0, (CharSequence)null, (Function1)null, 63, (Object)null);
? ? ? System.out.println(var4);
? ? ? int var6 = false;
? ? ? test3(j$iv);
? }
? private static final void test3(int i) {
? ? ? String var1 = "test3 Program arguments: " + CollectionsKt.contains((Iterable)RangesKt.downTo(3, 1), 1);
? ? ? System.out.println(var1);
? }
? private static final void test(String[] args, Function1 test3P) {
? ? ? int $i$f$test = 0;
? ? ? int j = 1;
? ? ? String var4 = "Program arguments:" + j + "? " + ArraysKt.joinToString$default(args, (CharSequence)null, (CharSequence)null, (CharSequence)null, 0, (CharSequence)null, (Function1)null, 63, (Object)null);
? ? ? System.out.println(var4);
? ? ? test3P.invoke(Integer.valueOf(j));
? }
}