Skip to content

Commit

Permalink
Fix KAPT stub for useJvmIr=False
Browse files Browse the repository at this point in the history
  • Loading branch information
Jingbo Yang committed Jan 11, 2024
1 parent 68ca571 commit 19a3dac
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,13 @@ class GenerationState private constructor(

@Suppress("UNCHECKED_CAST", "DEPRECATION_ERROR")
private fun loadClassBuilderInterceptors(): List<org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension> {
// KAPT with useJvmIr=False (non-Ir backend) can't use ClassBuilderExtensionAdapter
// Anything that's not JvmIrDeclarationOrigin became NO_ORIGIN after ClassBuilderExtensionAdapter's
// unwrapOrigin() and wrapToOrigin(), causing it to lose necessary information for KAPT stub generation.
if (!isIrBackend) {
return org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension.getInstances(project)
}

// Using Class.forName here because we're in the old JVM backend, and we need to load extensions declared in the JVM IR backend.
val adapted = Class.forName("org.jetbrains.kotlin.backend.jvm.extensions.ClassBuilderExtensionAdapter")
.getDeclaredMethod("getExtensions", Project::class.java)
Expand Down

0 comments on commit 19a3dac

Please sign in to comment.