Skip to content

Commit

Permalink
Fix KAPT stub for useJvmIr=Falsewq
Browse files Browse the repository at this point in the history
  • Loading branch information
Jingbo Yang committed Jan 10, 2024
1 parent 300702a commit ceb0632
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 1 addition & 4 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 ceb0632

Please sign in to comment.