question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AssistedInject – BackendException: Backend Internal error: Exception during psi2ir

See original GitHub issue

Running into this issue when using @AssistedInject on the latest version of Anvil and Kotlin 1.4.30 with useIR = true

Repro repository

Steps to reproduce:

  • useIR = true in build.gradle
  • Enable generateDaggerFactories
  • Create an @AssistedInject class
  • Build project - build is successful
  • Change code in any way (see sample in repro repo) and build
  • Following exception is thrown:
org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during psi2ir
File being compiled: /../../anvil-ir-issue/lib/build/anvil/src-gen-debug/dev/steelahhh/lib/SomeAssistedClass_Factory.kt
The root cause java.lang.NullPointerException was thrown at: kotlin.collections.CollectionsKt___CollectionsKt.joinToString(_Collections.kt)
	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.psi2ir.generators.DeclarationGenerator.generateMemberDeclaration(DeclarationGenerator.kt:78)
	at org.jetbrains.kotlin.psi2ir.generators.ModuleGenerator.generateSingleFile(ModuleGenerator.kt:83)
	at org.jetbrains.kotlin.psi2ir.generators.ModuleGenerator.generateModuleFragment(ModuleGenerator.kt:50)
	at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:81)
	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:106)
	at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:595)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:211)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:154)
	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:286)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:111)
	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.GeneratedMethodAccessor111.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(AccessController.java:774)
	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.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$84/0x0000000000000000.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:708)
	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:836)
Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.collections.CollectionsKt___CollectionsKt.joinToString, parameter $this$joinToString
	at kotlin.collections.CollectionsKt___CollectionsKt.joinToString(_Collections.kt)
	at kotlin.collections.CollectionsKt___CollectionsKt.joinToString$default(_Collections.kt:3340)
	at org.jetbrains.kotlin.ir.util.RenderIrElementVisitor.visitClass(RenderIrElement.kt:459)
	at org.jetbrains.kotlin.ir.util.RenderIrElementVisitor.visitClass(RenderIrElement.kt:30)
	at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:55)
	at org.jetbrains.kotlin.ir.util.RenderIrElementKt.render(RenderIrElement.kt:28)
	at org.jetbrains.kotlin.ir.symbols.impl.IrBindablePublicSymbolBase.bind(IrPublicSymbolBase.kt:51)
	at org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl.<init>(IrClassImpl.kt:46)
	at org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl.createClass(IrFactoryImpl.kt:50)
	at org.jetbrains.kotlin.ir.util.DescriptorToIrUtilKt.createIrClassFromDescriptor(DescriptorToIrUtil.kt:39)
	at org.jetbrains.kotlin.psi2ir.generators.ClassGenerator$generateClass$1.invoke(ClassGenerator.kt:91)
	at org.jetbrains.kotlin.psi2ir.generators.ClassGenerator$generateClass$1.invoke(ClassGenerator.kt:90)
	at org.jetbrains.kotlin.ir.util.SymbolTable.declareClass(SymbolTable.kt:1221)
	at org.jetbrains.kotlin.psi2ir.generators.ClassGenerator.generateClass(ClassGenerator.kt:90)
	at org.jetbrains.kotlin.psi2ir.generators.ClassGenerator.generateClass$default(ClassGenerator.kt:83)
	at org.jetbrains.kotlin.psi2ir.generators.DeclarationGenerator.generateClassOrObjectDeclaration(DeclarationGenerator.kt:104)
	at org.jetbrains.kotlin.psi2ir.generators.DeclarationGenerator.generateMemberDeclaration(DeclarationGenerator.kt:53)
	... 38 more

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
vRallevcommented, Apr 13, 2021

I tested 1.5.0-M2 and still was able to reproduce the issue, but not so anymore with 1.5.0-RC 🎉 Because Anvil is ready for the IR backend and the issue within Kotlin is resolved I’ll also close this ticket.

1reaction
sanginovscommented, Apr 2, 2021

clean build and re-run should resolve this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Backend Internal error: Exception during psi2ir in Jetpack ...
This issue is occurring cause the styleCss string is a collection of more than 100+ small strings which are being appended together to ......
Read more >
org.jetbrains.kotlin.backend.common.BackendException
It keeps pointing to this script but it has no issues. org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during psi2ir ...
Read more >
[Solved]-Backend Internal error: Exception during psi2ir-kotlin
Why am I getting Backend Internal error: "Exception during IR lowering error" when using Jetpack Compose clickable-Modifier? ... Back-End (JVM) internal error.
Read more >
I keep getting "Backend Internal error: Exception during IR ...
I keep getting "Backend Internal error: Exception during IR lowering" when trying to serialize a data class to json string.
Read more >
Backend Internal error: Exception during psi2ir - AndroidBugFix
Backend Internal error : Exception during psi2ir ... null: KtCallExpression: kodein() at org.jetbrains.kotlin.backend.common.CodegenUtil.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found