Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KT-64882 Fix KAPT stub for useJvmIr=False #5242

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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