@Contextual does not work with IR compiler
See original GitHub issueDescribe the bug
I use @Contextual
at many places in my multiplatform library. It works fine and all my unit tests are working with jvm und js(LEGACY), but not with js(IR) and native targets.
I get the following stacktrace when building the project:
e: java.lang.IllegalStateException: Not found Idx for public net.folivo.trixnity.core.model.events/Event|null[0]
at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.loadTopLevelDeclarationProto(IrFileDeserializer.kt:45)
at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeDeclaration$ir_serialization_common(IrFileDeserializer.kt:36)
at org.jetbrains.kotlin.backend.common.serialization.FileDeserializationState.deserializeAllFileReachableTopLevel(IrFileDeserializer.kt:127)
at org.jetbrains.kotlin.backend.common.serialization.ModuleDeserializationState.deserializeReachableDeclarations(BasicIrModuleDeserializer.kt:163)
at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.deserializeAllReachableTopLevels(KotlinIrLinker.kt:105)
at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.findDeserializedDeclarationForSymbol(KotlinIrLinker.kt:124)
at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.getDeclaration(KotlinIrLinker.kt:162)
at org.jetbrains.kotlin.ir.util.ExternalDependenciesGeneratorKt.getDeclaration(ExternalDependenciesGenerator.kt:61)
at org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator.generateUnboundSymbolsAsDependencies(ExternalDependenciesGenerator.kt:48)
at org.jetbrains.kotlin.ir.backend.js.KlibKt.loadIr(klib.kt:288)
at org.jetbrains.kotlin.ir.backend.js.CompilerKt.compile(compiler.kt:57)
at org.jetbrains.kotlin.ir.backend.js.CompilerKt.compile$default(compiler.kt:36)
at org.jetbrains.kotlin.cli.js.K2JsIrCompiler.doExecute(K2JsIrCompiler.kt:256)
at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:182)
at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:75)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:90)
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.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1575)
at jdk.internal.reflect.GeneratedMethodAccessor99.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:829)
To Reproduce Here is a minimal example from my code base.
Expected behavior
@Contextual
should work with IR compiler as it does without.
Environment
- Kotlin version: 1.5.20
- Library version: 1.2.1
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Is it possible that Contextual does not work with IR compile ...
Contextual and generics don't exactly play nice, but it should still work. ... Haha, JVM switched to IR compiler. I'm guessing javascript will...
Read more >Internal compiler error: StackOverflow - ContextualSerializer ...
I've found the following works*. - It's mostly just a simplified copy of the implementation. (However, the descriptor cannot 'implement' ...
Read more >Contextual receivers: Compiler error assigning contextual function to ...
When assigning a function to a val that has contextual receivers using ... I am not sure if the error is directly related...
Read more >Contextual Compiler Pass Injection · Cassette
To resolve issues like these, we'll need to dig deeper than contextual dispatch and implement an actual compiler pass. First, let's go over...
Read more >Design: Fortran IR — The Flang Compiler - LLVM releases
Pro: Straightforward implementation when control-flow is well-structured as the contextual state parallels the syntax of the language closely.
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
I’m not using
@Contextual
either. I think this has to do with generics. @benkuly just happens to be using both.With Kotlin 1.5.30 this does also affect the jvm target with the following exception. I also updated the example branch linked above.