JVM Compiler error after upgrading to 1.5.30
See original GitHub issueDescribe the bug
I’m getting a compiler error after upgrading to Kotlin 1.5.30:
e: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: C:/Users/jimne/Google Drive/My Stuff/spellbook/common/src/commonMain/kotlin/com/rnett/spellbook/spellbook/Spellcasting.kt
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
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.invokeSequential(performByIrFile.kt:68)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:55)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:41)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:43)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.doGenerateFilesInternal(JvmIrCodegenFactory.kt:191)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:60)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:321)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:113)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:56)
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:92)
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:412)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:112)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:358)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:300)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl$rebuild(IncrementalCompilerRunner.kt:119)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:170)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:81)
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:1658)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
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(AccessController.java:691)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.RuntimeException: Exception while generating code for:
FUN name:write$Self visibility:public modality:FINAL <> (self:com.rnett.spellbook.spellbook.Spellbook, output:kotlinx.serialization.encoding.CompositeEncoder, serialDesc:kotlinx.serialization.descriptors.SerialDescriptor) returnType:kotlin.Unit
annotations:
JvmStatic
VALUE_PARAMETER name:self index:0 type:com.rnett.spellbook.spellbook.Spellbook
VALUE_PARAMETER name:output index:1 type:kotlinx.serialization.encoding.CompositeEncoder
VALUE_PARAMETER name:serialDesc index:2 type:kotlinx.serialization.descriptors.SerialDescriptor
BLOCK_BODY
CALL 'public abstract fun encodeSerializableElement <T> (descriptor: kotlinx.serialization.descriptors.SerialDescriptor, index: kotlin.Int, serializer: kotlinx.serialization.SerializationStrategy<T of kotlinx.serialization.encoding.CompositeEncoder.encodeSerializableElement>, value: T of kotlinx.serialization.encoding.CompositeEncoder.encodeSerializableElement): kotlin.Unit declared in kotlinx.serialization.encoding.CompositeEncoder' type=kotlin.Unit origin=null
<T>: kotlin.collections.Map<kotlin.String, com.rnett.spellbook.spellbook.Spellcasting<*>>
$this: GET_VAR 'output: kotlinx.serialization.encoding.CompositeEncoder declared in com.rnett.spellbook.spellbook.Spellbook.write$Self' type=kotlinx.serialization.encoding.CompositeEncoder origin=null
descriptor: GET_VAR 'serialDesc: kotlinx.serialization.descriptors.SerialDescriptor declared in com.rnett.spellbook.spellbook.Spellbook.write$Self' type=kotlinx.serialization.descriptors.SerialDescriptor origin=null
index: CONST Int type=kotlin.Int value=0
serializer: CONSTRUCTOR_CALL 'public constructor <init> (kSerializer: kotlinx.serialization.KSerializer<K of kotlinx.serialization.internal.LinkedHashMapSerializer>, vSerializer: kotlinx.serialization.KSerializer<V of kotlinx.serialization.internal.LinkedHashMapSerializer>) [primary] declared in kotlinx.serialization.internal.LinkedHashMapSerializer' type=kotlinx.serialization.internal.LinkedHashMapSerializer<kotlin.String, com.rnett.spellbook.spellbook.Spellcasting<*>> origin=null
<class: K>: kotlin.String
<class: V>: com.rnett.spellbook.spellbook.Spellcasting<*>
kSerializer: GET_FIELD 'FIELD FIELD_FOR_OBJECT_INSTANCE name:INSTANCE type:kotlinx.serialization.internal.StringSerializer visibility:public [final,static]' type=kotlinx.serialization.internal.StringSerializer origin=null
vSerializer: CALL 'public final fun serializer <T0> (typeSerial0: kotlinx.serialization.KSerializer<T0 of com.rnett.spellbook.spellbook.Spellcasting.Companion.serializer>): kotlinx.serialization.KSerializer<com.rnett.spellbook.spellbook.Spellcasting<T0 of com.rnett.spellbook.spellbook.Spellcasting.Companion.serializer>> declared in com.rnett.spellbook.spellbook.Spellcasting.Companion' type=kotlinx.serialization.KSerializer<com.rnett.spellbook.spellbook.Spellcasting<T0 of com.rnett.spellbook.spellbook.Spellcasting.Companion.serializer>> origin=null
<T0>: com.rnett.spellbook.spellbook.Spellcasting<*>
$this: GET_FIELD 'FIELD FIELD_FOR_OBJECT_INSTANCE name:Companion type:com.rnett.spellbook.spellbook.Spellcasting.Companion visibility:public [final,static]' type=com.rnett.spellbook.spellbook.Spellcasting.Companion origin=null
value: BLOCK type=kotlin.collections.Map<kotlin.String, com.rnett.spellbook.spellbook.Spellcasting<*>> origin=null
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:spellcastings type:kotlin.collections.Map<kotlin.String, com.rnett.spellbook.spellbook.Spellcasting<*>> visibility:private [final]' type=kotlin.collections.Map<kotlin.String, com.rnett.spellbook.spellbook.Spellcasting<*>> origin=null
receiver: GET_VAR 'self: com.rnett.spellbook.spellbook.Spellbook declared in com.rnett.spellbook.spellbook.Spellbook.write$Self' type=com.rnett.spellbook.spellbook.Spellbook origin=null
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate$default(FunctionCodegen.kt:43)
at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethodNode(ClassCodegen.kt:341)
at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethod(ClassCodegen.kt:358)
at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generate(ClassCodegen.kt:130)
at org.jetbrains.kotlin.backend.jvm.JvmLowerKt$codegenPhase$1$1.lower(JvmLower.kt:304)
at org.jetbrains.kotlin.backend.common.phaser.FileLoweringPhaseAdapter.invoke(PhaseBuilders.kt:120)
at org.jetbrains.kotlin.backend.common.phaser.FileLoweringPhaseAdapter.invoke(PhaseBuilders.kt:116)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:65)
... 46 more
Caused by: java.lang.IllegalArgumentException: Null argument in ExpressionCodegen for parameter VALUE_PARAMETER name:typeSerial0 index:0 type:kotlinx.serialization.KSerializer<T0 of com.rnett.spellbook.spellbook.Spellcasting.Companion.serializer>
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitCall(ExpressionCodegen.kt:478)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitCall(ExpressionCodegen.kt:134)
at org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl.accept(IrCallImpl.kt:47)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.gen(ExpressionCodegen.kt:217)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.generateConstructorArguments(ExpressionCodegen.kt:605)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitConstructorCall(ExpressionCodegen.kt:593)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitConstructorCall(ExpressionCodegen.kt:134)
at org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl.accept(IrConstructorCallImpl.kt:28)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.gen(ExpressionCodegen.kt:217)
at org.jetbrains.kotlin.backend.jvm.codegen.IrCallGenerator$DefaultImpls.genValueAndPut(IrCallGenerator.kt:47)
at org.jetbrains.kotlin.backend.jvm.codegen.IrCallGenerator$DefaultCallGenerator.genValueAndPut(IrCallGenerator.kt:50)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitCall(ExpressionCodegen.kt:479)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitCall(ExpressionCodegen.kt:134)
at org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl.accept(IrCallImpl.kt:47)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitStatementContainer(ExpressionCodegen.kt:435)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitBlockBody(ExpressionCodegen.kt:439)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitBlockBody(ExpressionCodegen.kt:134)
at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBody.kt:54)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.generate(ExpressionCodegen.kt:235)
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.doGenerate(FunctionCodegen.kt:122)
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:48)
... 55 more
To Reproduce
Run :common:compileKotlinJvm
on the attached project.
Expected behavior The project compiles.
Environment
- Kotlin version: 1.5.30
- Library version: 1.2.2
- Kotlin platforms: JVM
- Gradle version: 7.2
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Internal Compiler Error after upgrade Kotlin version to 1.5.30
After the Kotlin upgrade the project can't build anymore, the build process throws : Execution failed for task ':app:compileDebugKotlin'. > ...
Read more >Kotlin 1.5.30 Is Now Available! - The JetBrains Blog
Kotlin 1.5.30 includes many experimental language and standard library features that we are planning to release in Kotlin 1.6.0.
Read more >What's new in Kotlin 1.5.30
The compiler raises a warning or error when the API is used and requires explicit consent to suppress it. In Kotlin 1.5.30, the...
Read more >Compose Compiler - Android Developers
Fundamental components of compose UI needed to interact with the device, including layout, drawing, and input. Declaring dependencies. To add a dependency on...
Read more >Kotlin 1.5 的兼容性指南
Short summary: Kotlin 1.5 uses the IR-based backend for the Kotlin/JVM compiler by default. The old backend is still used by default for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi! This error occurs when nested generics for sealed classes are used (
Map<String, Spellcasting<*>>
for your case).As a work-round, you may remove the generic parameter from
Spellcasting
, but in this case the fields of this class will be of typeSpellLevel
and polymorphic serialization will work (thetype
field will be added to JSON).Simple reproducer:
Seemingly the repro I provided previously does work now, but something else in my actual codebase is failing. I will look for a new repro!