Skip to content

Commit e10743b

Browse files
Kotlin: add extractor support for 2.4.0
Add the Kotlin 2.4.0 compiler plugin variant (component registrar, IR compatibility shims, and version-specific utilities), bundle the 2.4.0 compiler dependencies, and update the build wiring, supported version metadata and the too-new diagnostic bound. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4d70c5f commit e10743b

25 files changed

Lines changed: 506 additions & 171 deletions

MODULE.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ use_repo(
248248
"kotlin-compiler-2.2.20-Beta2",
249249
"kotlin-compiler-2.3.0",
250250
"kotlin-compiler-2.3.20",
251+
"kotlin-compiler-2.4.0",
251252
"kotlin-compiler-embeddable-1.8.0",
252253
"kotlin-compiler-embeddable-1.9.0-Beta",
253254
"kotlin-compiler-embeddable-1.9.20-Beta",
@@ -259,6 +260,7 @@ use_repo(
259260
"kotlin-compiler-embeddable-2.2.20-Beta2",
260261
"kotlin-compiler-embeddable-2.3.0",
261262
"kotlin-compiler-embeddable-2.3.20",
263+
"kotlin-compiler-embeddable-2.4.0",
262264
"kotlin-stdlib-1.8.0",
263265
"kotlin-stdlib-1.9.0-Beta",
264266
"kotlin-stdlib-1.9.20-Beta",
@@ -270,6 +272,7 @@ use_repo(
270272
"kotlin-stdlib-2.2.20-Beta2",
271273
"kotlin-stdlib-2.3.0",
272274
"kotlin-stdlib-2.3.20",
275+
"kotlin-stdlib-2.4.0",
273276
)
274277

275278
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")

docs/codeql/reusables/supported-versions-compilers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
Java,"Java 7 to 26 [6]_","javac (OpenJDK and Oracle JDK),
2222

2323
Eclipse compiler for Java (ECJ) [7]_",``.java``
24-
Kotlin,"Kotlin 1.8.0 to 2.3.2\ *x*","kotlinc",``.kt``
24+
Kotlin,"Kotlin 1.8.0 to 2.4.\ *x*","kotlinc",``.kt``
2525
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`` [8]_"
2626
Python [9]_,"2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13",Not applicable,``.py``
2727
Ruby [10]_,"up to 3.3",Not applicable,"``.rb``, ``.erb``, ``.gemspec``, ``Gemfile``"

java/kotlin-extractor/BUILD.bazel

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ _extractor_name_prefix = "%s-%s" % (
5353
"embeddable" if _for_embeddable else "standalone",
5454
)
5555

56+
_compiler_plugin_registrar_service_source = "src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar"
57+
58+
_compiler_plugin_registrar_service_target = "META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar"
59+
5660
py_binary(
5761
name = "generate_dbscheme",
5862
srcs = ["generate_dbscheme.py"],
@@ -64,8 +68,14 @@ _resources = [
6468
r[len("src/main/resources/"):],
6569
)
6670
for r in glob(["src/main/resources/**"])
71+
if r != _compiler_plugin_registrar_service_source
6772
]
6873

74+
_compiler_plugin_registrar_service = (
75+
_compiler_plugin_registrar_service_source,
76+
_compiler_plugin_registrar_service_target,
77+
)
78+
6979
kt_javac_options(
7080
name = "javac-options",
7181
release = "8",
@@ -91,19 +101,32 @@ kt_javac_options(
91101
# * `resource_strip_prefix` is unique per jar, so we must also put other resources under the same version prefix
92102
genrule(
93103
name = "resources-%s" % v,
94-
srcs = [src for src, _ in _resources],
104+
srcs = [src for src, _ in _resources] + (
105+
[_compiler_plugin_registrar_service[0]] if not version_less(v, "2.4.0") else []
106+
),
95107
outs = [
96108
"%s/com/github/codeql/extractor.name" % v,
97109
] + [
98110
"%s/%s" % (v, target)
99111
for _, target in _resources
100-
],
112+
] + (
113+
["%s/%s" % (
114+
v,
115+
_compiler_plugin_registrar_service[1],
116+
)] if not version_less(v, "2.4.0") else []
117+
),
101118
cmd = "\n".join([
102119
"echo %s-%s > $(RULEDIR)/%s/com/github/codeql/extractor.name" % (_extractor_name_prefix, v, v),
103120
] + [
104121
"cp $(execpath %s) $(RULEDIR)/%s/%s" % (source, v, target)
105122
for source, target in _resources
106-
]),
123+
] + (
124+
["cp $(execpath %s) $(RULEDIR)/%s/%s" % (
125+
_compiler_plugin_registrar_service[0],
126+
v,
127+
_compiler_plugin_registrar_service[1],
128+
)] if not version_less(v, "2.4.0") else []
129+
)),
107130
),
108131
kt_jvm_library(
109132
name = "%s-%s" % (_extractor_name_prefix, v),
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:66e73eacd619c9beb7c22042117af36b443529c4d80237ee82cc4b2acb6f3d0b
3+
size 61902486
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:c2b25e8c1c93ec416ba4327f5e31eaec0f0c8847241b9353e294b8db9dce564f
3+
size 60351320
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:ccb14ff83fabcb11458b798dbc9824748ccdffeec79c9aba789e6ed1cda86b1c
3+
size 1841929

java/kotlin-extractor/dev/wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import io
2828
import os
2929

30-
DEFAULT_VERSION = "2.3.20"
30+
DEFAULT_VERSION = "2.4.0"
3131

3232

3333
def options():

java/kotlin-extractor/src/main/kotlin/KotlinExtractorComponentRegistrar.kt

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,21 @@
33

44
package com.github.codeql
55

6-
import com.intellij.mock.MockProject
7-
import com.intellij.openapi.extensions.LoadingOrder
8-
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
96
import org.jetbrains.kotlin.config.CompilerConfiguration
107

118
class KotlinExtractorComponentRegistrar : Kotlin2ComponentRegistrar() {
12-
override fun registerProjectComponents(
13-
project: MockProject,
14-
configuration: CompilerConfiguration
15-
) {
9+
override fun doRegisterExtensions(configuration: CompilerConfiguration) {
1610
val invocationTrapFile = configuration[KEY_INVOCATION_TRAP_FILE]
1711
if (invocationTrapFile == null) {
1812
throw Exception("Required argument for TRAP invocation file not given")
1913
}
20-
// Register with LoadingOrder.LAST to ensure the extractor runs after other
21-
// IR generation plugins (like kotlinx.serialization) have generated their code.
22-
val extensionPoint = project.extensionArea.getExtensionPoint(IrGenerationExtension.extensionPointName)
23-
extensionPoint.registerExtension(
14+
registerExtractorExtension(
2415
KotlinExtractorExtension(
2516
invocationTrapFile,
2617
configuration[KEY_CHECK_TRAP_IDENTICAL] ?: false,
2718
configuration[KEY_COMPILATION_STARTTIME],
2819
configuration[KEY_EXIT_AFTER_EXTRACTION] ?: false
29-
),
30-
LoadingOrder.LAST,
31-
project
20+
)
3221
)
3322
}
3423
}

0 commit comments

Comments
 (0)