From 93e6135e7d1981ae921b392734c4d123abf6a162 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Wed, 26 Aug 2026 12:42:19 +0200 Subject: [PATCH 1/7] Kotlin: add 2.4.20-RC artifacts Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- MODULE.bazel | 3 +++ java/kotlin-extractor/deps/kotlin-compiler-2.4.20-RC.jar | 3 +++ .../deps/kotlin-compiler-embeddable-2.4.20-RC.jar | 3 +++ java/kotlin-extractor/deps/kotlin-stdlib-2.4.20-RC.jar | 3 +++ 4 files changed, 12 insertions(+) create mode 100644 java/kotlin-extractor/deps/kotlin-compiler-2.4.20-RC.jar create mode 100644 java/kotlin-extractor/deps/kotlin-compiler-embeddable-2.4.20-RC.jar create mode 100644 java/kotlin-extractor/deps/kotlin-stdlib-2.4.20-RC.jar diff --git a/MODULE.bazel b/MODULE.bazel index 17a6936f892c..88b6cc0a17ce 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -276,6 +276,7 @@ use_repo( "kotlin-compiler-2.3.0", "kotlin-compiler-2.3.20", "kotlin-compiler-2.4.0", + "kotlin-compiler-2.4.20-RC", "kotlin-compiler-embeddable-1.8.0", "kotlin-compiler-embeddable-1.9.0-Beta", "kotlin-compiler-embeddable-1.9.20-Beta", @@ -288,6 +289,7 @@ use_repo( "kotlin-compiler-embeddable-2.3.0", "kotlin-compiler-embeddable-2.3.20", "kotlin-compiler-embeddable-2.4.0", + "kotlin-compiler-embeddable-2.4.20-RC", "kotlin-stdlib-1.8.0", "kotlin-stdlib-1.9.0-Beta", "kotlin-stdlib-1.9.20-Beta", @@ -300,6 +302,7 @@ use_repo( "kotlin-stdlib-2.3.0", "kotlin-stdlib-2.3.20", "kotlin-stdlib-2.4.0", + "kotlin-stdlib-2.4.20-RC", ) go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk") diff --git a/java/kotlin-extractor/deps/kotlin-compiler-2.4.20-RC.jar b/java/kotlin-extractor/deps/kotlin-compiler-2.4.20-RC.jar new file mode 100644 index 000000000000..8e5a4c945250 --- /dev/null +++ b/java/kotlin-extractor/deps/kotlin-compiler-2.4.20-RC.jar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e2e10f209ef5a63ed70d04ab5c64a8cf346c323f356eb4241ce34ee03cf2e53 +size 60184229 diff --git a/java/kotlin-extractor/deps/kotlin-compiler-embeddable-2.4.20-RC.jar b/java/kotlin-extractor/deps/kotlin-compiler-embeddable-2.4.20-RC.jar new file mode 100644 index 000000000000..4a7601447f96 --- /dev/null +++ b/java/kotlin-extractor/deps/kotlin-compiler-embeddable-2.4.20-RC.jar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fac41bf816409462e189b41b87c4a8dfb48b995b4d8d6271968d4f638ceab255 +size 58593000 diff --git a/java/kotlin-extractor/deps/kotlin-stdlib-2.4.20-RC.jar b/java/kotlin-extractor/deps/kotlin-stdlib-2.4.20-RC.jar new file mode 100644 index 000000000000..2fb1da42a55a --- /dev/null +++ b/java/kotlin-extractor/deps/kotlin-stdlib-2.4.20-RC.jar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:540bee6d6310863014877cb4df8f087c256b22d0925955d1d20943d706bba524 +size 1853317 From c1b4fe638360d5a8b938b4d7b7f61df481bdeb4d Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Wed, 26 Aug 2026 12:42:19 +0200 Subject: [PATCH 2/7] Kotlin: address KT-85816 Kotlin 2.4.20-RC removes the remaining ComponentRegistrar API under KT-85816. Use an RC-specific registrar that only implements CompilerPluginRegistrar, and package the legacy ComponentRegistrar service only for older compilers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- java/kotlin-extractor/BUILD.bazel | 31 ++++++++++++++++-- .../v_2_4_20-RC/Kotlin2ComponentRegistrar.kt | 32 +++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_20-RC/Kotlin2ComponentRegistrar.kt diff --git a/java/kotlin-extractor/BUILD.bazel b/java/kotlin-extractor/BUILD.bazel index f33949f83914..1b9501e7c142 100644 --- a/java/kotlin-extractor/BUILD.bazel +++ b/java/kotlin-extractor/BUILD.bazel @@ -57,6 +57,10 @@ _compiler_plugin_registrar_service_source = "src/main/resources/META-INF/service _compiler_plugin_registrar_service_target = "META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar" +_component_registrar_service_source = "src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar" + +_component_registrar_service_target = "META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar" + py_binary( name = "generate_dbscheme", srcs = ["generate_dbscheme.py"], @@ -68,7 +72,10 @@ _resources = [ r[len("src/main/resources/"):], ) for r in glob(["src/main/resources/**"]) - if r != _compiler_plugin_registrar_service_source + if r not in ( + _compiler_plugin_registrar_service_source, + _component_registrar_service_source, + ) ] _compiler_plugin_registrar_service = ( @@ -76,6 +83,11 @@ _compiler_plugin_registrar_service = ( _compiler_plugin_registrar_service_target, ) +_component_registrar_service = ( + _component_registrar_service_source, + _component_registrar_service_target, +) + kt_javac_options( name = "javac-options", release = "8", @@ -93,7 +105,9 @@ kt_javac_options( "kotlin.RequiresOptIn", "org.jetbrains.kotlin.ir.symbols.%s" % ("IrSymbolInternals" if version_less(v, "2.0.0") else "UnsafeDuringIrConstructionAPI"), - ] + ([] if version_less(v, "2.2.20") else ["org.jetbrains.kotlin.DeprecatedForRemovalCompilerApi"]), + ] + ( + [] if version_less(v, "2.2.20") else ["org.jetbrains.kotlin.DeprecatedForRemovalCompilerApi"] + ), x_suppress_version_warnings = True, ), # * extractor.name is different for each version, so we need to put it in different output dirs @@ -103,6 +117,8 @@ kt_javac_options( name = "resources-%s" % v, srcs = [src for src, _ in _resources] + ( [_compiler_plugin_registrar_service[0]] if not version_less(v, "2.4.0") else [] + ) + ( + [_component_registrar_service[0]] if version_less(v, "2.4.20") else [] ), outs = [ "%s/com/github/codeql/extractor.name" % v, @@ -114,6 +130,11 @@ kt_javac_options( v, _compiler_plugin_registrar_service[1], )] if not version_less(v, "2.4.0") else [] + ) + ( + ["%s/%s" % ( + v, + _component_registrar_service[1], + )] if version_less(v, "2.4.20") else [] ), cmd = "\n".join([ "echo %s-%s > $(RULEDIR)/%s/com/github/codeql/extractor.name" % (_extractor_name_prefix, v, v), @@ -126,6 +147,12 @@ kt_javac_options( v, _compiler_plugin_registrar_service[1], )] if not version_less(v, "2.4.0") else [] + ) + ( + ["cp $(execpath %s) $(RULEDIR)/%s/%s" % ( + _component_registrar_service[0], + v, + _component_registrar_service[1], + )] if version_less(v, "2.4.20") else [] )), ), kt_jvm_library( diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_20-RC/Kotlin2ComponentRegistrar.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_20-RC/Kotlin2ComponentRegistrar.kt new file mode 100644 index 000000000000..f5091752633c --- /dev/null +++ b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_20-RC/Kotlin2ComponentRegistrar.kt @@ -0,0 +1,32 @@ +package com.github.codeql + +import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension +import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar +import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi +import org.jetbrains.kotlin.config.CompilerConfiguration + +@OptIn(ExperimentalCompilerApi::class) +abstract class Kotlin2ComponentRegistrar : CompilerPluginRegistrar() { + override val supportsK2: Boolean + get() = true + + override val pluginId: String + get() = "kotlin-extractor" + + private var extensionStorage: CompilerPluginRegistrar.ExtensionStorage? = null + + override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) { + this@Kotlin2ComponentRegistrar.extensionStorage = this + doRegisterExtensions(configuration) + } + + abstract fun doRegisterExtensions(configuration: CompilerConfiguration) + + protected fun registerExtractorExtension(extension: IrGenerationExtension) { + val storage = extensionStorage + ?: throw IllegalStateException("registerExtractorExtension called before registerExtensions") + with(storage) { + IrGenerationExtension.registerExtension(extension) + } + } +} From 0724cafd30ff38a42025a58bc12c0a3d9380b9ec Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Wed, 26 Aug 2026 12:42:31 +0200 Subject: [PATCH 3/7] Kotlin: address KT-86046 Kotlin 2.4.20-RC marks public K1 APIs with K1Deprecation under KT-86046 and rejects the previous repeatable-annotation IR access path. Opt in to K1Deprecation for 2.4.20 and later, and use the existing annotationClass compatibility extension. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- java/kotlin-extractor/BUILD.bazel | 2 ++ java/kotlin-extractor/src/main/kotlin/MetaAnnotationSupport.kt | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/java/kotlin-extractor/BUILD.bazel b/java/kotlin-extractor/BUILD.bazel index 1b9501e7c142..fae93f6a2cc4 100644 --- a/java/kotlin-extractor/BUILD.bazel +++ b/java/kotlin-extractor/BUILD.bazel @@ -107,6 +107,8 @@ kt_javac_options( ("IrSymbolInternals" if version_less(v, "2.0.0") else "UnsafeDuringIrConstructionAPI"), ] + ( [] if version_less(v, "2.2.20") else ["org.jetbrains.kotlin.DeprecatedForRemovalCompilerApi"] + ) + ( + [] if version_less(v, "2.4.20") else ["org.jetbrains.kotlin.K1Deprecation"] ), x_suppress_version_warnings = True, ), diff --git a/java/kotlin-extractor/src/main/kotlin/MetaAnnotationSupport.kt b/java/kotlin-extractor/src/main/kotlin/MetaAnnotationSupport.kt index e215b5ca31da..d5650389448d 100644 --- a/java/kotlin-extractor/src/main/kotlin/MetaAnnotationSupport.kt +++ b/java/kotlin-extractor/src/main/kotlin/MetaAnnotationSupport.kt @@ -96,8 +96,7 @@ class MetaAnnotationSupport( val metaAnnotations = annotationClass.annotations val jvmRepeatable = metaAnnotations.find { - it.symbol.owner.parentAsClass.fqNameWhenAvailable == - JvmAnnotationNames.REPEATABLE_ANNOTATION + it.annotationClass.fqNameWhenAvailable == JvmAnnotationNames.REPEATABLE_ANNOTATION } return if (jvmRepeatable != null) { ((jvmRepeatable.codeQlGetValueArgument(0) as? IrClassReference)?.symbol as? IrClassSymbol) From 96ac5ba6cbcf82b49a56385993a8586f203d4538 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Wed, 26 Aug 2026 12:42:32 +0200 Subject: [PATCH 4/7] Kotlin: preserve generated forwarder locations Kotlin 2.4.20-RC assigns synthetic source offsets to generated interface forwarders. Use the enclosing class location for each fabricated forwarder and its generated body and accesses, preserving existing database and query output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../src/main/kotlin/KotlinFileExtractor.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index 0b975d9b829b..bef2b554d7ec 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt @@ -1645,8 +1645,9 @@ open class KotlinFileExtractor( extractMethodAndParameterTypeAccesses: Boolean, typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List? - ) : Label = - forceExtractFunction( + ) : Label { + val sourceLoc = tw.getLocation(f.parentClassOrNull ?: f) + return forceExtractFunction( f, parentId, extractBody = false, @@ -1656,6 +1657,7 @@ open class KotlinFileExtractor( classTypeArgsIncludingOuterClasses, overriddenAttributes = OverriddenFunctionAttributes( + sourceLoc = sourceLoc, visibility = DescriptorVisibilities.PUBLIC, modality = Modality.OPEN ) @@ -1666,7 +1668,6 @@ open class KotlinFileExtractor( CompilerGeneratedKinds.INTERFACE_FORWARDER.kind ) if (extractBody) { - val realFunctionLocId = tw.getLocation(f) val inheritedDefaultFunction = f.realOverrideTarget val directlyInheritedSymbol = when (f) { @@ -1686,10 +1687,10 @@ open class KotlinFileExtractor( (directlyInheritedSymbol.owner.parentClassOrNull ?: return functionId) .typeWith() - extractExpressionBody(functionId, realFunctionLocId).also { returnId -> + extractExpressionBody(functionId, sourceLoc).also { returnId -> extractRawMethodAccess( f, - realFunctionLocId, + sourceLoc, f.returnType, functionId, returnId, @@ -1702,7 +1703,7 @@ open class KotlinFileExtractor( extractVariableAccess( syntheticParamId, param.type, - realFunctionLocId, + sourceLoc, argParentId, idxOffset + idx, functionId, @@ -1718,7 +1719,7 @@ open class KotlinFileExtractor( callId, -1, returnId, - realFunctionLocId + sourceLoc ) }, null @@ -1726,6 +1727,7 @@ open class KotlinFileExtractor( } } } + } private fun extractFunction( f: IrFunction, From 8b8b96175ab27f94ca3209a3a4451db2718fdbbb Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Wed, 26 Aug 2026 12:42:32 +0200 Subject: [PATCH 5/7] Kotlin: enable 2.4.20-RC support Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- java/kotlin-extractor/versions.bzl | 1 + .../diagnostics/kotlin-version-too-new/diagnostics.expected | 2 +- .../fake-kotlinc-source/kotlin/KotlinVersion.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/java/kotlin-extractor/versions.bzl b/java/kotlin-extractor/versions.bzl index f9642c96b788..f31d69b2a226 100644 --- a/java/kotlin-extractor/versions.bzl +++ b/java/kotlin-extractor/versions.bzl @@ -12,6 +12,7 @@ VERSIONS = [ "2.3.0", "2.3.20", "2.4.0", + "2.4.20-RC", ] def _version_to_tuple(v): diff --git a/java/ql/integration-tests/kotlin/all-platforms/diagnostics/kotlin-version-too-new/diagnostics.expected b/java/ql/integration-tests/kotlin/all-platforms/diagnostics/kotlin-version-too-new/diagnostics.expected index 09429027c5d6..613709bfb152 100644 --- a/java/ql/integration-tests/kotlin/all-platforms/diagnostics/kotlin-version-too-new/diagnostics.expected +++ b/java/ql/integration-tests/kotlin/all-platforms/diagnostics/kotlin-version-too-new/diagnostics.expected @@ -1,5 +1,5 @@ { - "markdownMessage": "The Kotlin version installed (`999.999.999`) is too recent for this version of CodeQL. Install a version lower than 2.4.20.", + "markdownMessage": "The Kotlin version installed (`2.4.20`) is too recent for this version of CodeQL. Install a version lower than 2.4.20.", "severity": "error", "source": { "extractorName": "java", diff --git a/java/ql/integration-tests/kotlin/all-platforms/diagnostics/kotlin-version-too-new/fake-kotlinc-source/kotlin/KotlinVersion.java b/java/ql/integration-tests/kotlin/all-platforms/diagnostics/kotlin-version-too-new/fake-kotlinc-source/kotlin/KotlinVersion.java index e4bd4ecb7e10..523d7e1d0d87 100644 --- a/java/ql/integration-tests/kotlin/all-platforms/diagnostics/kotlin-version-too-new/fake-kotlinc-source/kotlin/KotlinVersion.java +++ b/java/ql/integration-tests/kotlin/all-platforms/diagnostics/kotlin-version-too-new/fake-kotlinc-source/kotlin/KotlinVersion.java @@ -2,6 +2,6 @@ public class KotlinVersion { - public static String CURRENT = "999.999.999"; + public static String CURRENT = "2.4.20"; } From f146aa6601a99ca0a4e514c9ea83c2153dad911b Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Wed, 26 Aug 2026 12:42:33 +0200 Subject: [PATCH 6/7] Kotlin: make 2.4.20-RC the test default Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- java/kotlin-extractor/dev/wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/kotlin-extractor/dev/wrapper.py b/java/kotlin-extractor/dev/wrapper.py index 1b29de23f766..8c795418f67e 100755 --- a/java/kotlin-extractor/dev/wrapper.py +++ b/java/kotlin-extractor/dev/wrapper.py @@ -27,7 +27,7 @@ import io import os -DEFAULT_VERSION = "2.4.10" +DEFAULT_VERSION = "2.4.20-RC" def options(): From b9c81d5898aac5b2f2ac184caeff36a6a19f3922 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Wed, 26 Aug 2026 12:42:33 +0200 Subject: [PATCH 7/7] Kotlin: document preliminary 2.4.20-RC support Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/codeql/reusables/supported-versions-compilers.rst | 3 ++- java/ql/lib/change-notes/2026-08-21-kotlin-2.4.20.md | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 java/ql/lib/change-notes/2026-08-21-kotlin-2.4.20.md diff --git a/docs/codeql/reusables/supported-versions-compilers.rst b/docs/codeql/reusables/supported-versions-compilers.rst index 8651fa91a269..4fc5c5919285 100644 --- a/docs/codeql/reusables/supported-versions-compilers.rst +++ b/docs/codeql/reusables/supported-versions-compilers.rst @@ -21,7 +21,7 @@ Java,"Java 7 to 26 [5]_","javac (OpenJDK and Oracle JDK), Eclipse compiler for Java (ECJ) [6]_",``.java`` - Kotlin,"Kotlin 1.8.0 to 2.4.1\ *x*","kotlinc",``.kt`` + Kotlin [13]_,"Kotlin 1.8.0 to 2.4.20-RC","kotlinc",``.kt`` JavaScript,ECMAScript 2022 or lower,Not applicable,"``.js``, ``.jsx``, ``.mjs``, ``.es``, ``.es6``, ``.htm``, ``.html``, ``.xhtm``, ``.xhtml``, ``.vue``, ``.hbs``, ``.ejs``, ``.njk``, ``.json``, ``.yaml``, ``.yml``, ``.raml``, ``.xml`` [7]_" Python [8]_,"2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, 3.14",Not applicable,``.py`` Ruby,"up to 3.3",Not applicable,"``.rb``, ``.erb``, ``.gemspec``, ``Gemfile``" @@ -43,3 +43,4 @@ .. [10] Support for the analysis of Swift requires macOS. .. [11] Embedded Swift is not supported. .. [12] TypeScript analysis is performed by running the JavaScript extractor with TypeScript enabled. This is the default. + .. [13] Support for Kotlin 2.4.20-RC is preliminary. diff --git a/java/ql/lib/change-notes/2026-08-21-kotlin-2.4.20.md b/java/ql/lib/change-notes/2026-08-21-kotlin-2.4.20.md new file mode 100644 index 000000000000..15ae8bc3dbdd --- /dev/null +++ b/java/ql/lib/change-notes/2026-08-21-kotlin-2.4.20.md @@ -0,0 +1,4 @@ +--- +category: minorAnalysis +--- +* Preliminary support for Kotlin 2.4.20-RC has been added.