Skip to content

Kotlin: add Kotlin 2.4.0 support - #21970

Merged
jketema merged 4 commits into
mainfrom
andersfugmann/kotlin-2.4-v2
Jun 24, 2026
Merged

Kotlin: add Kotlin 2.4.0 support#21970
jketema merged 4 commits into
mainfrom
andersfugmann/kotlin-2.4-v2

Conversation

@andersfugmann

@andersfugmannandersfugmann commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Add extractor support for Kotlin 2.4.0 and adjust the integration tests that depend on a pre-2.4 compiler.

Changes

  • Extractor support for 2.4.0. Adds the Kotlin 2.4.0 compiler-plugin variant (component registrar, IR compatibility shims, and version-specific utilities), bundles the 2.4.0 compiler dependencies, updates the build wiring (BUILD.bazel, versions.bzl, MODULE.bazel, dev/wrapper.py), refreshes the supported-versions documentation, and raises the "Kotlin version too new" diagnostic bound from 2.3.30 to 2.4.10.
  • Mark kotlin1 integration tests. Six integration tests pass -language-version 1.9, which Kotlin 2.4 no longer accepts. They are marked with @pytest.mark.kotlin1 so CI can run them on a pinned pre-2.4 compiler.

Notes

  • This PR does not change query results: the only expected-file change is the version bound in the kotlin-version-too-new diagnostic.
  • The known K2 mixed Java/Kotlin extractor differences (which become visible once -language-version 1.9 is no longer available) are a needed follow-up investigation.

