Kotlin编译器错误内联函数,不完全确定发生了什么事情

我得到了这个令人困惑的错误,似乎是在Kotlin编译器中,我不介意更改我的代码,但我正在试图弄清楚我是否真的做错了什么。 我认为它遇到的代码是这样的:

inline fun <T> fiberListener(bufferSize: Int = 50, policy: Channels.OverflowPolicy = Channels.OverflowPolicy.BACKOFF, singleProducer: Boolean = true, singleConsumer: Boolean = true, crossinline action: (T) -> Unit): SendPort<T> { val channel = Channels.newChannel<T>(bufferSize, policy, singleProducer, singleConsumer) fiber { channel.forEach(action) } return channel } 

不知道还有什么可说的,我可以使这不是内联,但我认为这个代码应该工作。 我用Gradle使用Kotlin 1.0.4。 另外一点我不太肯定,这实际上是提供了一个性能提升,我对于crossinline还是有点不清楚。 但无论哪种方式似乎它应该工作,我没有得到任何IDE或编译器错误,除了这个内部的错误。

 Error:(37, 45) Kotlin: [Internal Error] org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't inline method call 'fiberListener' into local final fun <anonymous>(module: org.tenkiv.nexus.thermal.module.ProducerModule): kotlin.Unit defined in org.tenkiv.nexus.thermal.control_point.StateMaintainer.<init>[AnonymousFunctionDescriptor@392d1483] { module -> module.levelSensor?.addListener(fiberListener { onLevelEvent() }) } Cause: fiberListener$default (ILco/paralleluniverse/strands/channels/Channels$OverflowPolicy;ZZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lco/paralleluniverse/strands/channels/SendPort;: L0 ALOAD 6 IFNULL L1 NEW java/lang/UnsupportedOperationException DUP LDC "Super calls with default arguments not supported in this target, function: fiberListener" INVOKESPECIAL java/lang/UnsupportedOperationException.<init> (Ljava/lang/String;)V ATHROW L1 ILOAD 5 ICONST_1 IAND IFEQ L2 L3 LINENUMBER 13 L3 BIPUSH 50 ISTORE 0 L2 ILOAD 5 ICONST_2 IAND IFEQ L4 L5 LINENUMBER 14 L5 GETSTATIC co/paralleluniverse/strands/channels/Channels$OverflowPolicy.BACKOFF : Lco/paralleluniverse/strands/channels/Channels$OverflowPolicy; ASTORE 1 L4 ILOAD 5 ICONST_4 IAND IFEQ L6 L7 LINENUMBER 15 L7 ICONST_1 ISTORE 2 L6 ILOAD 5 BIPUSH 8 IAND IFEQ L8 L9 LINENUMBER 16 L9 ICONST_1 ISTORE 3 L8 L10 L11 ALOAD 1 LDC "policy" INVOKESTATIC kotlin/jvm/internal/Intrinsics.checkParameterIsNotNull (Ljava/lang/Object;Ljava/lang/String;)V ALOAD 4 LDC "action" INVOKESTATIC kotlin/jvm/internal/Intrinsics.checkParameterIsNotNull (Ljava/lang/Object;Ljava/lang/String;)V L12 LINENUMBER 40 L12 ILOAD 0 ALOAD 1 ILOAD 2 ILOAD 3 INVOKESTATIC co/paralleluniverse/strands/channels/Channels.newChannel (ILco/paralleluniverse/strands/channels/Channels$OverflowPolicy;ZZ)Lco/paralleluniverse/strands/channels/Channel; ASTORE 6 L13 L14 LINENUMBER 41 L14 NEW org/tenkiv/nexus/computer/QuasarKt$fiberListener$1 DUP ALOAD 6 ALOAD 4 INVOKESPECIAL org/tenkiv/nexus/computer/QuasarKt$fiberListener$1.<init> (Lco/paralleluniverse/strands/channels/Channel;Lkotlin/jvm/functions/Function1;)V CHECKCAST kotlin/jvm/functions/Function0 INVOKESTATIC co/paralleluniverse/kotlin/KotlinKt.fiber (Lkotlin/jvm/functions/Function0;)Lco/paralleluniverse/fibers/Fiber; POP L15 LINENUMBER 42 L15 ALOAD 6 CHECKCAST co/paralleluniverse/strands/channels/SendPort DUP LDC "channel" INVOKESTATIC kotlin/jvm/internal/Intrinsics.checkExpressionValueIsNotNull (Ljava/lang/Object;Ljava/lang/String;)V ARETURN L16 L17 ARETURN LOCALVARIABLE channel Lco/paralleluniverse/strands/channels/Channel; L13 L17 6 LOCALVARIABLE bufferSize I L0 L17 0 LOCALVARIABLE policy Lco/paralleluniverse/strands/channels/Channels$OverflowPolicy; L0 L17 1 LOCALVARIABLE singleProducer Z L0 L17 2 LOCALVARIABLE singleConsumer Z L0 L17 3 LOCALVARIABLE action Lkotlin/jvm/functions/Function1; L0 L17 4 LOCALVARIABLE $i$f$fiberListener I L10 L17 5 MAXSTACK = 4 MAXLOCALS = 7 Cause: Parameter specified as non-null is null: method org.jetbrains.kotlin.codegen.inline.ParametersBuilder.addCapturedParam, parameter original File being compiled and position: (37,45) in /Users/zjuhasz/Git/Nexus_Brain/src/main/kotlin/org/tenkiv/nexus/thermal/control_point/StateMaintainer.kt PsiElement: fiberListener { onLevelEvent() } The root cause was thrown at: ParametersBuilder.kt:-1 at org.jetbrains.kotlin.codegen.inline.InlineCodegen.throwCompilationException(InlineCodegen.java:172) at org.jetbrains.kotlin.codegen.inline.InlineCodegen.genCallInner(InlineCodegen.java:158) at org.jetbrains.kotlin.codegen.CallGenerator.genCall(CallGenerator.kt:100) at org.jetbrains.kotlin.codegen.ExpressionCodegen.invokeMethodWithArguments(ExpressionCodegen.java:2625) at org.jetbrains.kotlin.codegen.ExpressionCodegen.invokeMethodWithArguments(ExpressionCodegen.java:2583) at org.jetbrains.kotlin.codegen.Callable$invokeMethodWithArguments$1.invoke(Callable.kt:44) at org.jetbrains.kotlin.codegen.Callable$invokeMethodWithArguments$1.invoke(Callable.kt:23) at org.jetbrains.kotlin.codegen.OperationStackValue.putSelector(StackValue.kt:65) at org.jetbrains.kotlin.codegen.StackValue.put(StackValue.java:109) at org.jetbrains.kotlin.codegen.StackValue.put(StackValue.java:102) at org.jetbrains.kotlin.codegen.CallGenerator$DefaultCallGenerator.genValueAndPut(CallGenerator.kt:58) at org.jetbrains.kotlin.codegen.CallBasedArgumentGenerator.generateExpression(CallBasedArgumentGenerator.java:73) at org.jetbrains.kotlin.codegen.ArgumentGenerator.generate(ArgumentGenerator.kt:59) at org.jetbrains.kotlin.codegen.CallBasedArgumentGenerator.generate(CallBasedArgumentGenerator.java:60) at org.jetbrains.kotlin.codegen.ExpressionCodegen.invokeMethodWithArguments(ExpressionCodegen.java:2605) at org.jetbrains.kotlin.codegen.ExpressionCodegen.invokeMethodWithArguments(ExpressionCodegen.java:2583) at org.jetbrains.kotlin.codegen.Callable$invokeMethodWithArguments$1.invoke(Callable.kt:44) at org.jetbrains.kotlin.codegen.Callable$invokeMethodWithArguments$1.invoke(Callable.kt:23) at org.jetbrains.kotlin.codegen.OperationStackValue.putSelector(StackValue.kt:65) at org.jetbrains.kotlin.codegen.CoercionValue.putSelector(StackValue.kt:28) at org.jetbrains.kotlin.codegen.StackValue.put(StackValue.java:109) at org.jetbrains.kotlin.codegen.StackValue.put(StackValue.java:102) at org.jetbrains.kotlin.codegen.StackValue$StackValueWithSimpleReceiver.putReceiver(StackValue.java:1507) at org.jetbrains.kotlin.codegen.StackValueWithLeaveTask.putReceiver(StackValue.kt:53) at org.jetbrains.kotlin.codegen.StackValue.put(StackValue.java:107) at org.jetbrains.kotlin.codegen.StackValue.put(StackValue.java:102) at org.jetbrains.kotlin.codegen.ExpressionCodegen.gen(ExpressionCodegen.java:324) at org.jetbrains.kotlin.codegen.ExpressionCodegen.returnExpression(ExpressionCodegen.java:2066) at org.jetbrains.kotlin.codegen.FunctionGenerationStrategy$FunctionDefault.doGenerateBody(FunctionGenerationStrategy.java:50) at org.jetbrains.kotlin.codegen.FunctionGenerationStrategy$CodegenBased.generateBody(FunctionGenerationStrategy.java:72) at org.jetbrains.kotlin.codegen.FunctionCodegen.generateMethodBody(FunctionCodegen.java:378) at org.jetbrains.kotlin.codegen.inline.InlineCodegen.generateMethodBody(InlineCodegen.java:512) at org.jetbrains.kotlin.codegen.inline.InlineCodegen.generateLambdaBody(InlineCodegen.java:477) at org.jetbrains.kotlin.codegen.inline.InlineCodegen.generateClosuresBodies(InlineCodegen.java:456) at org.jetbrains.kotlin.codegen.inline.InlineCodegen.inlineCall(InlineCodegen.java:365) at org.jetbrains.kotlin.codegen.inline.InlineCodegen.genCallInner(InlineCodegen.java:149) at org.jetbrains.kotlin.codegen.CallGenerator.genCall(CallGenerator.kt:100) at org.jetbrains.kotlin.codegen.ExpressionCodegen.invokeMethodWithArguments(ExpressionCodegen.java:2625) at org.jetbrains.kotlin.codegen.ExpressionCodegen.invokeMethodWithArguments(ExpressionCodegen.java:2583) at org.jetbrains.kotlin.codegen.Callable$invokeMethodWithArguments$1.invoke(Callable.kt:44) at org.jetbrains.kotlin.codegen.Callable$invokeMethodWithArguments$1.invoke(Callable.kt:23) at org.jetbrains.kotlin.codegen.OperationStackValue.putSelector(StackValue.kt:65) at org.jetbrains.kotlin.codegen.StackValue.put(StackValue.java:109) at org.jetbrains.kotlin.codegen.StackValue.put(StackValue.java:102) at org.jetbrains.kotlin.codegen.ExpressionCodegen.generateBlock(ExpressionCodegen.java:1727) at org.jetbrains.kotlin.codegen.ExpressionCodegen.generateBlock(ExpressionCodegen.java:1676) at org.jetbrains.kotlin.codegen.CodegenStatementVisitor.visitBlockExpression(CodegenStatementVisitor.java:56) at org.jetbrains.kotlin.codegen.CodegenStatementVisitor.visitBlockExpression(CodegenStatementVisitor.java:22) at org.jetbrains.kotlin.psi.KtBlockExpression.accept(KtBlockExpression.java:44) at org.jetbrains.kotlin.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:283) at org.jetbrains.kotlin.codegen.ExpressionCodegen.genStatement(ExpressionCodegen.java:342) at org.jetbrains.kotlin.codegen.ExpressionCodegen.gen(ExpressionCodegen.java:312) at org.jetbrains.kotlin.codegen.MemberCodegen.generateInitializers(MemberCodegen.java:377) at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.generateInitializers(ImplementationBodyCodegen.java:1099) at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.generatePrimaryConstructorImpl(ImplementationBodyCodegen.java:1038) at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.access$300(ImplementationBodyCodegen.java:92) at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen$3.doGenerateBody(ImplementationBodyCodegen.java:946) at org.jetbrains.kotlin.codegen.FunctionGenerationStrategy$CodegenBased.generateBody(FunctionGenerationStrategy.java:72) at org.jetbrains.kotlin.codegen.FunctionCodegen.generateMethodBody(FunctionCodegen.java:378) at org.jetbrains.kotlin.codegen.FunctionCodegen.generateMethod(FunctionCodegen.java:213) at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.generatePrimaryConstructor(ImplementationBodyCodegen.java:942) at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.generateConstructors(ImplementationBodyCodegen.java:397) at org.jetbrains.kotlin.codegen.ClassBodyCodegen.generateBody(ClassBodyCodegen.java:79) at org.jetbrains.kotlin.codegen.MemberCodegen.generate(MemberCodegen.java:118) at org.jetbrains.kotlin.codegen.MemberCodegen.genClassOrObject(MemberCodegen.java:232) at org.jetbrains.kotlin.codegen.PackageCodegen.generateClassOrObject(PackageCodegen.java:145) at org.jetbrains.kotlin.codegen.PackageCodegen.generateFile(PackageCodegen.java:98) at org.jetbrains.kotlin.codegen.PackageCodegen.generate(PackageCodegen.java:61) at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.generatePackage(KotlinCodegenFacade.java:99) at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.doGenerateFiles(KotlinCodegenFacade.java:77) at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:44) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:452) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:150) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:183) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52) at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:199) at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:154) at org.jetbrains.kotlin.cli.common.CLICompiler.execAndOutputXml(CLICompiler.java:73) at org.jetbrains.kotlin.daemon.CompileServiceImpl$remoteIncrementalCompile$1.invoke(CompileServiceImpl.kt:247) at org.jetbrains.kotlin.daemon.CompileServiceImpl$remoteIncrementalCompile$1.invoke(CompileServiceImpl.kt:70) at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$1$1.invoke(CompileServiceImpl.kt:421) at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$1$1.invoke(CompileServiceImpl.kt:70) at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137) at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:454) at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$checkedCompile(CompileServiceImpl.kt:70) at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$1.invoke(CompileServiceImpl.kt:420) at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$1.invoke(CompileServiceImpl.kt:70) at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive(CompileServiceImpl.kt:565) at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive$default(CompileServiceImpl.kt:504) at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:411) at org.jetbrains.kotlin.daemon.CompileServiceImpl.remoteIncrementalCompile(CompileServiceImpl.kt:244) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.run(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$254(TCPTransport.java:683) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$1/2057391342.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method org.jetbrains.kotlin.codegen.inline.ParametersBuilder.addCapturedParam, parameter original at org.jetbrains.kotlin.codegen.inline.ParametersBuilder.addCapturedParam(ParametersBuilder.kt) at org.jetbrains.kotlin.codegen.inline.LambdaInfo.addAllParameters(LambdaInfo.java:158) at org.jetbrains.kotlin.codegen.inline.MethodInliner$1.visitMethodInsn(MethodInliner.java:223) at org.jetbrains.org.objectweb.asm.tree.MethodInsnNode.accept(MethodInsnNode.java:133) at org.jetbrains.org.objectweb.asm.tree.InsnList.accept(InsnList.java:162) at org.jetbrains.org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:817) at org.jetbrains.kotlin.codegen.inline.MethodInliner.doInline(MethodInliner.java:311) at org.jetbrains.kotlin.codegen.inline.MethodInliner.doInline(MethodInliner.java:111) at org.jetbrains.kotlin.codegen.inline.MethodInliner.doInline(MethodInliner.java:95) at org.jetbrains.kotlin.codegen.inline.AnonymousObjectTransformer.inlineMethod(AnonymousObjectTransformer.java:230) at org.jetbrains.kotlin.codegen.inline.AnonymousObjectTransformer.inlineMethodAndUpdateGlobalResult(AnonymousObjectTransformer.java:191) at org.jetbrains.kotlin.codegen.inline.AnonymousObjectTransformer.doTransform(AnonymousObjectTransformer.java:144) at org.jetbrains.kotlin.codegen.inline.MethodInliner$1.handleAnonymousObjectRegeneration(MethodInliner.java:180) at org.jetbrains.kotlin.codegen.inline.MethodInliner$1.anew(MethodInliner.java:199) at org.jetbrains.org.objectweb.asm.commons.InstructionAdapter.visitTypeInsn(InstructionAdapter.java:478) at org.jetbrains.org.objectweb.asm.tree.TypeInsnNode.accept(TypeInsnNode.java:83) at org.jetbrains.org.objectweb.asm.tree.InsnList.accept(InsnList.java:162) at org.jetbrains.org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:817) at org.jetbrains.kotlin.codegen.inline.MethodInliner.doInline(MethodInliner.java:311) at org.jetbrains.kotlin.codegen.inline.MethodInliner.doInline(MethodInliner.java:111) at org.jetbrains.kotlin.codegen.inline.MethodInliner.doInline(MethodInliner.java:95) at org.jetbrains.kotlin.codegen.inline.AnonymousObjectTransformer.inlineMethod(AnonymousObjectTransformer.java:230) at org.jetbrains.kotlin.codegen.inline.AnonymousObjectTransformer.inlineMethodAndUpdateGlobalResult(AnonymousObjectTransformer.java:191) at org.jetbrains.kotlin.codegen.inline.AnonymousObjectTransformer.doTransform(AnonymousObjectTransformer.java:144) at org.jetbrains.kotlin.codegen.inline.MethodInliner$1.handleAnonymousObjectRegeneration(MethodInliner.java:180) at org.jetbrains.kotlin.codegen.inline.MethodInliner$1.anew(MethodInliner.java:199) at org.jetbrains.org.objectweb.asm.commons.InstructionAdapter.visitTypeInsn(InstructionAdapter.java:478) at org.jetbrains.org.objectweb.asm.tree.TypeInsnNode.accept(TypeInsnNode.java:83) at org.jetbrains.org.objectweb.asm.tree.InsnList.accept(InsnList.java:162) at org.jetbrains.org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:817) at org.jetbrains.kotlin.codegen.inline.MethodInliner.doInline(MethodInliner.java:311) at org.jetbrains.kotlin.codegen.inline.MethodInliner.doInline(MethodInliner.java:111) at org.jetbrains.kotlin.codegen.inline.MethodInliner.doInline(MethodInliner.java:95) at org.jetbrains.kotlin.codegen.inline.InlineCodegen.inlineCall(InlineCodegen.java:392) at org.jetbrains.kotlin.codegen.inline.InlineCodegen.genCallInner(InlineCodegen.java:149) ... 107 more 

Kotlin language will be the best programming language for Android.