diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinExtractorComponentRegistrar.kt b/java/kotlin-extractor/src/main/kotlin/KotlinExtractorComponentRegistrar.kt index 7fd6416dcd62..81e3c2bba360 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinExtractorComponentRegistrar.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinExtractorComponentRegistrar.kt @@ -4,6 +4,7 @@ package com.github.codeql import com.intellij.mock.MockProject +import com.intellij.openapi.extensions.LoadingOrder import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension import org.jetbrains.kotlin.config.CompilerConfiguration @@ -16,14 +17,18 @@ class KotlinExtractorComponentRegistrar : Kotlin2ComponentRegistrar() { if (invocationTrapFile == null) { throw Exception("Required argument for TRAP invocation file not given") } - IrGenerationExtension.registerExtension( - project, + // Register with LoadingOrder.LAST to ensure the extractor runs after other + // IR generation plugins (like kotlinx.serialization) have generated their code. + val extensionPoint = project.extensionArea.getExtensionPoint(IrGenerationExtension.extensionPointName) + extensionPoint.registerExtension( KotlinExtractorExtension( invocationTrapFile, configuration[KEY_CHECK_TRAP_IDENTICAL] ?: false, configuration[KEY_COMPILATION_STARTTIME], configuration[KEY_EXIT_AFTER_EXTRACTION] ?: false - ) + ), + LoadingOrder.LAST, + project ) } } diff --git a/java/ql/lib/change-notes/2026-01-26-kotlin-extractor-load-last.md b/java/ql/lib/change-notes/2026-01-26-kotlin-extractor-load-last.md new file mode 100644 index 000000000000..e6b496073b9c --- /dev/null +++ b/java/ql/lib/change-notes/2026-01-26-kotlin-extractor-load-last.md @@ -0,0 +1,4 @@ +--- +category: fix +--- +* Kotlin: The Kotlin extractor now registers as the last IR generation extension, ensuring that code generated by other compiler plugins (such as kotlinx.serialization) is correctly captured.