CopilotAI 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
FileDescription
MODULE.bazelAdds Bazel repos for Kotlin 2.4.0 compiler/embeddable/stdlib artifacts.
java/ql/test/query-tests/security/CWE-312/android/CleartextStorage/DB-CHECK.expectedUpdated test baseline output (dbcheck).
java/ql/test/query-tests/security/CWE-312/android/CleartextStorage/CleartextStorageSharedPrefsTest.expectedUpdated test baseline output.
java/ql/test/library-tests/pathsanitizer/test.expectedUpdated test baseline output.
java/ql/test/library-tests/pathsanitizer/DB-CHECK.expectedUpdated test baseline output (dbcheck).
java/ql/lib/change-notes/2026-06-08-kotlin-drop-1x.mdAdds change note deprecating Kotlin < 2.0.
java/ql/lib/change-notes/2026-06-04-kotlin-2.4.0.mdAdds change note for Kotlin 2.4.0 support.
java/ql/integration-tests/kotlin/all-platforms/kotlin_java_lowering_wildcards/test.pyMoves test compilation to -language-version 2.0.
java/ql/integration-tests/kotlin/all-platforms/kotlin_java_lowering_wildcards/test.expectedUpdates expected output for wildcard lowering changes.
java/ql/integration-tests/kotlin/all-platforms/kotlin_java_lowering_wildcards/DB-CHECK.expectedUpdated test baseline output (dbcheck).
java/ql/integration-tests/kotlin/all-platforms/java-interface-redeclares-tostring/test.pyMoves test compilation to -language-version 2.0.
java/ql/integration-tests/kotlin/all-platforms/java-interface-redeclares-tostring/test.expectedUpdates expected output for interface toString redeclare scenario.
java/ql/integration-tests/kotlin/all-platforms/file_classes/test.pyMoves test compilation to -language-version 2.0.
java/ql/integration-tests/kotlin/all-platforms/file_classes/classes.expectedUpdates expected class extraction output.
java/ql/integration-tests/kotlin/all-platforms/extractor_information_kotlin1/test.pyMoves test compilation to -language-version 2.0.
java/ql/integration-tests/kotlin/all-platforms/extractor_information_kotlin1/ExtractorInformation.expectedUpdates expected extractor info (Uses Kotlin 2 flag).
java/ql/integration-tests/kotlin/all-platforms/external-property-overloads/test.pyMoves test compilation to -language-version 2.0.
java/ql/integration-tests/kotlin/all-platforms/external-property-overloads/test.expectedUpdates expected external binary location formatting.
java/ql/integration-tests/kotlin/all-platforms/enhanced-nullability/test.pyMoves test compilation to -language-version 2.0.
java/ql/integration-tests/kotlin/all-platforms/enhanced-nullability/test.expectedUpdates expected output for enhanced nullability extraction.
java/ql/integration-tests/kotlin/all-platforms/enhanced-nullability/DB-CHECK.expectedUpdated test baseline output (dbcheck).
java/ql/integration-tests/kotlin/all-platforms/diagnostics/kotlin-version-too-new/diagnostics.expectedUpdates max-supported-version diagnostic message.
java/kotlin-extractor/versions.bzlAdds 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.CompilerPluginRegistrarAdds service registration for Kotlin 2.4+ compiler plugin registrar.
java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_0/parameterIndexExcludingReceivers.ktAdds 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.ktIntroduces Kotlin 2.4.0 CompilerPluginRegistrar-based registration path.
java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_0/IrCompat.ktAdds Kotlin 2.4.0 IR compatibility accessors for removed APIs.
java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_9_0-Beta/Kotlin2ComponentRegistrar.ktRefactors older registrar to route through doRegisterExtensions and centralize extension registration.
java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/Kotlin2ComponentRegistrar.ktRefactors older registrar to route through doRegisterExtensions.
java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/IrCompat.ktAdds pre-2.4.0 IR compatibility wrappers matching the new shim API.
java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.ktSwitches annotation handling to compatibility wrappers (codeQlAddAnnotations / codeQlAnnotationFromSymbolOwner).
java/kotlin-extractor/src/main/kotlin/utils/JvmNames.ktSwitches annotation argument access to compatibility wrappers.
java/kotlin-extractor/src/main/kotlin/TrapWriter.ktSwitches extension receiver access to compatibility wrapper.
java/kotlin-extractor/src/main/kotlin/MetaAnnotationSupport.ktSwitches IR annotation construction/mutation to compatibility wrappers.
java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.ktSwitches parameter/receiver access to compatibility wrappers.
java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.ktSwitches multiple IR access patterns to compatibility wrappers; updates related comment/docs.
java/kotlin-extractor/src/main/kotlin/KotlinExtractorComponentRegistrar.ktRefactors registrar to use doRegisterExtensions and centralized extension registration.
java/kotlin-extractor/src/main/kotlin/comments/CommentExtractor.ktSwitches extension receiver detection to compatibility wrapper.
java/kotlin-extractor/dev/wrapper.pyBumps default wrapper Kotlin version to 2.4.0.
java/kotlin-extractor/deps/kotlin-stdlib-2.4.0.jarAdds Kotlin 2.4.0 stdlib (LFS pointer).
java/kotlin-extractor/deps/kotlin-compiler-embeddable-2.4.0.jarAdds Kotlin 2.4.0 embeddable compiler (LFS pointer).
java/kotlin-extractor/deps/kotlin-compiler-2.4.0.jarAdds Kotlin 2.4.0 compiler (LFS pointer).
java/kotlin-extractor/BUILD.bazelConditionally packages CompilerPluginRegistrar service file for Kotlin >= 2.4.0.
docs/codeql/reusables/supported-versions-compilers.rstUpdates 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 threadjava/kotlin-extractor/versions.bzl
@andersfugmann
andersfugmannforce-pushed the andersfugmann/kotlin-2.4-v2 branch 2 times, most recently from 30b0a30 to 547c78fCompareJune 12, 2026 09:53
@andersfugmann
andersfugmann marked this pull request as draft June 12, 2026 14:09
@hfhbdhfhbd mentioned this pull request Jun 13, 2026
andersfugmannand others added 2 commits June 16, 2026 16:24
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>
Mark the integration tests that require a Kotlin 1.x language version
with @pytest.mark.kotlin1 so CI can run them on a pinned pre-2.4
compiler (Kotlin 2.4 no longer accepts -language-version 1.9).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@andersfugmann
andersfugmannforce-pushed the andersfugmann/kotlin-2.4-v2 branch from 79437b8 to 1b785a8CompareJune 16, 2026 14:25
@andersfugmannandersfugmann changed the title Kotlin support 2.4.0 and drop 1.x test modeKotlin: add Kotlin 2.4.0 supportJun 17, 2026
@andersfugmann
andersfugmann marked this pull request as ready for review June 17, 2026 08:16

