I switched my project to Kotlin 2.0.0-RC2 and I of...
# compiler
n
I switched my project to Kotlin 2.0.0-RC2 and I often run into "Backend Internal error: Exception during IR lowering" errors. These errors are not reported automatically by Idea, and they are very difficult to investigate because the exact location of the error is not present in the message, only the .kt file name. Is there a way to debug such errors, so I can maybe report them and/or find workarounds? Thanks.
They seem to be related to generics, they are similar to this:
Copy code
Caused by: java.lang.AssertionError: Mismatching type arguments: 0 vs 3 + 0
Example:
Copy code
org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: .../TypeSafeProjectionQueryTest.kt
The root cause java.lang.AssertionError was thrown at: org.jetbrains.kotlin.ir.expressions.IrExpressionsKt.copyTypeArgumentsFrom(IrExpressions.kt:81)
	at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:253)
	at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:236)
	at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:65)
	at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:52)
	at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:38)
	at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.phaseBody(CompilerPhase.kt:166)
	at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:113)
	at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29)
	at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:16)
	at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.phaseBody(CompilerPhase.kt:166)
	at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:113)
	at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:62)
	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.invokeLowerings(JvmIrCodegenFactory.kt:358)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.runLowerings(KotlinToJVMBytecodeCompiler.kt:453)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:128)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:176)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:50)
...
Caused by: java.lang.AssertionError: Mismatching type arguments: 0 vs 3 + 0
	at org.jetbrains.kotlin.ir.expressions.IrExpressionsKt.copyTypeArgumentsFrom(IrExpressions.kt:81)
	at org.jetbrains.kotlin.ir.expressions.IrExpressionsKt.copyTypeArgumentsFrom$default(IrExpressions.kt:80)
	at org.jetbrains.kotlin.backend.jvm.lower.JvmInlineClassLowering.buildReplacement(JvmInlineClassLowering.kt:210)
	at org.jetbrains.kotlin.backend.jvm.lower.JvmInlineClassLowering.visitFunctionAccess(JvmInlineClassLowering.kt:249)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:296)
	at org.jetbrains.kotlin.backend.jvm.lower.JvmInlineClassLowering.visitCall(JvmInlineClassLowering.kt:361)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:299)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:19)
	at org.jetbrains.kotlin.ir.expressions.IrCall.accept(IrCall.kt:24)
	at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:24)
	at org.jetbrains.kotlin.ir.expressions.IrReturn.transformChildren(IrReturn.kt:31)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpression(IrElementTransformerVoid.kt:166)
p
This shouldn't normally happen on any code (basicaly, it is compiler crash), can you please report this as bug. If your code is publically available or at least you can show TypeSafeProjectionQueryTest.kt and related classes it would be useful.
287 Views