Skip to content

Kotlin support 2.4.0 and drop 1.x test mode#21970

Open
andersfugmann wants to merge 3 commits into
mainfrom
andersfugmann/kotlin-2.4-v2
Open

Kotlin support 2.4.0 and drop 1.x test mode#21970
andersfugmann wants to merge 3 commits into
mainfrom
andersfugmann/kotlin-2.4-v2

Conversation

@andersfugmann

Copy link
Copy Markdown
Contributor

Drop Kotlin 1.x test mode to 2.0, add Kotlin 2.4.0 extractor compatibility, and keep only required expected file updates. Known K2 mixed Java/Kotlin differences are tracked in https://github.com/github/codeql-kotlin-team/issues/196.

andersfugmann and others added 2 commits June 11, 2026 09:27
Kotlin 2.4.0 removes -language-version 1.9, so tests and support bounds move to 2.0.\n\nExpected output updates include pre-existing K2 differences in mixed Java/Kotlin scenarios, tracked in github/codeql-kotlin-team#196.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add 2.4.0 compiler artifacts and API compatibility shims, including updated plugin registration and version-agnostic IR accessors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 11, 2026 07:34
@andersfugmann andersfugmann requested review from a team as code owners June 11, 2026 07:34
@andersfugmann

Copy link
Copy Markdown
Contributor Author

Result-loss analysis: all changed failing tests were reproduced in Kotlin 2.0 mode, avoidable losses were addressed, and remaining differences are the pre-existing K2 mixed Java/Kotlin callable-binding issue tracked at https://github.com/github/codeql-kotlin-team/issues/196 and discussed in prior thread.

@andersfugmann

Copy link
Copy Markdown
Contributor Author

/qlucie

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the Java/Kotlin extractor and its test infrastructure to support Kotlin 2.4.0, while dropping Kotlin 1.x support (minimum Kotlin version becomes 2.0.0) and updating baselines/docs accordingly.

Changes:

  • Add Kotlin 2.4.0 compiler/stdlib dependencies and extractor compatibility shims for Kotlin IR API changes in 2.4.0.
  • Switch Kotlin integration tests that previously used Kotlin 1.x language mode to use -language-version 2.0, and update expected outputs.
  • Update docs and change notes to reflect the new supported Kotlin version range and deprecation of Kotlin < 2.0.