@jketemajketema 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.

Some comments and questions. Nothing major here.

Comment threadjava/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_0/IrCompat.kt Outdated
Comment threadjava/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_0/IrCompat.kt Outdated
@githubgithub deleted a comment from jketemaJun 18, 2026
Comment threadjava/kotlin-extractor/BUILD.bazel

@jketemajketema 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.

We generally do not leave empty lines between imports in integration tests.

Comment threaddocs/codeql/reusables/supported-versions-compilers.rst Outdated
* Update documentation to only claim support for 2.4.0x
* Python test code; remove newlines between imports.
* Sync comments between kotlin 1.8 and 1.9
* Update code comments to attach where actually relevant,
and improve comments on IrMemberAccessExpression<*>.extensionReceiverParameterIndex()
@andersfugmann

Copy link
Copy Markdown
ContributorAuthor

All but one comment addressed.

@jketemajketema 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.

I'm happy with the changes here. Probably still needs a DCA run?

@redsun82redsun82 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.

LGTM, modulo the comments I gave on the internal PR about the kotlin1 pytest mark

@jketema
jketema merged commit b8c78fd into mainJun 24, 2026
81 of 90 checks passed
@jketema
jketema deleted the andersfugmann/kotlin-2.4-v2 branch June 24, 2026 14:40
GCHOfficial pushed a commit to GCHOfficial/iptvs that referenced this pull request Jun 26, 2026
The Kotlin 2.4.0 extractor support (github/codeql#21970) is merged but not yet
in a released CodeQL CLI — the latest (2.25.6) still caps at < 2.3.30, so the
java-kotlin job fails regardless of action version. Keep the v4 upgrade (off the
deprecated v3 / Node 20) and scope to c-cpp + actions; the comment records the
exact condition to re-add Kotlin.
GCHOfficial added a commit to GCHOfficial/iptvs that referenced this pull request Jun 26, 2026
* ci: CodeQL action v4 + re-add Kotlin
v3 is deprecated (Dec 2026) and runs on the now-deprecated Node 20; its bundled
CodeQL CLI also predated Kotlin 2.4.0 support, which is why java-kotlin failed
with 'Kotlin version 2.4.0 is too recent'. github/codeql#21970 added 2.4.0
support, shipped in v4's CLI — so move init/analyze to @v4 and restore the
java-kotlin matrix entry (build-mode manual via 'flutter build apk').
* ci: keep CodeQL on v4 but drop Kotlin until a CLI ships 2.4.0
The Kotlin 2.4.0 extractor support (github/codeql#21970) is merged but not yet
in a released CodeQL CLI — the latest (2.25.6) still caps at < 2.3.30, so the
java-kotlin job fails regardless of action version. Keep the v4 upgrade (off the
deprecated v3 / Node 20) and scope to c-cpp + actions; the comment records the
exact condition to re-add Kotlin.
---------
Co-authored-by: George-Cosmin Hanta <george-cosmin.hanta@marigoldointment.com>
GCHOfficial added a commit to GCHOfficial/iptvs that referenced this pull request Jul 8, 2026
…e_flutter 2.16.0 (#85)
CodeQL CLI 2.26.0 / codeql-bundle-v2.26.0 (published 2026-07-08) ships the
Kotlin 2.4.0 support merged in github/codeql#21970, so codeql-action@v4 no
longer aborts with "Kotlin version 2.4.0 is too recent". Re-add the
java-kotlin matrix entry (build-mode manual: setup-java temurin 17 +
flutter build apk --debug, checkout with LFS for the libdovi AAR) and
refresh the header comment to document the >= v2.26.0 bundle requirement.
Also bump the Flutter pin 3.44.4 -> 3.44.5 across build/codeql/release
workflows and upgrade supabase_flutter 2.15.4 -> 2.16.0 (supabase 2.14.0,
gotrue 2.26.0, realtime_client 2.11.0, passkeys_platform_interface 2.8.0).
flutter analyze clean; flutter test 141/141 pass.
Closes#32
Claude-Session: https://claude.ai/code/session_01Pf76uZnruw81CCGZo1pQFo
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for freeto 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.

6 participants

@andersfugmann@igfoo@redsun82@hfhbd@jketema