我在编译以下代码时遇到问题:
@Composable
fun getWallethColors()= KotprefSettings.getNightMode().let {
if ((it == MODE_NIGHT_FOLLOW_SYSTEM && isSystemInDarkTheme()) || it == MODE_NIGHT_YES)
darkColors()
else
lightColors()
}
它抛出以下错误:
e: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: /home/ligi/git/walleth/app/app/src/main/java/org/walleth/ui/theme/WallethComposeTheme.kt
The root cause java.lang.AssertionError was thrown at: org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitWhen(JvmOptimizationLowering.kt:197)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:239)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:235)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(PhaseBuilders.kt:124)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(PhaseBuilders.kt:112)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:94)
at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:30)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:94)
w: Flag is not supported by this version of the compiler: -Xallow-jvm-ir-dependencies
at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:41)
at org.jetbrains.kotlin.backend.jvm.JvmLower.lower(JvmLower.kt:407)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.doGenerateFilesInternal(JvmIrCodegenFactory.kt:191)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:62)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:592)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:212)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:155)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:386)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:110)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:303)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:121)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:74)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:607)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:96)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1659)
at jdk.internal.reflect.GeneratedMethodAccessor110.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.AssertionError: ANDAND condition should have an 'if true then false' body on its second branch. Failing expression: WHEN type=kotlin.Boolean origin=ANDAND
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'it: kotlin.Int declared in org.walleth.ui.theme.WallethComposeThemeKt.getWallethColors$lambda-1' type=kotlin.Int origin=null
arg1: CONST Int type=kotlin.Int value=-1
then: BLOCK type=kotlin.Boolean origin=null
BLOCK type=kotlin.Unit origin=null
CALL 'public abstract fun startReplaceableGroup (key: kotlin.Int): kotlin.Unit declared in androidx.compose.runtime.Composer' type=kotlin.Unit origin=null
$this: GET_VAR '$$composer: androidx.compose.runtime.Composer? declared in org.walleth.ui.theme.WallethComposeThemeKt.getWallethColors$lambda-1' type=androidx.compose.runtime.Composer? origin=null
key: CONST Int type=kotlin.Int value=-1635160717
CALL 'public final fun sourceInformation (composer: androidx.compose.runtime.Composer, sourceInformation: kotlin.String): kotlin.Unit declared in androidx.compose.runtime.ComposerKt' type=kotlin.Unit origin=null
composer: GET_VAR '$$composer: androidx.compose.runtime.Composer? declared in org.walleth.ui.theme.WallethComposeThemeKt.getWallethColors$lambda-1' type=androidx.compose.runtime.Composer? origin=null
sourceInformation: CONST String type=kotlin.String value="21@785L21"
VAR IR_TEMPORARY_VARIABLE name:tmp0_group type:kotlin.Boolean [val]
CALL 'public final fun isSystemInDarkTheme ($composer: androidx.compose.runtime.Composer?, $changed: kotlin.Int): kotlin.Boolean declared in androidx.compose.foundation.DarkThemeKt' type=kotlin.Boolean origin=null
$composer: GET_VAR '$$composer: androidx.compose.runtime.Composer? declared in org.walleth.ui.theme.WallethComposeThemeKt.getWallethColors$lambda-1' type=androidx.compose.runtime.Composer? origin=null
$changed: CONST Int type=kotlin.Int value=0
CALL 'public abstract fun endReplaceableGroup (): kotlin.Unit declared in androidx.compose.runtime.Composer' type=kotlin.Unit origin=null
$this: GET_VAR '$$composer: androidx.compose.runtime.Composer? declared in org.walleth.ui.theme.WallethComposeThemeKt.getWallethColors$lambda-1' type=androidx.compose.runtime.Composer? origin=null
GET_VAR 'val tmp0_group: kotlin.Boolean [val] declared in org.walleth.ui.theme.WallethComposeThemeKt.getWallethColors$lambda-1' type=kotlin.Boolean origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=kotlin.Boolean origin=null
CALL 'public abstract fun startReplaceableGroup (key: kotlin.Int): kotlin.Unit declared in androidx.compose.runtime.Composer' type=kotlin.Unit origin=null
$this: GET_VAR '$$composer: androidx.compose.runtime.Composer? declared in org.walleth.ui.theme.WallethComposeThemeKt.getWallethColors$lambda-1' type=androidx.compose.runtime.Composer? origin=null
key: CONST Int type=kotlin.Int value=849626562
CALL 'public abstract fun endReplaceableGroup (): kotlin.Unit declared in androidx.compose.runtime.Composer' type=kotlin.Unit origin=null
$this: GET_VAR '$$composer: androidx.compose.runtime.Composer? declared in org.walleth.ui.theme.WallethComposeThemeKt.getWallethColors$lambda-1' type=androidx.compose.runtime.Composer? origin=null
CONST Boolean type=kotlin.Boolean value=false
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitWhen(JvmOptimizationLowering.kt:197)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitWhen(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.expressions.IrWhen.accept(IrWhen.kt:29)
at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
at org.jetbrains.kotlin.ir.expressions.IrBranch.transformChildren(IrWhen.kt:54)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitBranch(IrElementTransformer.kt:132)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitBranch(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitBranch(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.expressions.impl.IrBranchImpl.transform(IrWhenImpl.kt:56)
at org.jetbrains.kotlin.ir.expressions.IrWhen.transformChildren(IrWhen.kt:37)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitWhen(JvmOptimizationLowering.kt:191)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitWhen(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.expressions.IrWhen.accept(IrWhen.kt:29)
at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
at org.jetbrains.kotlin.ir.expressions.IrBranch.transformChildren(IrWhen.kt:54)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitBranch(IrElementTransformer.kt:132)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitBranch(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitBranch(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.expressions.impl.IrBranchImpl.transform(IrWhenImpl.kt:56)
at org.jetbrains.kotlin.ir.expressions.IrWhen.transformChildren(IrWhen.kt:37)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitWhen(JvmOptimizationLowering.kt:191)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitWhen(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.expressions.IrWhen.accept(IrWhen.kt:29)
at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
at org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl.transformChildren(IrVariableImpl.kt:81)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitDeclaration(IrElementTransformer.kt:46)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitDeclaration(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitDeclaration(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitVariable(IrElementTransformer.kt:60)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitVariable(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitVariable(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl.accept(IrVariableImpl.kt:74)
at org.jetbrains.kotlin.ir.IrElement$DefaultImpls.transform(IrElement.kt:32)
at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:19)
at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
at org.jetbrains.kotlin.ir.expressions.IrContainerExpression.transformChildren(IrBlock.kt:41)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitContainerExpression(JvmOptimizationLowering.kt:340)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitContainerExpression(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitBlock(IrElementTransformer.kt:91)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitBlock(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitBlock(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl.accept(IrBlockImpl.kt:48)
at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:26)
at org.jetbrains.kotlin.ir.expressions.IrBlockBody.transformChildren(IrBody.kt:62)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitBlockBody(JvmOptimizationLowering.kt:334)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitBlockBody(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBody.kt:54)
at org.jetbrains.kotlin.ir.expressions.IrBody.transform(IrBody.kt:27)
at org.jetbrains.kotlin.ir.declarations.IrFunction.transformChildren(IrFunction.kt:69)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitFunction(JvmOptimizationLowering.kt:86)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitFunction(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitSimpleFunction(IrElementTransformer.kt:53)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitSimpleFunction(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitSimpleFunction(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.declarations.IrSimpleFunction.accept(IrSimpleFunction.kt:29)
at org.jetbrains.kotlin.ir.IrElement$DefaultImpls.transform(IrElement.kt:32)
at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:19)
at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
at org.jetbrains.kotlin.ir.declarations.IrClass.transformChildren(IrClass.kt:67)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitClass(JvmOptimizationLowering.kt:74)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering$lower$transformer$1.visitClass(JvmOptimizationLowering.kt:68)
at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:56)
at org.jetbrains.kotlin.ir.IrElement$DefaultImpls.transform(IrElement.kt:32)
at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:19)
at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.transformChildren(IrFileImpl.kt:71)
at org.jetbrains.kotlin.backend.jvm.lower.JvmOptimizationLowering.lower(JvmOptimizationLowering.kt:355)
at org.jetbrains.kotlin.backend.common.phaser.FileLoweringPhaseAdapter.invoke(PhaseBuilders.kt:155)
at org.jetbrains.kotlin.backend.common.phaser.FileLoweringPhaseAdapter.invoke(PhaseBuilders.kt:151)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:94)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(PhaseBuilders.kt:121)
... 41 more
有趣的是,当我把它重写为:
fun getWallethColors(isSystemDark: Boolean) = KotprefSettings.getNightMode().let {
if ((it == MODE_NIGHT_FOLLOW_SYSTEM && isSystemDark) || it == MODE_NIGHT_YES)
darkColors()
else
lightColors()
}
@Composable
fun getWallethColors() = getWallethColors(isSystemInDarkTheme())
它编译得很好。我是喷气背包创作的新手,想知道我是做错了什么,还是这是一个bug。
这是一个错误。请在https://issuetracker.google.com/issues/new?component=612128
如果编译器抛出:e: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error
,则(根据定义(它始终是编译器级别的错误。