Show a summary per file
File Description
MODULE.bazel Adds Bazel repos for Kotlin 2.4.0 compiler/embeddable/stdlib artifacts.
java/ql/test/query-tests/security/CWE-312/android/CleartextStorage/DB-CHECK.expected Updated test baseline output (dbcheck).
java/ql/test/query-tests/security/CWE-312/android/CleartextStorage/CleartextStorageSharedPrefsTest.expected Updated test baseline output.
java/ql/test/library-tests/pathsanitizer/test.expected Updated test baseline output.
java/ql/test/library-tests/pathsanitizer/DB-CHECK.expected Updated test baseline output (dbcheck).
java/ql/lib/change-notes/2026-06-08-kotlin-drop-1x.md Adds change note deprecating Kotlin < 2.0.
java/ql/lib/change-notes/2026-06-04-kotlin-2.4.0.md Adds change note for Kotlin 2.4.0 support.
java/ql/integration-tests/kotlin/all-platforms/kotlin_java_lowering_wildcards/test.py Moves test compilation to -language-version 2.0.
java/ql/integration-tests/kotlin/all-platforms/kotlin_java_lowering_wildcards/test.expected Updates expected output for wildcard lowering changes.
java/ql/integration-tests/kotlin/all-platforms/kotlin_java_lowering_wildcards/DB-CHECK.expected Updated test baseline output (dbcheck).
java/ql/integration-tests/kotlin/all-platforms/java-interface-redeclares-tostring/test.py Moves test compilation to -language-version 2.0.
java/ql/integration-tests/kotlin/all-platforms/java-interface-redeclares-tostring/test.expected Updates expected output for interface toString redeclare scenario.
java/ql/integration-tests/kotlin/all-platforms/file_classes/test.py Moves test compilation to -language-version 2.0.
java/ql/integration-tests/kotlin/all-platforms/file_classes/classes.expected Updates expected class extraction output.
java/ql/integration-tests/kotlin/all-platforms/extractor_information_kotlin1/test.py Moves test compilation to -language-version 2.0.
java/ql/integration-tests/kotlin/all-platforms/extractor_information_kotlin1/ExtractorInformation.expected Updates expected extractor info (Uses Kotlin 2 flag).
java/ql/integration-tests/kotlin/all-platforms/external-property-overloads/test.py Moves test compilation to -language-version 2.0.
java/ql/integration-tests/kotlin/all-platforms/external-property-overloads/test.expected Updates expected external binary location formatting.
java/ql/integration-tests/kotlin/all-platforms/enhanced-nullability/test.py Moves test compilation to -language-version 2.0.
java/ql/integration-tests/kotlin/all-platforms/enhanced-nullability/test.expected Updates expected output for enhanced nullability extraction.
java/ql/integration-tests/kotlin/all-platforms/enhanced-nullability/DB-CHECK.expected Updated test baseline output (dbcheck).
java/ql/integration-tests/kotlin/all-platforms/diagnostics/kotlin-version-too-new/diagnostics.expected Updates max-supported-version diagnostic message.
java/kotlin-extractor/versions.bzl Adds 2.4.0 to supported versions list; adjusts language-version mapping.
java/kotlin-extractor/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar Adds service registration for Kotlin 2.4+ compiler plugin registrar.
java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_0/parameterIndexExcludingReceivers.kt Adds Kotlin 2.4.0-specific parameter indexing logic (handles new receiver kinds).
java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_0/Kotlin2ComponentRegistrar.kt Introduces Kotlin 2.4.0 CompilerPluginRegistrar-based registration path.
java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_0/IrCompat.kt Adds Kotlin 2.4.0 IR compatibility accessors for removed APIs.
java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_9_0-Beta/Kotlin2ComponentRegistrar.kt Refactors older registrar to route through doRegisterExtensions and centralize extension registration.
java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/Kotlin2ComponentRegistrar.kt Refactors older registrar to route through doRegisterExtensions.
java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/IrCompat.kt Adds pre-2.4.0 IR compatibility wrappers matching the new shim API.
java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt Switches annotation handling to compatibility wrappers (codeQlAddAnnotations / codeQlAnnotationFromSymbolOwner).
java/kotlin-extractor/src/main/kotlin/utils/JvmNames.kt Switches annotation argument access to compatibility wrappers.
java/kotlin-extractor/src/main/kotlin/TrapWriter.kt Switches extension receiver access to compatibility wrapper.
java/kotlin-extractor/src/main/kotlin/MetaAnnotationSupport.kt Switches IR annotation construction/mutation to compatibility wrappers.
java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt Switches parameter/receiver access to compatibility wrappers.
java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt Switches multiple IR access patterns to compatibility wrappers; updates related comment/docs.
java/kotlin-extractor/src/main/kotlin/KotlinExtractorComponentRegistrar.kt Refactors registrar to use doRegisterExtensions and centralized extension registration.
java/kotlin-extractor/src/main/kotlin/comments/CommentExtractor.kt Switches extension receiver detection to compatibility wrapper.
java/kotlin-extractor/dev/wrapper.py Bumps default wrapper Kotlin version to 2.4.0.
java/kotlin-extractor/deps/kotlin-stdlib-2.4.0.jar Adds Kotlin 2.4.0 stdlib (LFS pointer).
java/kotlin-extractor/deps/kotlin-compiler-embeddable-2.4.0.jar Adds Kotlin 2.4.0 embeddable compiler (LFS pointer).
java/kotlin-extractor/deps/kotlin-compiler-2.4.0.jar Adds Kotlin 2.4.0 compiler (LFS pointer).
java/kotlin-extractor/BUILD.bazel Conditionally packages CompilerPluginRegistrar service file for Kotlin >= 2.4.0.
docs/codeql/reusables/supported-versions-compilers.rst Updates documented supported Kotlin version range to 2.0.0–2.4.x.

Copilot's findings

  • Files reviewed: 44/44 changed files
  • Comments generated: 4

Comment on lines 7810 to 7812
* this.dispatchReceiver = dispatchReceiver
* this.extensionReceiver = extensionReceiver
* this.codeQlExtensionReceiver = extensionReceiver
* }
Comment on lines 11 to 15
"2.2.20-Beta2",
"2.3.0",
"2.3.20",
"2.4.0",
]
@andersfugmann

Copy link
Copy Markdown
Contributor Author

Current red Qlucie checks are caused by semmle-code workflow jobs still invoking just kotlin language-tests-1 (which runs test-kotlin1 with -language-version 1.9, now unsupported by Kotlin 2.4).\n\nI have the corresponding workflow updates in semmle-code PR https://github.com/github/semmle-code/pull/55714 (extras jobs only run language-tests-2). After that dependency lands, rerunning /qlucie on this PR should clear these failures.

Align Kotlin 2.4 registrar plugin id with command-line processor, drop unused registrar state, fix the function-reference explanatory comment, and remove 1.x extractor targets from VERSIONS.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@andersfugmann

Copy link
Copy Markdown
Contributor Author

/qlucie

@andersfugmann

Copy link
Copy Markdown
Contributor Author

Addressed review feedback in commit e50e0b5. Updated the Kotlin 2.4 registrar plugin id to kotlin-extractor, removed unused registrar state, fixed the FunctionReference explanatory comment to use extensionReceiver, and removed Kotlin 1.x entries from java/kotlin-extractor/versions.bzl (with MODULE.bazel regenerated via bazel mod tidy). Local validation: tools/bazel build target many and the enhanced-nullability Kotlin integration test pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants