From a42ee98afe44c323917554e6b38e2336f8b0a950 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Thu, 4 Dec 2025 15:56:48 +0100 Subject: [PATCH 01/19] Kotlin: Update kotlin_rules to 2.2.0 and remove support for Kotlin 1.6 and 1.7 --- MODULE.bazel | 14 +----------- .../deps/kotlin-compiler-1.6.0.jar | 3 --- .../deps/kotlin-compiler-1.6.20.jar | 3 --- .../deps/kotlin-compiler-1.7.0.jar | 3 --- .../deps/kotlin-compiler-1.7.20.jar | 3 --- .../deps/kotlin-compiler-embeddable-1.6.0.jar | 3 --- .../kotlin-compiler-embeddable-1.6.20.jar | 3 --- .../deps/kotlin-compiler-embeddable-1.7.0.jar | 3 --- .../kotlin-compiler-embeddable-1.7.20.jar | 3 --- .../deps/kotlin-stdlib-1.6.0.jar | 3 --- .../deps/kotlin-stdlib-1.6.20.jar | 3 --- .../deps/kotlin-stdlib-1.7.0.jar | 3 --- .../deps/kotlin-stdlib-1.7.20.jar | 3 --- java/kotlin-extractor/versions.bzl | 4 ---- .../rules_kotlin/2.1.3-codeql.1/source.json | 9 -------- .../MODULE.bazel | 22 ++++++++++--------- .../codeql_add_language_version_option.patch | 18 +++++++-------- .../patches/codeql_do_not_emit_jdeps.patch | 6 ++--- .../rules_kotlin/2.2.0-codeql.1/source.json | 9 ++++++++ .../modules/rules_kotlin/metadata.json | 2 +- 20 files changed, 33 insertions(+), 87 deletions(-) delete mode 100644 java/kotlin-extractor/deps/kotlin-compiler-1.6.0.jar delete mode 100644 java/kotlin-extractor/deps/kotlin-compiler-1.6.20.jar delete mode 100644 java/kotlin-extractor/deps/kotlin-compiler-1.7.0.jar delete mode 100644 java/kotlin-extractor/deps/kotlin-compiler-1.7.20.jar delete mode 100644 java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.6.0.jar delete mode 100644 java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.6.20.jar delete mode 100644 java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.7.0.jar delete mode 100644 java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.7.20.jar delete mode 100644 java/kotlin-extractor/deps/kotlin-stdlib-1.6.0.jar delete mode 100644 java/kotlin-extractor/deps/kotlin-stdlib-1.6.20.jar delete mode 100644 java/kotlin-extractor/deps/kotlin-stdlib-1.7.0.jar delete mode 100644 java/kotlin-extractor/deps/kotlin-stdlib-1.7.20.jar delete mode 100644 misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/source.json rename misc/bazel/registry/modules/rules_kotlin/{2.1.3-codeql.1 => 2.2.0-codeql.1}/MODULE.bazel (52%) rename misc/bazel/registry/modules/rules_kotlin/{2.1.3-codeql.1 => 2.2.0-codeql.1}/patches/codeql_add_language_version_option.patch (58%) rename misc/bazel/registry/modules/rules_kotlin/{2.1.3-codeql.1 => 2.2.0-codeql.1}/patches/codeql_do_not_emit_jdeps.patch (81%) create mode 100644 misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/source.json diff --git a/MODULE.bazel b/MODULE.bazel index 8ba6c2fcd8c8..3e261fac8f66 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -24,7 +24,7 @@ bazel_dep(name = "bazel_skylib", version = "1.8.1") bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "absl") bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json") bazel_dep(name = "fmt", version = "12.1.0-codeql.1") -bazel_dep(name = "rules_kotlin", version = "2.1.3-codeql.1") +bazel_dep(name = "rules_kotlin", version = "2.2.0-codeql.1") bazel_dep(name = "gazelle", version = "0.40.0") bazel_dep(name = "rules_dotnet", version = "0.21.5-codeql.1") bazel_dep(name = "googletest", version = "1.14.0.bcr.1") @@ -221,10 +221,6 @@ use_repo( kotlin_extractor_deps, "codeql_kotlin_defaults", "codeql_kotlin_embeddable", - "kotlin-compiler-1.6.0", - "kotlin-compiler-1.6.20", - "kotlin-compiler-1.7.0", - "kotlin-compiler-1.7.20", "kotlin-compiler-1.8.0", "kotlin-compiler-1.9.0-Beta", "kotlin-compiler-1.9.20-Beta", @@ -234,10 +230,6 @@ use_repo( "kotlin-compiler-2.1.20-Beta1", "kotlin-compiler-2.2.0-Beta1", "kotlin-compiler-2.2.20-Beta2", - "kotlin-compiler-embeddable-1.6.0", - "kotlin-compiler-embeddable-1.6.20", - "kotlin-compiler-embeddable-1.7.0", - "kotlin-compiler-embeddable-1.7.20", "kotlin-compiler-embeddable-1.8.0", "kotlin-compiler-embeddable-1.9.0-Beta", "kotlin-compiler-embeddable-1.9.20-Beta", @@ -247,10 +239,6 @@ use_repo( "kotlin-compiler-embeddable-2.1.20-Beta1", "kotlin-compiler-embeddable-2.2.0-Beta1", "kotlin-compiler-embeddable-2.2.20-Beta2", - "kotlin-stdlib-1.6.0", - "kotlin-stdlib-1.6.20", - "kotlin-stdlib-1.7.0", - "kotlin-stdlib-1.7.20", "kotlin-stdlib-1.8.0", "kotlin-stdlib-1.9.0-Beta", "kotlin-stdlib-1.9.20-Beta", diff --git a/java/kotlin-extractor/deps/kotlin-compiler-1.6.0.jar b/java/kotlin-extractor/deps/kotlin-compiler-1.6.0.jar deleted file mode 100644 index 4a98879e43e6..000000000000 --- a/java/kotlin-extractor/deps/kotlin-compiler-1.6.0.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4bd7a92568fd89c23b7f9f36d4380886beed18d3d54ea6adf49bebae627db805 -size 51408858 diff --git a/java/kotlin-extractor/deps/kotlin-compiler-1.6.20.jar b/java/kotlin-extractor/deps/kotlin-compiler-1.6.20.jar deleted file mode 100644 index 5a467a5af518..000000000000 --- a/java/kotlin-extractor/deps/kotlin-compiler-1.6.20.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:90567c5cf297985d028fa39aa3a7904dc8096173e1c7f3d3f35fe7074581098e -size 53370229 diff --git a/java/kotlin-extractor/deps/kotlin-compiler-1.7.0.jar b/java/kotlin-extractor/deps/kotlin-compiler-1.7.0.jar deleted file mode 100644 index ef54ce1e6532..000000000000 --- a/java/kotlin-extractor/deps/kotlin-compiler-1.7.0.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ce85fafb3e24712d62a0d02d277c2d56197d74afdd4f5ca995eaf33d2c504663 -size 53906809 diff --git a/java/kotlin-extractor/deps/kotlin-compiler-1.7.20.jar b/java/kotlin-extractor/deps/kotlin-compiler-1.7.20.jar deleted file mode 100644 index 442aea3e3425..000000000000 --- a/java/kotlin-extractor/deps/kotlin-compiler-1.7.20.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0e36d98c56f7c9685ab9d9e1fac9be36a5214939adb3f905b93c62de76023618 -size 54773087 diff --git a/java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.6.0.jar b/java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.6.0.jar deleted file mode 100644 index eafb6508d449..000000000000 --- a/java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.6.0.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0366843cd2defdd583c6b16b10bc32b85f28c5bf9510f10e44c886f5bd24c388 -size 49978431 diff --git a/java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.6.20.jar b/java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.6.20.jar deleted file mode 100644 index f426dae65b1e..000000000000 --- a/java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.6.20.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:be634faaafb56816b6ef6d583e57ab33e4d6e5180cde2f505ccf7d45dc738ef8 -size 51976423 diff --git a/java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.7.0.jar b/java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.7.0.jar deleted file mode 100644 index 0857bed8c9e1..000000000000 --- a/java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.7.0.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:573935b492e65b93a792eaa6270295532f580cd4f26f9f6eb105ecbafcd182d4 -size 52514265 diff --git a/java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.7.20.jar b/java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.7.20.jar deleted file mode 100644 index b95097b6935e..000000000000 --- a/java/kotlin-extractor/deps/kotlin-compiler-embeddable-1.7.20.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5ec2be1872dc47b9dcb466f1781eded6c59d9eee18657d4b0f1148e619caea36 -size 53395419 diff --git a/java/kotlin-extractor/deps/kotlin-stdlib-1.6.0.jar b/java/kotlin-extractor/deps/kotlin-stdlib-1.6.0.jar deleted file mode 100644 index 3ad56eecdc2d..000000000000 --- a/java/kotlin-extractor/deps/kotlin-stdlib-1.6.0.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:115daea30b0d484afcf2360237b9d9537f48a4a2f03f3cc2a16577dfc6e90342 -size 1508076 diff --git a/java/kotlin-extractor/deps/kotlin-stdlib-1.6.20.jar b/java/kotlin-extractor/deps/kotlin-stdlib-1.6.20.jar deleted file mode 100644 index b170c1da738b..000000000000 --- a/java/kotlin-extractor/deps/kotlin-stdlib-1.6.20.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:eeb51c2b67b26233fd81d0bc4f8044ec849718890905763ceffd84a31e2cb799 -size 1509405 diff --git a/java/kotlin-extractor/deps/kotlin-stdlib-1.7.0.jar b/java/kotlin-extractor/deps/kotlin-stdlib-1.7.0.jar deleted file mode 100644 index bed18f8429b7..000000000000 --- a/java/kotlin-extractor/deps/kotlin-stdlib-1.7.0.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:aa88e9625577957f3249a46cb6e166ee09b369e600f7a11d148d16b0a6d87f05 -size 1524619 diff --git a/java/kotlin-extractor/deps/kotlin-stdlib-1.7.20.jar b/java/kotlin-extractor/deps/kotlin-stdlib-1.7.20.jar deleted file mode 100644 index 9998f1e65920..000000000000 --- a/java/kotlin-extractor/deps/kotlin-stdlib-1.7.20.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7779ec96b9acbf92ca023858ac04543f9d2c3bdf1722425fff42f25ff3acfc9b -size 1537347 diff --git a/java/kotlin-extractor/versions.bzl b/java/kotlin-extractor/versions.bzl index 95897f49cc81..f540e99db90a 100644 --- a/java/kotlin-extractor/versions.bzl +++ b/java/kotlin-extractor/versions.bzl @@ -1,9 +1,5 @@ # when updating this list, `bazel mod tidy` should be run from `codeql` to update `MODULE.bazel` VERSIONS = [ - "1.6.0", - "1.6.20", - "1.7.0", - "1.7.20", "1.8.0", "1.9.0-Beta", "1.9.20-Beta", diff --git a/misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/source.json b/misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/source.json deleted file mode 100644 index 8abac8eb4bd1..000000000000 --- a/misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/source.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "integrity": "sha256-4USKVrJGJAeyaI3qht9cN1s2oJkb1HjC3dlMlxaBJeI=", - "url": "https://github.com/bazelbuild/rules_kotlin/releases/download/v2.1.3/rules_kotlin-v2.1.3.tar.gz", - "patches": { - "codeql_do_not_emit_jdeps.patch": "sha256-1ir4Aio1SICxnj1wafQ0GefT/m7bwn2n+SQwq19V3A8=", - "codeql_add_language_version_option.patch": "sha256-F7RthnrO6kJlCNcQ76L1Utqll2OwyeFZ/HmT82NwgB4=" - }, - "patch_strip": 1 -} diff --git a/misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/MODULE.bazel b/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/MODULE.bazel similarity index 52% rename from misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/MODULE.bazel rename to misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/MODULE.bazel index 41bef52cf9f6..f0876478fe97 100644 --- a/misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/MODULE.bazel +++ b/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/MODULE.bazel @@ -1,16 +1,23 @@ module( name = "rules_kotlin", - version = "2.1.3-codeql.1", + version = "2.2.0-codeql.1", compatibility_level = 1, repo_name = "rules_kotlin", ) bazel_dep(name = "platforms", version = "0.0.11") bazel_dep(name = "bazel_skylib", version = "1.7.1") +# bazel_dep(name = "rules_java", version = "7.2.0") bazel_dep(name = "rules_java", version = "7.2.0") -bazel_dep(name = "rules_python", version = "0.23.1") -bazel_dep(name = "rules_cc", version = "0.0.8") -bazel_dep(name = "rules_android", version = "0.1.1") +bazel_dep(name = "rules_android", version = "0.6.4") +bazel_dep(name = "bazel_features", version = "1.25.0") +bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf") +bazel_dep(name = "rules_proto", version = "6.0.2", repo_name = "rules_proto") +bazel_dep(name = "abseil-py", version = "2.1.0", repo_name = "py_absl") +bazel_dep(name = "rules_cc", version = "0.0.16") + +rules_java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains") +use_repo(rules_java_toolchains, "remote_java_tools") rules_kotlin_extensions = use_extension( "//src/main/starlark/core/repositories:bzlmod_setup.bzl", @@ -24,12 +31,7 @@ use_repo( "kotlinx_serialization_core_jvm", "kotlinx_serialization_json", "kotlinx_serialization_json_jvm", + "kotlin_build_tools_impl", ) register_toolchains("//kotlin/internal:default_toolchain") - -# TODO(bencodes) We should be able to remove this once rules_android has rolled out official Bzlmod support -remote_android_extensions = use_extension("@bazel_tools//tools/android:android_extensions.bzl", "remote_android_tools_extensions") -use_repo(remote_android_extensions, "android_gmaven_r8", "android_tools") - -bazel_dep(name = "rules_proto", version = "5.3.0-21.7") diff --git a/misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/patches/codeql_add_language_version_option.patch b/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/patches/codeql_add_language_version_option.patch similarity index 58% rename from misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/patches/codeql_add_language_version_option.patch rename to misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/patches/codeql_add_language_version_option.patch index b0bf85d4faef..795d1f88f387 100644 --- a/misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/patches/codeql_add_language_version_option.patch +++ b/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/patches/codeql_add_language_version_option.patch @@ -1,22 +1,20 @@ -diff --git a/src/main/starlark/core/options/opts.kotlinc.bzl b/src/main/starlark/core/options/opts.kotlinc.bzl -index 76df826..ef2d6ca 100644 ---- a/src/main/starlark/core/options/opts.kotlinc.bzl -+++ b/src/main/starlark/core/options/opts.kotlinc.bzl -@@ -33,6 +33,11 @@ def _map_jdk_release_to_flag(version): +--- a/src/main/starlark/core/options/opts.kotlinc.bzl 2000-01-01 01:00:00.000000000 +0100 ++++ b/src/main/starlark/core/options/opts.kotlinc.bzl 2025-11-17 16:51:01.012063056 +0100 +@@ -51,6 +51,11 @@ return None return ["-Xjdk-release=%s" % version] - + +def _map_language_version_to_flag(version): + if not version: + return None + return ["-language-version=%s" % version, "-api-version=%s" % version] + _KOPTS_ALL = { - "warn": struct( + "include_stdlibs": struct( args = dict( -@@ -429,6 +434,15 @@ _KOPTS_ALL = { +@@ -495,6 +500,15 @@ value_to_flag = None, - map_value_to_flag = _map_jdk_release_to_flag, + map_value_to_flag = _map_warning_level, ), + "language_version": struct( + args = dict( @@ -28,5 +26,5 @@ index 76df826..ef2d6ca 100644 + map_value_to_flag = _map_language_version_to_flag, + ), } - + def _merge(key, rule_defined): diff --git a/misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/patches/codeql_do_not_emit_jdeps.patch b/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/patches/codeql_do_not_emit_jdeps.patch similarity index 81% rename from misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/patches/codeql_do_not_emit_jdeps.patch rename to misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/patches/codeql_do_not_emit_jdeps.patch index 380c837d06a4..e6b71ab0c4f5 100644 --- a/misc/bazel/registry/modules/rules_kotlin/2.1.3-codeql.1/patches/codeql_do_not_emit_jdeps.patch +++ b/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/patches/codeql_do_not_emit_jdeps.patch @@ -1,11 +1,9 @@ Emitting jdeps is broken for the 2.0.0 kotlin extractor, and we don't need those files. Patching it here rather than passing `--@rules_kotlin//kotlin/settings:jvm_emit_jdeps=false` allows us to not have to specify that option (and therefore pull in `rules_kotlin`) in `semmle-code`. -diff --git a/kotlin/settings/BUILD.bazel b/kotlin/settings/BUILD.bazel -index 2c93c11..f352b80 100644 --- a/kotlin/settings/BUILD.bazel +++ b/kotlin/settings/BUILD.bazel -@@ -25,7 +25,7 @@ release_archive( +@@ -16,6 +16,6 @@ release_archive( # Flag that controls the emission of jdeps files during kotlin jvm compilation. bool_flag( name = "jvm_emit_jdeps", @@ -13,4 +11,4 @@ index 2c93c11..f352b80 100644 + build_setting_default = False, visibility = ["//visibility:public"], ) - + diff --git a/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/source.json b/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/source.json new file mode 100644 index 000000000000..bfa243b5a22e --- /dev/null +++ b/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/source.json @@ -0,0 +1,9 @@ +{ + "integrity": "sha256-4STROYYIW8ChW+LIXBQVurVwhEK3jSSf4iv430OlNA0=", + "url": "https://github.com/bazelbuild/rules_kotlin/releases/download/v2.2.0/rules_kotlin-v2.2.0.tar.gz", + "patches": { + "codeql_do_not_emit_jdeps.patch": "sha256-gIlhXEY71vlCkpr5wj2vm3yv6RwcuKLhgbTGqdVvQfU=", + "codeql_add_language_version_option.patch": "sha256-HoH8NWXxmYHmm/SxaugRdXgMntvcQx5gRLW2yQIvWhM=" + }, + "patch_strip": 1 +} diff --git a/misc/bazel/registry/modules/rules_kotlin/metadata.json b/misc/bazel/registry/modules/rules_kotlin/metadata.json index dace87c72d1c..3609865f4d5b 100644 --- a/misc/bazel/registry/modules/rules_kotlin/metadata.json +++ b/misc/bazel/registry/modules/rules_kotlin/metadata.json @@ -21,7 +21,7 @@ "github:bazelbuild/rules_kotlin" ], "versions": [ - "2.1.3-codeql.1" + "2.2.0-codeql.1", ], "yanked_versions": {} } From 79bcedc932a00dbd5a3aa3f1ba6441952ac7d9f8 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Thu, 4 Dec 2025 16:01:50 +0100 Subject: [PATCH 02/19] Kotlin: Remove resource_strip_prefix for kotlin extraction --- java/kotlin-extractor/BUILD.bazel | 5 ----- 1 file changed, 5 deletions(-) diff --git a/java/kotlin-extractor/BUILD.bazel b/java/kotlin-extractor/BUILD.bazel index a714e06d4111..ab265dd946e2 100644 --- a/java/kotlin-extractor/BUILD.bazel +++ b/java/kotlin-extractor/BUILD.bazel @@ -126,11 +126,6 @@ kt_javac_options( module_name = "codeql-kotlin-extractor", # resource_strip_prefix is very nit-picky: the following makes it work from # `codeql`, `@codeql_kotlin_embeddable` and `semmle-code` - resource_strip_prefix = ( - ("../%s/" % repo_name() if repo_name() else "") + - ("%s/" % package_name() if package_name() else "") + - v - ), resources = [ ":resources-%s" % v, ], From edd3235e82b3297448de5d811807445950fe8111 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Thu, 4 Dec 2025 16:12:24 +0100 Subject: [PATCH 03/19] Kotlin: Silence compilation warnings --- java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt | 2 ++ java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt | 1 + .../kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt | 3 +++ 3 files changed, 6 insertions(+) diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index 72c766bb0828..cb1ce8ed253e 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt @@ -415,6 +415,7 @@ open class KotlinFileExtractor( private fun extractClassModifiers(c: IrClass, id: Label) { with("class modifiers", c) { + @Suppress("REDUNDANT_ELSE_IN_WHEN") when (c.modality) { Modality.FINAL -> addModifiers(id, "final") Modality.SEALED -> addModifiers(id, "sealed") @@ -2801,6 +2802,7 @@ open class KotlinFileExtractor( private fun extractBody(b: IrBody, callable: Label) { with("body", b) { + @Suppress("REDUNDANT_ELSE_IN_WHEN") when (b) { is IrBlockBody -> extractBlockBody(b, callable) is IrSyntheticBody -> extractSyntheticBody(b, callable) diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt index 83cbec771fc5..bb664e711a3e 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt @@ -1836,6 +1836,7 @@ open class KotlinUsesExtractor( // Note this function doesn't return a signature because type arguments are never // incorporated into function signatures. + @Suppress("REDUNDANT_ELSE_IN_WHEN") return when (arg) { is IrStarProjection -> { val anyTypeLabel = diff --git a/java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt b/java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt index fb39b6675759..f4eac03df9d0 100644 --- a/java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt +++ b/java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt @@ -111,6 +111,7 @@ private fun subProjectedType( } ?: makeTypeProjection(t.substituteTypeArguments(substitutionMap), outerVariance) private fun IrTypeArgument.upperBound(context: IrPluginContext) = + @Suppress("REDUNDANT_ELSE_IN_WHEN") when (this) { is IrStarProjection -> context.irBuiltIns.anyNType is IrTypeProjection -> @@ -125,6 +126,7 @@ private fun IrTypeArgument.upperBound(context: IrPluginContext) = } private fun IrTypeArgument.lowerBound(context: IrPluginContext) = + @Suppress("REDUNDANT_ELSE_IN_WHEN") when (this) { is IrStarProjection -> context.irBuiltIns.nothingType is IrTypeProjection -> @@ -209,6 +211,7 @@ fun IrClass.toRawType(): IrType { } fun IrTypeArgument.withQuestionMark(b: Boolean): IrTypeArgument = + @Suppress("REDUNDANT_ELSE_IN_WHEN") when (this) { is IrStarProjection -> this is IrTypeProjection -> From ae640978fd82c6d7ad6fee222d7bdf4113a344e9 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Thu, 4 Dec 2025 16:14:13 +0100 Subject: [PATCH 04/19] Kotlin: Add support for Kotlin 2.3.0-Beta2 --- MODULE.bazel | 3 +++ .../deps/kotlin-compiler-2.3.0-Beta2.jar | 3 +++ .../kotlin-compiler-embeddable-2.3.0-Beta2.jar | 3 +++ .../deps/kotlin-stdlib-2.3.0-Beta2.jar | 3 +++ .../src/main/kotlin/KotlinFileExtractor.kt | 16 +++++++++++++--- .../src/main/kotlin/KotlinUsesExtractor.kt | 3 --- java/kotlin-extractor/versions.bzl | 1 + 7 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 java/kotlin-extractor/deps/kotlin-compiler-2.3.0-Beta2.jar create mode 100644 java/kotlin-extractor/deps/kotlin-compiler-embeddable-2.3.0-Beta2.jar create mode 100644 java/kotlin-extractor/deps/kotlin-stdlib-2.3.0-Beta2.jar diff --git a/MODULE.bazel b/MODULE.bazel index 3e261fac8f66..8396af644c7b 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -230,6 +230,7 @@ use_repo( "kotlin-compiler-2.1.20-Beta1", "kotlin-compiler-2.2.0-Beta1", "kotlin-compiler-2.2.20-Beta2", + "kotlin-compiler-2.3.0-Beta2", "kotlin-compiler-embeddable-1.8.0", "kotlin-compiler-embeddable-1.9.0-Beta", "kotlin-compiler-embeddable-1.9.20-Beta", @@ -239,6 +240,7 @@ use_repo( "kotlin-compiler-embeddable-2.1.20-Beta1", "kotlin-compiler-embeddable-2.2.0-Beta1", "kotlin-compiler-embeddable-2.2.20-Beta2", + "kotlin-compiler-embeddable-2.3.0-Beta2", "kotlin-stdlib-1.8.0", "kotlin-stdlib-1.9.0-Beta", "kotlin-stdlib-1.9.20-Beta", @@ -248,6 +250,7 @@ use_repo( "kotlin-stdlib-2.1.20-Beta1", "kotlin-stdlib-2.2.0-Beta1", "kotlin-stdlib-2.2.20-Beta2", + "kotlin-stdlib-2.3.0-Beta2", ) go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk") diff --git a/java/kotlin-extractor/deps/kotlin-compiler-2.3.0-Beta2.jar b/java/kotlin-extractor/deps/kotlin-compiler-2.3.0-Beta2.jar new file mode 100644 index 000000000000..81c85be01074 --- /dev/null +++ b/java/kotlin-extractor/deps/kotlin-compiler-2.3.0-Beta2.jar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ed7d52fa82ae3837e63b6f110a8e25ef807c773c1597f93fb3a1e509e2624c6 +size 59087152 diff --git a/java/kotlin-extractor/deps/kotlin-compiler-embeddable-2.3.0-Beta2.jar b/java/kotlin-extractor/deps/kotlin-compiler-embeddable-2.3.0-Beta2.jar new file mode 100644 index 000000000000..aa1aed82c11f --- /dev/null +++ b/java/kotlin-extractor/deps/kotlin-compiler-embeddable-2.3.0-Beta2.jar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d66c146d383a7b8463cb1a0fc9bbff9b0db0b136a465730a338f1fc2bf160f1c +size 57665679 diff --git a/java/kotlin-extractor/deps/kotlin-stdlib-2.3.0-Beta2.jar b/java/kotlin-extractor/deps/kotlin-stdlib-2.3.0-Beta2.jar new file mode 100644 index 000000000000..e0151662ad5b --- /dev/null +++ b/java/kotlin-extractor/deps/kotlin-stdlib-2.3.0-Beta2.jar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fb35d6a1bf6df0a5a4e78307c92885f63878a53499cc2800f0ba706e527ab615 +size 1796815 diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index cb1ce8ed253e..fc22eda04d47 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt @@ -1645,7 +1645,7 @@ open class KotlinFileExtractor( extractMethodAndParameterTypeAccesses: Boolean, typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List? - ) = + ) : Label = forceExtractFunction( f, parentId, @@ -2975,12 +2975,22 @@ open class KotlinFileExtractor( val locId = tw.getLocation(s) tw.writeStmts_block(blockId, parent, idx, callable) tw.writeHasLocation(blockId, locId) - extractVariable(s.delegate, callable, blockId, 0) + // For Kotlin < 2.3, s.deligate is not-nullable. Cast to a be nullable, + // as a workaround to silence warnings for kotlin < 2.3 about the elvis + // operator being redundant. + // For Kotlin >= 2.3, the cast is redundant, so we need to silence that warning + + @Suppress("USELESS_CAST") + val delegate = (s.delegate as IrVariable?) ?: run { + logger.errorElement("Local delegated property is missing delegate", s) + return + } + extractVariable(delegate, callable, blockId, 0) val propId = tw.getFreshIdLabel() tw.writeKtProperties(propId, s.name.asString()) tw.writeHasLocation(propId, locId) - tw.writeKtPropertyDelegates(propId, useVariable(s.delegate)) + tw.writeKtPropertyDelegates(propId, useVariable(delegate)) // Getter: extractStatement(s.getter, callable, blockId, 1) diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt index bb664e711a3e..ba38ac1da373 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt @@ -849,9 +849,6 @@ open class KotlinUsesExtractor( } private fun useSimpleType(s: IrSimpleType, context: TypeContext): TypeResults { - if (s.abbreviation != null) { - // TODO: Extract this information - } // We use this when we don't actually have an IrClass for a class // we want to refer to // TODO: Eliminate the need for this if possible diff --git a/java/kotlin-extractor/versions.bzl b/java/kotlin-extractor/versions.bzl index f540e99db90a..b7ae04934e17 100644 --- a/java/kotlin-extractor/versions.bzl +++ b/java/kotlin-extractor/versions.bzl @@ -9,6 +9,7 @@ VERSIONS = [ "2.1.20-Beta1", "2.2.0-Beta1", "2.2.20-Beta2", + "2.3.0-Beta2", ] def _version_to_tuple(v): From c4c60407dda7d45fa20a278e0fe3d061b88d568a Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Thu, 4 Dec 2025 17:05:58 +0100 Subject: [PATCH 05/19] Kotlin: Update compiler plugin for Kotlin 2.3.0-Beta2 --- .../Kotlin2ComponentRegistrar.kt | 13 ++++++++ ...tJvmModuleNameForDeserializedDescriptor.kt | 31 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/Kotlin2ComponentRegistrar.kt create mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/getJvmModuleNameForDeserializedDescriptor.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/Kotlin2ComponentRegistrar.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/Kotlin2ComponentRegistrar.kt new file mode 100644 index 000000000000..e20c45ddc4d4 --- /dev/null +++ b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/Kotlin2ComponentRegistrar.kt @@ -0,0 +1,13 @@ +// For ComponentRegistrar +@file:Suppress("DEPRECATION", "DEPRECATION_ERROR") + +package com.github.codeql + +import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar +import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi + +@OptIn(ExperimentalCompilerApi::class) +abstract class Kotlin2ComponentRegistrar : ComponentRegistrar { + override val supportsK2: Boolean + get() = true +} diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/getJvmModuleNameForDeserializedDescriptor.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/getJvmModuleNameForDeserializedDescriptor.kt new file mode 100644 index 000000000000..21da983e40ed --- /dev/null +++ b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/getJvmModuleNameForDeserializedDescriptor.kt @@ -0,0 +1,31 @@ +package com.github.codeql.utils.versions + +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource +import org.jetbrains.kotlin.metadata.deserialization.* +import org.jetbrains.kotlin.metadata.jvm.deserialization.* +import org.jetbrains.kotlin.metadata.jvm.JvmProtoBuf +import org.jetbrains.kotlin.resolve.DescriptorUtils.* +import org.jetbrains.kotlin.serialization.deserialization.descriptors.* + +fun getJvmModuleNameForDeserializedDescriptor(descriptor: CallableMemberDescriptor): String? { + val parent = getParentOfType(descriptor, ClassOrPackageFragmentDescriptor::class.java, false) + + when { + parent is DeserializedClassDescriptor -> { + val classProto = parent.classProto + val nameResolver = parent.c.nameResolver + return classProto.getExtensionOrNull(JvmProtoBuf.classModuleName) + ?.let(nameResolver::getString) + ?: JvmProtoBufUtil.DEFAULT_MODULE_NAME + } + descriptor is DeserializedMemberDescriptor -> { + val source = descriptor.containerSource + if (source is JvmPackagePartSource) { + return source.moduleName + } + } + } + + return null +} From ca62b572199785151d264acc88b029071526b364 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Fri, 5 Dec 2025 09:21:39 +0100 Subject: [PATCH 06/19] Kotlin: Fix bazel format and address copilot review comments --- java/kotlin-extractor/BUILD.bazel | 2 -- java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt | 2 +- .../registry/modules/rules_kotlin/2.2.0-codeql.1/MODULE.bazel | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/java/kotlin-extractor/BUILD.bazel b/java/kotlin-extractor/BUILD.bazel index ab265dd946e2..665155d49f2e 100644 --- a/java/kotlin-extractor/BUILD.bazel +++ b/java/kotlin-extractor/BUILD.bazel @@ -124,8 +124,6 @@ kt_javac_options( javac_opts = ":javac-options", kotlinc_opts = ":kotlinc-options-%s" % v, module_name = "codeql-kotlin-extractor", - # resource_strip_prefix is very nit-picky: the following makes it work from - # `codeql`, `@codeql_kotlin_embeddable` and `semmle-code` resources = [ ":resources-%s" % v, ], diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index fc22eda04d47..af8015fa4573 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt @@ -2975,7 +2975,7 @@ open class KotlinFileExtractor( val locId = tw.getLocation(s) tw.writeStmts_block(blockId, parent, idx, callable) tw.writeHasLocation(blockId, locId) - // For Kotlin < 2.3, s.deligate is not-nullable. Cast to a be nullable, + // For Kotlin < 2.3, s.delegate is not-nullable. Cast to a be nullable, // as a workaround to silence warnings for kotlin < 2.3 about the elvis // operator being redundant. // For Kotlin >= 2.3, the cast is redundant, so we need to silence that warning diff --git a/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/MODULE.bazel b/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/MODULE.bazel index f0876478fe97..df66ce2051ab 100644 --- a/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/MODULE.bazel +++ b/misc/bazel/registry/modules/rules_kotlin/2.2.0-codeql.1/MODULE.bazel @@ -7,7 +7,6 @@ module( bazel_dep(name = "platforms", version = "0.0.11") bazel_dep(name = "bazel_skylib", version = "1.7.1") -# bazel_dep(name = "rules_java", version = "7.2.0") bazel_dep(name = "rules_java", version = "7.2.0") bazel_dep(name = "rules_android", version = "0.6.4") bazel_dep(name = "bazel_features", version = "1.25.0") @@ -28,10 +27,10 @@ use_repo( "com_github_google_ksp", "com_github_jetbrains_kotlin", "com_github_pinterest_ktlint", + "kotlin_build_tools_impl", "kotlinx_serialization_core_jvm", "kotlinx_serialization_json", "kotlinx_serialization_json_jvm", - "kotlin_build_tools_impl", ) register_toolchains("//kotlin/internal:default_toolchain") From 59b66c15bffd9ce02b94dbfd17399c0cb5b8f616 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Sat, 20 Dec 2025 11:18:11 +0100 Subject: [PATCH 07/19] Kotlin: Strip prefix when building plugin --- java/kotlin-extractor/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/java/kotlin-extractor/BUILD.bazel b/java/kotlin-extractor/BUILD.bazel index 665155d49f2e..a4356af1835b 100644 --- a/java/kotlin-extractor/BUILD.bazel +++ b/java/kotlin-extractor/BUILD.bazel @@ -124,6 +124,7 @@ kt_javac_options( javac_opts = ":javac-options", kotlinc_opts = ":kotlinc-options-%s" % v, module_name = "codeql-kotlin-extractor", + resource_strip_prefix = v, resources = [ ":resources-%s" % v, ], From e743cbdf302f317fe73508a0eb4aaf83dc204513 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Mon, 5 Jan 2026 08:50:38 +0100 Subject: [PATCH 08/19] Kotlin: Create IrSimpleType factory function to support constructor changes introduced in Kotlin 2.3 --- .../src/main/kotlin/KotlinUsesExtractor.kt | 2 +- .../src/main/kotlin/utils/TypeSubstitution.kt | 3 +-- .../v_1_6_0/IrSimpleTypeImplCompat.kt | 19 +++++++++++++++++ .../v_2_3_0-Beta2/IrSimpleTypeImplCompat.kt | 21 +++++++++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IrSimpleTypeImplCompat.kt create mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/IrSimpleTypeImplCompat.kt diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt index ba38ac1da373..eec0103723d8 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt @@ -725,7 +725,7 @@ open class KotlinUsesExtractor( componentType.isNullableCodeQL() if (unchanged) arrayType else - IrSimpleTypeImpl( + codeqlIrSimpleTypeImpl( arrayType.classifier, true, listOf(makeTypeProjection(componentTypeBroadened, Variance.INVARIANT)), diff --git a/java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt b/java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt index f4eac03df9d0..76cbba5576a8 100644 --- a/java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt +++ b/java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt @@ -27,7 +27,6 @@ import org.jetbrains.kotlin.ir.types.IrStarProjection import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.IrTypeArgument import org.jetbrains.kotlin.ir.types.IrTypeProjection -import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection import org.jetbrains.kotlin.ir.util.* @@ -61,7 +60,7 @@ private fun IrSimpleType.substituteTypeArguments( } } - return IrSimpleTypeImpl(classifier, isNullableCodeQL(), newArguments, annotations) + return codeqlIrSimpleTypeImpl(classifier, isNullableCodeQL(), newArguments, annotations) } /** diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IrSimpleTypeImplCompat.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IrSimpleTypeImplCompat.kt new file mode 100644 index 000000000000..ed0ad405e294 --- /dev/null +++ b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IrSimpleTypeImplCompat.kt @@ -0,0 +1,19 @@ +package com.github.codeql.utils.versions + +import org.jetbrains.kotlin.ir.expressions.IrConstructorCall +import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol +import org.jetbrains.kotlin.ir.types.IrSimpleType +import org.jetbrains.kotlin.ir.types.IrTypeArgument +import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl + +fun codeqlIrSimpleTypeImpl( + classifier: IrClassifierSymbol, + isNullable: Boolean, + arguments: List, + annotations: List +): IrSimpleType = IrSimpleTypeImpl( + classifier, + isNullable, + arguments, + annotations +) diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/IrSimpleTypeImplCompat.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/IrSimpleTypeImplCompat.kt new file mode 100644 index 000000000000..b2b4e14731c9 --- /dev/null +++ b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/IrSimpleTypeImplCompat.kt @@ -0,0 +1,21 @@ +package com.github.codeql.utils.versions + +import org.jetbrains.kotlin.ir.expressions.IrConstructorCall +import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol +import org.jetbrains.kotlin.ir.types.IrSimpleType +import org.jetbrains.kotlin.ir.types.IrTypeArgument +import org.jetbrains.kotlin.ir.types.SimpleTypeNullability +import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl + +fun codeqlIrSimpleTypeImpl( + classifier: IrClassifierSymbol, + isNullable: Boolean, + arguments: List, + annotations: List +): IrSimpleType = IrSimpleTypeImpl( + classifier, + SimpleTypeNullability.fromHasQuestionMark(isNullable), + arguments, + annotations, + null // originalKotlinType - explicitly pass null to avoid default parameter issues +) From 1cd75d3984264c2e15be1028559b1ec8638179a9 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Mon, 5 Jan 2026 14:20:27 +0100 Subject: [PATCH 09/19] Kotlin: Fix spelling --- java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index af8015fa4573..185749759479 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt @@ -2975,7 +2975,7 @@ open class KotlinFileExtractor( val locId = tw.getLocation(s) tw.writeStmts_block(blockId, parent, idx, callable) tw.writeHasLocation(blockId, locId) - // For Kotlin < 2.3, s.delegate is not-nullable. Cast to a be nullable, + // For Kotlin < 2.3, s.delegate is not-nullable. Cast to be nullable, // as a workaround to silence warnings for kotlin < 2.3 about the elvis // operator being redundant. // For Kotlin >= 2.3, the cast is redundant, so we need to silence that warning From 716e4e15769399b218bbb56390f16e8e5b8a40c4 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Mon, 5 Jan 2026 14:20:49 +0100 Subject: [PATCH 10/19] Kotlin: Remove obsolete file --- ...tJvmModuleNameForDeserializedDescriptor.kt | 31 ------------------- 1 file changed, 31 deletions(-) delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/getJvmModuleNameForDeserializedDescriptor.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/getJvmModuleNameForDeserializedDescriptor.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/getJvmModuleNameForDeserializedDescriptor.kt deleted file mode 100644 index 21da983e40ed..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/getJvmModuleNameForDeserializedDescriptor.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource -import org.jetbrains.kotlin.metadata.deserialization.* -import org.jetbrains.kotlin.metadata.jvm.deserialization.* -import org.jetbrains.kotlin.metadata.jvm.JvmProtoBuf -import org.jetbrains.kotlin.resolve.DescriptorUtils.* -import org.jetbrains.kotlin.serialization.deserialization.descriptors.* - -fun getJvmModuleNameForDeserializedDescriptor(descriptor: CallableMemberDescriptor): String? { - val parent = getParentOfType(descriptor, ClassOrPackageFragmentDescriptor::class.java, false) - - when { - parent is DeserializedClassDescriptor -> { - val classProto = parent.classProto - val nameResolver = parent.c.nameResolver - return classProto.getExtensionOrNull(JvmProtoBuf.classModuleName) - ?.let(nameResolver::getString) - ?: JvmProtoBufUtil.DEFAULT_MODULE_NAME - } - descriptor is DeserializedMemberDescriptor -> { - val source = descriptor.containerSource - if (source is JvmPackagePartSource) { - return source.moduleName - } - } - } - - return null -} From c4d5eaead4055120264eead41fb4eef5283ddaa9 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Mon, 5 Jan 2026 17:00:42 +0100 Subject: [PATCH 11/19] Kotlin: Remove support for Kotlin versions 1.6 and 1.7 This change rolls up all files from v1_6_0, v1_6_20, v1_7_0 and v_1_7_20. In addition, versioned files that are not overridden by any later Kotlin versions (i.e. files that only have one copy under utils/versions) are inlined and removed to simplify list of changes. List of removed/inlined files: allOverriddenIncludingSelf.kt copyTo.kt ExperimentalCompilerApi.kt getFileClassFqName.kt IsUnderscoreParameter.kt ReferenceEntity.kt SyntheticBodyKind.kt Types.kt withHasQuestionMark.kt --- .../src/main/kotlin/KotlinFileExtractor.kt | 6 +-- .../src/main/kotlin/KotlinUsesExtractor.kt | 2 +- .../src/main/kotlin/MetaAnnotationSupport.kt | 6 ++- .../src/main/kotlin/utils/ClassNames.kt | 36 ++++++++++++++++ .../src/main/kotlin/utils/GetByFqName.kt | 29 +++++++++++++ .../src/main/kotlin/utils/JvmNames.kt | 4 +- .../src/main/kotlin/utils/TypeSubstitution.kt | 11 ++++- .../v_1_6_0/ExperimentalCompilerApi.kt | 4 -- .../versions/v_1_6_0/IsUnderscoreParameter.kt | 21 ---------- .../utils/versions/v_1_6_0/ReferenceEntity.kt | 33 --------------- .../versions/v_1_6_0/SyntheticBodyKind.kt | 5 --- .../kotlin/utils/versions/v_1_6_0/Types.kt | 6 --- .../v_1_6_0/allOverriddenIncludingSelf.kt | 6 --- .../kotlin/utils/versions/v_1_6_0/copyTo.kt | 7 ---- ...rameterDeclarationWithWrappedDescriptor.kt | 7 ---- .../versions/v_1_6_0/getFileClassFqName.kt | 8 ---- .../utils/versions/v_1_6_0/getKotlinType.kt | 6 --- .../versions/v_1_6_0/withHasQuestionMark.kt | 8 ---- .../v_1_6_20/IsUnderscoreParameter.kt | 7 ---- .../kotlin/utils/versions/v_1_6_20/Types.kt | 6 --- .../versions/v_1_7_0/getFileClassFqName.kt | 41 ------------------- .../versions/v_1_7_0/withHasQuestionMark.kt | 13 ------ .../v_1_7_20/allOverriddenIncludingSelf.kt | 6 --- .../kotlin/utils/versions/v_1_7_20/copyTo.kt | 7 ---- .../{v_1_6_0 => v_1_8_0}/CodeQLIrConst.kt | 0 .../{v_1_6_0 => v_1_8_0}/CodeQLIsRoot.kt | 0 .../CommentExtractorLighterAST.kt | 0 .../v_1_8_0/ExperimentalCompilerApi.kt | 4 -- .../FirMetadataSourceFirFile.kt | 0 .../{v_1_6_0 => v_1_8_0}/IrLazyFunction.kt | 0 .../IrSimpleTypeImplCompat.kt | 0 .../{v_1_6_0 => v_1_8_0}/IrSymbolInternals.kt | 0 .../{v_1_6_0 => v_1_8_0}/IrVisitor.kt | 0 .../JvmDefaultModeIsNoCompatibility.kt | 0 .../Kotlin2ComponentRegistrar.kt | 0 .../LinesOfCodeLighterAST.kt | 0 .../versions/{v_1_6_0 => v_1_8_0}/Psi2Ir.kt | 0 .../utils/versions/v_1_8_0/ReferenceEntity.kt | 35 ---------------- .../versions/v_1_8_0/SyntheticBodyKind.kt | 5 --- .../versions/{v_1_6_0 => v_1_8_0}/UsesK2.kt | 0 .../VirtualFileBasedSourceElement.kt | 0 ...rameterDeclarationWithWrappedDescriptor.kt | 0 .../{v_1_6_0 => v_1_8_0}/getJvmDefaultMode.kt | 0 ...tJvmModuleNameForDeserializedDescriptor.kt | 0 .../{v_1_7_0 => v_1_8_0}/getKotlinType.kt | 0 .../isDispatchReceiver.kt | 0 .../{v_1_6_0 => v_1_8_0}/packageFqName.kt | 0 .../parameterIndexExcludingReceivers.kt | 0 .../versions/{v_1_6_0 => v_1_8_0}/parents.kt | 0 .../{v_1_6_0 => v_1_8_0}/typeUtils.kt | 0 50 files changed, 85 insertions(+), 244 deletions(-) delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/ExperimentalCompilerApi.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IsUnderscoreParameter.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/ReferenceEntity.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/SyntheticBodyKind.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/Types.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/allOverriddenIncludingSelf.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/copyTo.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/createImplicitParameterDeclarationWithWrappedDescriptor.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/getFileClassFqName.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/getKotlinType.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/withHasQuestionMark.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_20/IsUnderscoreParameter.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_20/Types.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_0/getFileClassFqName.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_0/withHasQuestionMark.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_20/allOverriddenIncludingSelf.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_20/copyTo.kt rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/CodeQLIrConst.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/CodeQLIsRoot.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/CommentExtractorLighterAST.kt (100%) delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/ExperimentalCompilerApi.kt rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/FirMetadataSourceFirFile.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/IrLazyFunction.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/IrSimpleTypeImplCompat.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/IrSymbolInternals.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/IrVisitor.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/JvmDefaultModeIsNoCompatibility.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/Kotlin2ComponentRegistrar.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/LinesOfCodeLighterAST.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/Psi2Ir.kt (100%) delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/ReferenceEntity.kt delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/SyntheticBodyKind.kt rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/UsesK2.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/VirtualFileBasedSourceElement.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_7_20 => v_1_8_0}/createImplicitParameterDeclarationWithWrappedDescriptor.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/getJvmDefaultMode.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/getJvmModuleNameForDeserializedDescriptor.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_7_0 => v_1_8_0}/getKotlinType.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/isDispatchReceiver.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/packageFqName.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/parameterIndexExcludingReceivers.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/parents.kt (100%) rename java/kotlin-extractor/src/main/kotlin/utils/versions/{v_1_6_0 => v_1_8_0}/typeUtils.kt (100%) diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index 185749759479..baf0a8382161 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt @@ -1343,7 +1343,7 @@ open class KotlinFileExtractor( extractTypeAccessRecursive(substitutedType, location, id, -1) } val syntheticParameterNames = - isUnderscoreParameter(vp) || + vp.origin == IrDeclarationOrigin.UNDERSCORE_PARAMETER || ((vp.parent as? IrFunction)?.let { hasSynthesizedParameterNames(it) } ?: true) val javaParameter = when (val callable = (vp.parent as? IrFunction)?.let { getJavaCallable(it) }) { @@ -2836,7 +2836,7 @@ open class KotlinFileExtractor( when { kind == IrSyntheticBodyKind.ENUM_VALUES -> tw.writeKtSyntheticBody(callable, 1) kind == IrSyntheticBodyKind.ENUM_VALUEOF -> tw.writeKtSyntheticBody(callable, 2) - kind == kind_ENUM_ENTRIES -> tw.writeKtSyntheticBody(callable, 3) + kind == IrSyntheticBodyKind.ENUM_ENTRIES -> tw.writeKtSyntheticBody(callable, 3) else -> { logger.errorElement("Unhandled synthetic body kind " + kind, b) } @@ -3344,7 +3344,7 @@ open class KotlinFileExtractor( // that specified the default values, which will in turn dynamically dispatch back to the // relevant override. val overriddenCallTarget = - (callTarget as? IrSimpleFunction)?.allOverriddenIncludingSelf()?.firstOrNull { + (callTarget as? IrSimpleFunction)?.allOverridden(includeSelf = true)?.firstOrNull { it.overriddenSymbols.isEmpty() && it.valueParameters.any { p -> p.defaultValue != null } } ?: callTarget diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt index eec0103723d8..3994850fc756 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt @@ -936,7 +936,7 @@ open class KotlinUsesExtractor( return arrayInfo.componentTypeResults } owner is IrClass -> { - val args = if (s.codeQlIsRawType()) null else s.arguments + val args = if (s.isRawType()) null else s.arguments return useSimpleTypeClass(owner, args, s.isNullableCodeQL()) } diff --git a/java/kotlin-extractor/src/main/kotlin/MetaAnnotationSupport.kt b/java/kotlin-extractor/src/main/kotlin/MetaAnnotationSupport.kt index 368600267c11..96d5dd8bbbdd 100644 --- a/java/kotlin-extractor/src/main/kotlin/MetaAnnotationSupport.kt +++ b/java/kotlin-extractor/src/main/kotlin/MetaAnnotationSupport.kt @@ -1,6 +1,5 @@ package com.github.codeql -import com.github.codeql.utils.versions.copyParameterToFunction import com.github.codeql.utils.versions.createImplicitParameterDeclarationWithWrappedDescriptor import java.lang.annotation.ElementType import java.util.HashSet @@ -21,7 +20,9 @@ import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrConstructor import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrEnumEntry +import org.jetbrains.kotlin.ir.declarations.IrFunction import org.jetbrains.kotlin.ir.declarations.IrProperty +import org.jetbrains.kotlin.ir.declarations.IrValueParameter import org.jetbrains.kotlin.ir.expressions.IrClassReference import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue @@ -31,6 +32,7 @@ import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.types.typeWith import org.jetbrains.kotlin.ir.util.constructedClass import org.jetbrains.kotlin.ir.util.constructors +import org.jetbrains.kotlin.ir.util.copyTo import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols import org.jetbrains.kotlin.ir.util.defaultType import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable @@ -330,7 +332,7 @@ class MetaAnnotationSupport( ) return } - val newParam = copyParameterToFunction(thisReceiever, this) + val newParam = thisReceiever.copyTo(this) dispatchReceiverParameter = newParam body = factory diff --git a/java/kotlin-extractor/src/main/kotlin/utils/ClassNames.kt b/java/kotlin-extractor/src/main/kotlin/utils/ClassNames.kt index a18dd06247f7..97eb6d0bca46 100644 --- a/java/kotlin-extractor/src/main/kotlin/utils/ClassNames.kt +++ b/java/kotlin-extractor/src/main/kotlin/utils/ClassNames.kt @@ -12,9 +12,11 @@ import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable import org.jetbrains.kotlin.ir.util.parentClassOrNull import org.jetbrains.kotlin.load.java.sources.JavaSourceElement import org.jetbrains.kotlin.load.java.structure.impl.classFiles.BinaryJavaClass +import org.jetbrains.kotlin.load.kotlin.FacadeClassSource import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinarySourceElement import org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClass +import org.jetbrains.kotlin.name.FqName // Adapted from Kotlin's interpreter/Utils.kt function 'internalName' // Translates class names into their JLS section 13.1 binary name, @@ -31,6 +33,40 @@ fun getFileClassName(f: IrFile) = .replaceFirst(Regex("""\.kt$"""), "") .replaceFirstChar { it.uppercase() }) + "Kt") +fun getFileClassFqName(d: IrDeclaration): FqName? { + // d is in a file class. + // Get the name in a similar way to the compiler's ExternalPackageParentPatcherLowering + // visitMemberAccess/generateOrGetFacadeClass. + + // But first, fields aren't IrMemberWithContainerSource, so we need + // to get back to the property (if there is one) + if (d is IrField) { + val propSym = d.correspondingPropertySymbol + if (propSym != null) { + return getFileClassFqName(propSym.owner) + } + } + + // Now the main code + if (d is IrMemberWithContainerSource) { + val containerSource = d.containerSource + if (containerSource is FacadeClassSource) { + val facadeClassName = containerSource.facadeClassName + if (facadeClassName != null) { + // TODO: This is really a multifile-class rather than a file-class, + // but for now we treat them the same. + return facadeClassName.fqNameForTopLevelClassMaybeWithDollars + } else { + return containerSource.className.fqNameForTopLevelClassMaybeWithDollars + } + } else { + return null + } + } else { + return null + } +} + fun getIrElementBinaryName(that: IrElement): String { if (that is IrFile) { val shortName = getFileClassName(that) diff --git a/java/kotlin-extractor/src/main/kotlin/utils/GetByFqName.kt b/java/kotlin-extractor/src/main/kotlin/utils/GetByFqName.kt index a3f5bb80a48e..8fff87475948 100644 --- a/java/kotlin-extractor/src/main/kotlin/utils/GetByFqName.kt +++ b/java/kotlin-extractor/src/main/kotlin/utils/GetByFqName.kt @@ -2,9 +2,38 @@ package com.github.codeql.utils import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext import org.jetbrains.kotlin.ir.symbols.* +import org.jetbrains.kotlin.name.CallableId +import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name +fun getClassByFqName(pluginContext: IrPluginContext, fqName: FqName): IrClassSymbol? { + val id = ClassId.topLevel(fqName) + return getClassByClassId(pluginContext, id) +} + +fun getClassByClassId(pluginContext: IrPluginContext, id: ClassId): IrClassSymbol? { + return pluginContext.referenceClass(id) +} + +fun getFunctionsByFqName( + pluginContext: IrPluginContext, + pkgName: FqName, + name: Name +): Collection { + val id = CallableId(pkgName, name) + return pluginContext.referenceFunctions(id) +} + +fun getPropertiesByFqName( + pluginContext: IrPluginContext, + pkgName: FqName, + name: Name +): Collection { + val id = CallableId(pkgName, name) + return pluginContext.referenceProperties(id) +} + fun getClassByFqName(pluginContext: IrPluginContext, fqName: String): IrClassSymbol? { return getClassByFqName(pluginContext, FqName(fqName)) } diff --git a/java/kotlin-extractor/src/main/kotlin/utils/JvmNames.kt b/java/kotlin-extractor/src/main/kotlin/utils/JvmNames.kt index ec7c17b39fc6..02059b3db649 100644 --- a/java/kotlin-extractor/src/main/kotlin/utils/JvmNames.kt +++ b/java/kotlin-extractor/src/main/kotlin/utils/JvmNames.kt @@ -1,6 +1,5 @@ package com.github.codeql.utils -import com.github.codeql.utils.versions.allOverriddenIncludingSelf import com.github.codeql.utils.versions.CodeQLIrConst import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.ir.declarations.IrAnnotationContainer @@ -9,6 +8,7 @@ import org.jetbrains.kotlin.ir.declarations.IrFunction import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.types.IrSimpleType +import org.jetbrains.kotlin.ir.util.allOverridden import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable import org.jetbrains.kotlin.ir.util.packageFqName import org.jetbrains.kotlin.ir.util.parentClassOrNull @@ -62,7 +62,7 @@ private val specialFunctionShortNames = specialFunctions.keys.map { it.functionN private fun getSpecialJvmName(f: IrFunction): String? { if (specialFunctionShortNames.contains(f.name) && f is IrSimpleFunction) { - f.allOverriddenIncludingSelf().forEach { overriddenFunc -> + f.allOverridden(includeSelf = true).forEach { overriddenFunc -> overriddenFunc.parentClassOrNull?.fqNameWhenAvailable?.let { parentFqName -> specialFunctions[MethodKey(parentFqName, f.name)]?.let { return it diff --git a/java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt b/java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt index 76cbba5576a8..ba9b21ab3b86 100644 --- a/java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt +++ b/java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt @@ -3,7 +3,6 @@ package com.github.codeql.utils import com.github.codeql.KotlinUsesExtractor import com.github.codeql.Logger import com.github.codeql.getJavaEquivalentClassId -import com.github.codeql.utils.versions.codeQlWithHasQuestionMark import com.github.codeql.utils.versions.createImplicitParameterDeclarationWithWrappedDescriptor import com.github.codeql.utils.versions.* import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext @@ -21,6 +20,8 @@ import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol import org.jetbrains.kotlin.ir.symbols.impl.DescriptorlessExternalPackageFragmentSymbol import org.jetbrains.kotlin.ir.types.addAnnotations import org.jetbrains.kotlin.ir.types.classifierOrNull +import org.jetbrains.kotlin.ir.types.makeNotNull +import org.jetbrains.kotlin.ir.types.makeNullable import org.jetbrains.kotlin.ir.types.typeWith import org.jetbrains.kotlin.ir.types.IrSimpleType import org.jetbrains.kotlin.ir.types.IrStarProjection @@ -35,6 +36,14 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull +fun IrType.codeQlWithHasQuestionMark(b: Boolean): IrType { + if (b) { + return this.makeNullable() + } else { + return this.makeNotNull() + } +} + fun IrType.substituteTypeArguments(params: List, arguments: List) = when (this) { is IrSimpleType -> substituteTypeArguments(params.map { it.symbol }.zip(arguments).toMap()) diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/ExperimentalCompilerApi.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/ExperimentalCompilerApi.kt deleted file mode 100644 index 9b40a26bc511..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/ExperimentalCompilerApi.kt +++ /dev/null @@ -1,4 +0,0 @@ -package org.jetbrains.kotlin.compiler.plugin - -@RequiresOptIn("This API is experimental. There are no stability guarantees for it") -annotation class ExperimentalCompilerApi diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IsUnderscoreParameter.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IsUnderscoreParameter.kt deleted file mode 100644 index cb0fae2555b6..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IsUnderscoreParameter.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI -import org.jetbrains.kotlin.ir.declarations.IrValueParameter -import org.jetbrains.kotlin.psi.KtParameter -import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils -import org.jetbrains.kotlin.resolve.calls.util.isSingleUnderscore -import org.jetbrains.kotlin.utils.addToStdlib.safeAs - -@OptIn(ObsoleteDescriptorBasedAPI::class) -fun isUnderscoreParameter(vp: IrValueParameter) = - try { - DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor) - ?.safeAs() - ?.isSingleUnderscore == true - } catch (e: NotImplementedError) { - // Some kinds of descriptor throw in `getSourceFromDescriptor` as that method is not - // normally expected to - // be applied to synthetic functions. - false - } diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/ReferenceEntity.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/ReferenceEntity.kt deleted file mode 100644 index 22e49c974443..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/ReferenceEntity.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.github.codeql.utils - -import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext -import org.jetbrains.kotlin.ir.symbols.* -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name - -fun getClassByFqName(pluginContext: IrPluginContext, fqName: FqName): IrClassSymbol? { - return pluginContext.referenceClass(fqName) -} - -fun getClassByClassId(pluginContext: IrPluginContext, id: ClassId): IrClassSymbol? { - return getClassByFqName(pluginContext, id.asSingleFqName()) -} - -fun getFunctionsByFqName( - pluginContext: IrPluginContext, - pkgName: FqName, - name: Name -): Collection { - val fqName = pkgName.child(name) - return pluginContext.referenceFunctions(fqName) -} - -fun getPropertiesByFqName( - pluginContext: IrPluginContext, - pkgName: FqName, - name: Name -): Collection { - val fqName = pkgName.child(name) - return pluginContext.referenceProperties(fqName) -} diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/SyntheticBodyKind.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/SyntheticBodyKind.kt deleted file mode 100644 index 2d71b430c9f3..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/SyntheticBodyKind.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind - -val kind_ENUM_ENTRIES: IrSyntheticBodyKind? = null diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/Types.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/Types.kt deleted file mode 100644 index 61a580e2a279..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/Types.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.backend.jvm.codegen.isRawType -import org.jetbrains.kotlin.ir.types.IrSimpleType - -fun IrSimpleType.codeQlIsRawType() = this.isRawType() diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/allOverriddenIncludingSelf.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/allOverriddenIncludingSelf.kt deleted file mode 100644 index 24ac7e40f481..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/allOverriddenIncludingSelf.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.backend.common.ir.allOverridden -import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction - -fun IrSimpleFunction.allOverriddenIncludingSelf() = this.allOverridden(includeSelf = true) diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/copyTo.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/copyTo.kt deleted file mode 100644 index a0d46acc56e8..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/copyTo.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.backend.common.ir.copyTo -import org.jetbrains.kotlin.ir.declarations.IrFunction -import org.jetbrains.kotlin.ir.declarations.IrValueParameter - -fun copyParameterToFunction(p: IrValueParameter, f: IrFunction) = p.copyTo(f) diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/createImplicitParameterDeclarationWithWrappedDescriptor.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/createImplicitParameterDeclarationWithWrappedDescriptor.kt deleted file mode 100644 index 36016980af19..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/createImplicitParameterDeclarationWithWrappedDescriptor.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclarationWithWrappedDescriptor -import org.jetbrains.kotlin.ir.declarations.IrClass - -fun IrClass.createImplicitParameterDeclarationWithWrappedDescriptor() = - this.createImplicitParameterDeclarationWithWrappedDescriptor() diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/getFileClassFqName.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/getFileClassFqName.kt deleted file mode 100644 index 4400589ae343..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/getFileClassFqName.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.ir.declarations.IrDeclaration -import org.jetbrains.kotlin.name.FqName - -fun getFileClassFqName(@Suppress("UNUSED_PARAMETER") d: IrDeclaration): FqName? { - return null -} diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/getKotlinType.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/getKotlinType.kt deleted file mode 100644 index 3f21550f13f6..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/getKotlinType.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.ir.types.IrSimpleType -import org.jetbrains.kotlin.ir.types.impl.IrTypeBase - -fun getKotlinType(s: IrSimpleType) = (s as? IrTypeBase)?.kotlinType diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/withHasQuestionMark.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/withHasQuestionMark.kt deleted file mode 100644 index 114391ae6bfe..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/withHasQuestionMark.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.types.withHasQuestionMark - -fun IrType.codeQlWithHasQuestionMark(b: Boolean): IrType { - return this.withHasQuestionMark(b) -} diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_20/IsUnderscoreParameter.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_20/IsUnderscoreParameter.kt deleted file mode 100644 index d727126ffc4a..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_20/IsUnderscoreParameter.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin -import org.jetbrains.kotlin.ir.declarations.IrValueParameter - -fun isUnderscoreParameter(vp: IrValueParameter) = - vp.origin == IrDeclarationOrigin.UNDERSCORE_PARAMETER diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_20/Types.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_20/Types.kt deleted file mode 100644 index 7db5d520b29f..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_20/Types.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.backend.jvm.ir.isRawType -import org.jetbrains.kotlin.ir.types.IrSimpleType - -fun IrSimpleType.codeQlIsRawType() = this.isRawType() diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_0/getFileClassFqName.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_0/getFileClassFqName.kt deleted file mode 100644 index 82275ba0342d..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_0/getFileClassFqName.kt +++ /dev/null @@ -1,41 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.ir.declarations.IrDeclaration -import org.jetbrains.kotlin.ir.declarations.IrField -import org.jetbrains.kotlin.ir.declarations.IrMemberWithContainerSource -import org.jetbrains.kotlin.load.kotlin.FacadeClassSource -import org.jetbrains.kotlin.name.FqName - -fun getFileClassFqName(d: IrDeclaration): FqName? { - // d is in a file class. - // Get the name in a similar way to the compiler's ExternalPackageParentPatcherLowering - // visitMemberAccess/generateOrGetFacadeClass. - - // But first, fields aren't IrMemberWithContainerSource, so we need - // to get back to the property (if there is one) - if (d is IrField) { - val propSym = d.correspondingPropertySymbol - if (propSym != null) { - return getFileClassFqName(propSym.owner) - } - } - - // Now the main code - if (d is IrMemberWithContainerSource) { - val containerSource = d.containerSource - if (containerSource is FacadeClassSource) { - val facadeClassName = containerSource.facadeClassName - if (facadeClassName != null) { - // TODO: This is really a multifile-class rather than a file-class, - // but for now we treat them the same. - return facadeClassName.fqNameForTopLevelClassMaybeWithDollars - } else { - return containerSource.className.fqNameForTopLevelClassMaybeWithDollars - } - } else { - return null - } - } else { - return null - } -} diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_0/withHasQuestionMark.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_0/withHasQuestionMark.kt deleted file mode 100644 index f4e171f8fb2a..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_0/withHasQuestionMark.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.types.makeNotNull -import org.jetbrains.kotlin.ir.types.makeNullable - -fun IrType.codeQlWithHasQuestionMark(b: Boolean): IrType { - if (b) { - return this.makeNullable() - } else { - return this.makeNotNull() - } -} diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_20/allOverriddenIncludingSelf.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_20/allOverriddenIncludingSelf.kt deleted file mode 100644 index 2d33930ecbcf..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_20/allOverriddenIncludingSelf.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction -import org.jetbrains.kotlin.ir.util.allOverridden - -fun IrSimpleFunction.allOverriddenIncludingSelf() = this.allOverridden(includeSelf = true) diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_20/copyTo.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_20/copyTo.kt deleted file mode 100644 index a68e93432470..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_20/copyTo.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.ir.declarations.IrFunction -import org.jetbrains.kotlin.ir.declarations.IrValueParameter -import org.jetbrains.kotlin.ir.util.copyTo - -fun copyParameterToFunction(p: IrValueParameter, f: IrFunction) = p.copyTo(f) diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/CodeQLIrConst.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/CodeQLIrConst.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/CodeQLIrConst.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/CodeQLIrConst.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/CodeQLIsRoot.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/CodeQLIsRoot.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/CodeQLIsRoot.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/CodeQLIsRoot.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/CommentExtractorLighterAST.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/CommentExtractorLighterAST.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/CommentExtractorLighterAST.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/CommentExtractorLighterAST.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/ExperimentalCompilerApi.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/ExperimentalCompilerApi.kt deleted file mode 100644 index 48829cc30c5f..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/ExperimentalCompilerApi.kt +++ /dev/null @@ -1,4 +0,0 @@ -package com.github.codeql - -// The compiler provides the annotation class, so we don't need to do -// anything diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/FirMetadataSourceFirFile.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/FirMetadataSourceFirFile.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/FirMetadataSourceFirFile.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/FirMetadataSourceFirFile.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IrLazyFunction.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/IrLazyFunction.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IrLazyFunction.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/IrLazyFunction.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IrSimpleTypeImplCompat.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/IrSimpleTypeImplCompat.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IrSimpleTypeImplCompat.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/IrSimpleTypeImplCompat.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IrSymbolInternals.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/IrSymbolInternals.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IrSymbolInternals.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/IrSymbolInternals.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IrVisitor.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/IrVisitor.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/IrVisitor.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/IrVisitor.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/JvmDefaultModeIsNoCompatibility.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/JvmDefaultModeIsNoCompatibility.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/JvmDefaultModeIsNoCompatibility.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/JvmDefaultModeIsNoCompatibility.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/Kotlin2ComponentRegistrar.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/Kotlin2ComponentRegistrar.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/Kotlin2ComponentRegistrar.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/Kotlin2ComponentRegistrar.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/LinesOfCodeLighterAST.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/LinesOfCodeLighterAST.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/LinesOfCodeLighterAST.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/LinesOfCodeLighterAST.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/Psi2Ir.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/Psi2Ir.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/Psi2Ir.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/Psi2Ir.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/ReferenceEntity.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/ReferenceEntity.kt deleted file mode 100644 index 666e4e38386a..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/ReferenceEntity.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.github.codeql.utils - -import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext -import org.jetbrains.kotlin.ir.symbols.* -import org.jetbrains.kotlin.name.CallableId -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name - -fun getClassByFqName(pluginContext: IrPluginContext, fqName: FqName): IrClassSymbol? { - val id = ClassId.topLevel(fqName) - return getClassByClassId(pluginContext, id) -} - -fun getClassByClassId(pluginContext: IrPluginContext, id: ClassId): IrClassSymbol? { - return pluginContext.referenceClass(id) -} - -fun getFunctionsByFqName( - pluginContext: IrPluginContext, - pkgName: FqName, - name: Name -): Collection { - val id = CallableId(pkgName, name) - return pluginContext.referenceFunctions(id) -} - -fun getPropertiesByFqName( - pluginContext: IrPluginContext, - pkgName: FqName, - name: Name -): Collection { - val id = CallableId(pkgName, name) - return pluginContext.referenceProperties(id) -} diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/SyntheticBodyKind.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/SyntheticBodyKind.kt deleted file mode 100644 index 4c654282ca78..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/SyntheticBodyKind.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.codeql.utils.versions - -import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind - -val kind_ENUM_ENTRIES: IrSyntheticBodyKind? = IrSyntheticBodyKind.ENUM_ENTRIES diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/UsesK2.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/UsesK2.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/UsesK2.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/UsesK2.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/VirtualFileBasedSourceElement.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/VirtualFileBasedSourceElement.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/VirtualFileBasedSourceElement.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/VirtualFileBasedSourceElement.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_20/createImplicitParameterDeclarationWithWrappedDescriptor.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/createImplicitParameterDeclarationWithWrappedDescriptor.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_20/createImplicitParameterDeclarationWithWrappedDescriptor.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/createImplicitParameterDeclarationWithWrappedDescriptor.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/getJvmDefaultMode.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/getJvmDefaultMode.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/getJvmDefaultMode.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/getJvmDefaultMode.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/getJvmModuleNameForDeserializedDescriptor.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/getJvmModuleNameForDeserializedDescriptor.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/getJvmModuleNameForDeserializedDescriptor.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/getJvmModuleNameForDeserializedDescriptor.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_0/getKotlinType.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/getKotlinType.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_7_0/getKotlinType.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/getKotlinType.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/isDispatchReceiver.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/isDispatchReceiver.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/isDispatchReceiver.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/isDispatchReceiver.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/packageFqName.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/packageFqName.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/packageFqName.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/packageFqName.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/parameterIndexExcludingReceivers.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/parameterIndexExcludingReceivers.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/parameterIndexExcludingReceivers.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/parameterIndexExcludingReceivers.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/parents.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/parents.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/parents.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/parents.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/typeUtils.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/typeUtils.kt similarity index 100% rename from java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_6_0/typeUtils.kt rename to java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/typeUtils.kt From fd11b02d140fb22a8abc66406d7b07c593704eb9 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Mon, 5 Jan 2026 17:15:16 +0100 Subject: [PATCH 12/19] Kotlin: Add additional warning suppresion to v1_9_0 and remove copy in v2_3_0 --- .../v_1_9_0-Beta/Kotlin2ComponentRegistrar.kt | 2 +- .../v_2_3_0-Beta2/Kotlin2ComponentRegistrar.kt | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/Kotlin2ComponentRegistrar.kt diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_9_0-Beta/Kotlin2ComponentRegistrar.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_9_0-Beta/Kotlin2ComponentRegistrar.kt index 323d8e2c2836..e20c45ddc4d4 100644 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_9_0-Beta/Kotlin2ComponentRegistrar.kt +++ b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_9_0-Beta/Kotlin2ComponentRegistrar.kt @@ -1,5 +1,5 @@ // For ComponentRegistrar -@file:Suppress("DEPRECATION") +@file:Suppress("DEPRECATION", "DEPRECATION_ERROR") package com.github.codeql diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/Kotlin2ComponentRegistrar.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/Kotlin2ComponentRegistrar.kt deleted file mode 100644 index e20c45ddc4d4..000000000000 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_3_0-Beta2/Kotlin2ComponentRegistrar.kt +++ /dev/null @@ -1,13 +0,0 @@ -// For ComponentRegistrar -@file:Suppress("DEPRECATION", "DEPRECATION_ERROR") - -package com.github.codeql - -import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar -import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi - -@OptIn(ExperimentalCompilerApi::class) -abstract class Kotlin2ComponentRegistrar : ComponentRegistrar { - override val supportsK2: Boolean - get() = true -} From 0958f3cfb195da2c38bf0f24b9a34679e28b8b27 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Tue, 6 Jan 2026 13:55:48 +0100 Subject: [PATCH 13/19] Kotlin: Do not skip writing of getter and setters if the local deligate is null --- .../src/main/kotlin/KotlinFileExtractor.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index baf0a8382161..f83d887eb56f 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt @@ -2979,19 +2979,19 @@ open class KotlinFileExtractor( // as a workaround to silence warnings for kotlin < 2.3 about the elvis // operator being redundant. // For Kotlin >= 2.3, the cast is redundant, so we need to silence that warning - @Suppress("USELESS_CAST") - val delegate = (s.delegate as IrVariable?) ?: run { - logger.errorElement("Local delegated property is missing delegate", s) - return - } - extractVariable(delegate, callable, blockId, 0) - + val delegate = s.delegate as IrVariable? val propId = tw.getFreshIdLabel() - tw.writeKtProperties(propId, s.name.asString()) - tw.writeHasLocation(propId, locId) - tw.writeKtPropertyDelegates(propId, useVariable(delegate)) + if (delegate == null) { + // This is not expected to happen, as the plugin hooks into the pipeline before IR lowering. + logger.errorElement("Local delegated property is missing delegate", s) + } else { + extractVariable(delegate, callable, blockId, 0) + tw.writeKtProperties(propId, s.name.asString()) + tw.writeHasLocation(propId, locId) + tw.writeKtPropertyDelegates(propId, useVariable(delegate)) + } // Getter: extractStatement(s.getter, callable, blockId, 1) val getterLabel = getLocallyVisibleFunctionLabels(s.getter).function From fdc74b1b6a6f1187323fae04a583c702013342e8 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Thu, 8 Jan 2026 10:04:37 +0100 Subject: [PATCH 14/19] Kotlin: Add changenotes for Kotlin 2.3 support and removal of support for Kotlin 1.6 and 1.7 --- java/ql/lib/change-notes/2026-01-07-kotlin-2_3.md | 4 ++++ .../2026-01-07-kotlin-mimimum_suppoted_version.md | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 java/ql/lib/change-notes/2026-01-07-kotlin-2_3.md create mode 100644 java/ql/lib/change-notes/2026-01-07-kotlin-mimimum_suppoted_version.md diff --git a/java/ql/lib/change-notes/2026-01-07-kotlin-2_3.md b/java/ql/lib/change-notes/2026-01-07-kotlin-2_3.md new file mode 100644 index 000000000000..82253f0e5e8c --- /dev/null +++ b/java/ql/lib/change-notes/2026-01-07-kotlin-2_3.md @@ -0,0 +1,4 @@ +--- +category: feature +--- +* Kotlin versions up to 2.3.0\ *x* are now supported. diff --git a/java/ql/lib/change-notes/2026-01-07-kotlin-mimimum_suppoted_version.md b/java/ql/lib/change-notes/2026-01-07-kotlin-mimimum_suppoted_version.md new file mode 100644 index 000000000000..6877579f6c67 --- /dev/null +++ b/java/ql/lib/change-notes/2026-01-07-kotlin-mimimum_suppoted_version.md @@ -0,0 +1,4 @@ +--- +category: breaking +--- +* Support for Kotlin 1.6.x and 1.7.x series has been dropped From 4213ca410815ee31bc2e9fa286d1a9ee87e5823d Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Wed, 7 Jan 2026 10:16:31 +0100 Subject: [PATCH 15/19] Kotlin: Bump versions in documentation --- docs/codeql/reusables/supported-versions-compilers.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/codeql/reusables/supported-versions-compilers.rst b/docs/codeql/reusables/supported-versions-compilers.rst index c03713bdce25..fd937fe4ac02 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 25 [6]_","javac (OpenJDK and Oracle JDK), Eclipse compiler for Java (ECJ) [7]_",``.java`` - Kotlin,"Kotlin 1.6.0 [15]_ to 2.2.2\ *x*","kotlinc",``.kt`` + Kotlin,"Kotlin 1.8.0 to 2.3.0\ *x*","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`` [8]_" 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`` Ruby [10]_,"up to 3.3",Not applicable,"``.rb``, ``.erb``, ``.gemspec``, ``Gemfile``" @@ -45,4 +45,3 @@ .. [12] Support for the analysis of Swift requires macOS. .. [13] Embedded Swift is not supported. .. [14] TypeScript analysis is performed by running the JavaScript extractor with TypeScript enabled. This is the default. - .. [15] Support for Kotlin versions 1.6 and 1.7 is deprecated and will be removed in release 2.24.1. From d21ab18b9d5de1d4aab668a194a82f6c99d1113d Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Wed, 7 Jan 2026 10:59:00 +0100 Subject: [PATCH 16/19] Kotlin: Bump default version --- 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 aeef81e5c1d2..3f09ea53a4f0 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.2.0" +DEFAULT_VERSION = "2.3.0-Beta2" def options(): From 799140dc8fa6a8c0bcfb996ac7883326b03f00ba Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Wed, 7 Jan 2026 11:23:10 +0100 Subject: [PATCH 17/19] Kotlin: Bump upper bound for supported kotlin version in integration test --- .../diagnostics/kotlin-version-too-new/diagnostics.expected | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 50cbd2609f26..5ef0ef541962 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.2.30.", + "markdownMessage": "The Kotlin version installed (`999.999.999`) is too recent for this version of CodeQL. Install a version lower than 2.3.10.", "severity": "error", "source": { "extractorName": "java", From 536a84cf72cf72f69245aca799a6bbe9ce50719c Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Thu, 8 Jan 2026 09:59:31 +0100 Subject: [PATCH 18/19] Kotlin: Update kotlin compiler version in integration tests --- .../kotlin/all-platforms/compiler_arguments/app/build.gradle | 2 +- .../kotlin/all-platforms/gradle_groovy_app/app/build.gradle | 2 +- .../kotlin/all-platforms/kotlin_kfunction/app/build.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/java/ql/integration-tests/kotlin/all-platforms/compiler_arguments/app/build.gradle b/java/ql/integration-tests/kotlin/all-platforms/compiler_arguments/app/build.gradle index c0bc33405247..8b91012467ec 100644 --- a/java/ql/integration-tests/kotlin/all-platforms/compiler_arguments/app/build.gradle +++ b/java/ql/integration-tests/kotlin/all-platforms/compiler_arguments/app/build.gradle @@ -8,7 +8,7 @@ plugins { // Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin. - id 'org.jetbrains.kotlin.jvm' version '1.7.0' + id 'org.jetbrains.kotlin.jvm' version '1.8.0' // Apply the application plugin to add support for building a CLI application in Java. id 'application' diff --git a/java/ql/integration-tests/kotlin/all-platforms/gradle_groovy_app/app/build.gradle b/java/ql/integration-tests/kotlin/all-platforms/gradle_groovy_app/app/build.gradle index 8ef1009376c9..8b91012467ec 100644 --- a/java/ql/integration-tests/kotlin/all-platforms/gradle_groovy_app/app/build.gradle +++ b/java/ql/integration-tests/kotlin/all-platforms/gradle_groovy_app/app/build.gradle @@ -8,7 +8,7 @@ plugins { // Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin. - id 'org.jetbrains.kotlin.jvm' version '1.6.0' + id 'org.jetbrains.kotlin.jvm' version '1.8.0' // Apply the application plugin to add support for building a CLI application in Java. id 'application' diff --git a/java/ql/integration-tests/kotlin/all-platforms/kotlin_kfunction/app/build.gradle b/java/ql/integration-tests/kotlin/all-platforms/kotlin_kfunction/app/build.gradle index 924524190cff..8b91012467ec 100644 --- a/java/ql/integration-tests/kotlin/all-platforms/kotlin_kfunction/app/build.gradle +++ b/java/ql/integration-tests/kotlin/all-platforms/kotlin_kfunction/app/build.gradle @@ -8,7 +8,7 @@ plugins { // Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin. - id 'org.jetbrains.kotlin.jvm' version '1.6.20' + id 'org.jetbrains.kotlin.jvm' version '1.8.0' // Apply the application plugin to add support for building a CLI application in Java. id 'application' From b19a38781bf3fc89ce7350bf9c483a9ecf999342 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Thu, 8 Jan 2026 10:02:45 +0100 Subject: [PATCH 19/19] Kotlin: Update kotlin serialization integration test to use Kotlin compiler 1.8.10 and accept test changes --- .../PrintAst.expected | 476 +----------------- .../app/build.gradle | 7 +- .../diag.expected | 2 - 3 files changed, 15 insertions(+), 470 deletions(-) diff --git a/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/PrintAst.expected b/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/PrintAst.expected index 752db3cd6471..3fe2e593cef8 100644 --- a/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/PrintAst.expected +++ b/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/PrintAst.expected @@ -21,35 +21,6 @@ app/src/main/kotlin/testProject/App.kt: # 0| 0: [TypeAccess] int # 0| 3: [Parameter] serializationConstructorMarker # 0| 0: [TypeAccess] SerializationConstructorMarker -# 7| 5: [BlockStmt] { ... } -# 7| 0: [ExprStmt] ; -# 7| 0: [WhenExpr] when ... -# 7| 0: [WhenBranch] ... -> ... -# 7| 0: [ValueNEExpr] ... (value not-equals) ... -# 7| 0: [IntegerLiteral] 3 -# 7| 1: [AndBitwiseExpr] ... & ... -# 7| 0: [IntegerLiteral] 3 -# 7| 1: [VarAccess] seen1 -# 7| 1: [ExprStmt] ; -# 7| 0: [MethodCall] throwMissingFieldException(...) -# 7| -1: [TypeAccess] PluginExceptionsKt -# 7| 0: [VarAccess] seen1 -# 7| 1: [IntegerLiteral] 3 -# 7| 2: [MethodCall] getDescriptor(...) -# 7| -1: [VarAccess] INSTANCE -# 7| 1: [SuperConstructorInvocationStmt] super(...) -# 7| 2: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] Project.this.name -# 7| -1: [ThisAccess] Project.this -# 7| 0: [TypeAccess] Project -# 7| 1: [VarAccess] name -# 7| 3: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] Project.this.language -# 7| -1: [ThisAccess] Project.this -# 7| 0: [TypeAccess] Project -# 7| 1: [VarAccess] language # 0| 2: [Method] component1 #-----| 1: (Annotations) # 0| 1: [Annotation] NotNull @@ -224,21 +195,6 @@ app/src/main/kotlin/testProject/App.kt: #-----| -1: (Annotations) # 0| 1: [Annotation] NotNull # 0| 0: [TypeAccess] SerialDescriptor -# 7| 5: [BlockStmt] { ... } -# 7| 0: [ExprStmt] ; -# 7| 0: [MethodCall] encodeStringElement(...) -# 7| -1: [VarAccess] output -# 7| 0: [VarAccess] serialDesc -# 7| 1: [IntegerLiteral] 0 -# 7| 2: [MethodCall] getName(...) -# 7| -1: [VarAccess] self -# 7| 1: [ExprStmt] ; -# 7| 0: [MethodCall] encodeIntElement(...) -# 7| -1: [VarAccess] output -# 7| 0: [VarAccess] serialDesc -# 7| 1: [IntegerLiteral] 1 -# 7| 2: [MethodCall] getLanguage(...) -# 7| -1: [VarAccess] self # 7| 10: [Class] $serializer #-----| -3: (Annotations) # 0| 1: [Annotation] Deprecated @@ -248,21 +204,13 @@ app/src/main/kotlin/testProject/App.kt: # 0| 2: [ArrayInit] {...} # 0| 3: [VarAccess] DeprecationLevel.HIDDEN # 0| -1: [TypeAccess] DeprecationLevel -# 0| 1: [FieldDeclaration] SerialDescriptor descriptor; -# 0| -1: [TypeAccess] SerialDescriptor -# 0| 2: [Method] childSerializers +# 0| 1: [Method] childSerializers #-----| 1: (Annotations) # 0| 1: [Annotation] NotNull # 0| 3: [TypeAccess] KSerializer[] # 0| 0: [TypeAccess] KSerializer # 0| 0: [WildcardTypeAccess] ? ... -# 7| 5: [BlockStmt] { ... } -# 7| 0: [ReturnStmt] return ... -# 7| 0: [ArrayCreationExpr] new KSerializer[] -# 7| -2: [ArrayInit] {...} -# 7| -1: [TypeAccess] KSerializer -# 7| 0: [IntegerLiteral] 2 -# 0| 3: [Method] deserialize +# 0| 2: [Method] deserialize #-----| 1: (Annotations) # 0| 1: [Annotation] NotNull # 0| 3: [TypeAccess] Project @@ -271,148 +219,11 @@ app/src/main/kotlin/testProject/App.kt: #-----| -1: (Annotations) # 0| 1: [Annotation] NotNull # 0| 0: [TypeAccess] Decoder -# 7| 5: [BlockStmt] { ... } -# 7| 0: [LocalVariableDeclStmt] var ...; -# 7| 1: [LocalVariableDeclExpr] tmp0_desc -# 7| 0: [MethodCall] getDescriptor(...) -# 7| -1: [ThisAccess] this -# 7| 1: [LocalVariableDeclStmt] var ...; -# 7| 1: [LocalVariableDeclExpr] tmp1_flag -# 7| 0: [BooleanLiteral] true -# 7| 2: [LocalVariableDeclStmt] var ...; -# 7| 1: [LocalVariableDeclExpr] tmp2_index -# 7| 0: [IntegerLiteral] 0 -# 7| 3: [LocalVariableDeclStmt] var ...; -# 7| 1: [LocalVariableDeclExpr] tmp3_bitMask0 -# 7| 0: [IntegerLiteral] 0 -# 7| 4: [LocalVariableDeclStmt] var ...; -# 7| 1: [LocalVariableDeclExpr] tmp4_local0 -# 7| 0: [NullLiteral] null -# 7| 5: [LocalVariableDeclStmt] var ...; -# 7| 1: [LocalVariableDeclExpr] tmp5_local1 -# 7| 0: [IntegerLiteral] 0 -# 7| 6: [LocalVariableDeclStmt] var ...; -# 7| 1: [LocalVariableDeclExpr] tmp6_input -# 7| 0: [MethodCall] beginStructure(...) -# 7| -1: [VarAccess] decoder -# 7| 0: [VarAccess] tmp0_desc -# 7| 7: [ExprStmt] ; -# 7| 0: [WhenExpr] when ... -# 7| 0: [WhenBranch] ... -> ... -# 7| 0: [MethodCall] decodeSequentially(...) -# 7| -1: [VarAccess] tmp6_input -# 7| 1: [BlockStmt] { ... } -# 7| 0: [BlockStmt] { ... } -# 7| 0: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] tmp4_local0 -# 7| 1: [MethodCall] decodeStringElement(...) -# 7| -1: [VarAccess] tmp6_input -# 7| 0: [VarAccess] tmp0_desc -# 7| 1: [IntegerLiteral] 0 -# 7| 1: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] tmp3_bitMask0 -# 7| 1: [OrBitwiseExpr] ... | ... -# 7| 0: [VarAccess] tmp3_bitMask0 -# 7| 1: [IntegerLiteral] 1 -# 7| 1: [BlockStmt] { ... } -# 7| 0: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] tmp5_local1 -# 7| 1: [MethodCall] decodeIntElement(...) -# 7| -1: [VarAccess] tmp6_input -# 7| 0: [VarAccess] tmp0_desc -# 7| 1: [IntegerLiteral] 1 -# 7| 1: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] tmp3_bitMask0 -# 7| 1: [OrBitwiseExpr] ... | ... -# 7| 0: [VarAccess] tmp3_bitMask0 -# 7| 1: [IntegerLiteral] 2 -# 7| 1: [WhenBranch] ... -> ... -# 7| 0: [BooleanLiteral] true -# 7| 1: [WhileStmt] while (...) -# 7| 0: [VarAccess] tmp1_flag -# 7| 1: [BlockStmt] { ... } -# 7| 0: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] tmp2_index -# 7| 1: [MethodCall] decodeElementIndex(...) -# 7| -1: [VarAccess] tmp6_input -# 7| 0: [VarAccess] tmp0_desc -# 7| 1: [ExprStmt] ; -# 7| 0: [WhenExpr] when ... -# 7| 0: [WhenBranch] ... -> ... -# 7| 0: [ValueEQExpr] ... (value equals) ... -# 7| 0: [VarAccess] tmp2_index -# 7| 1: [IntegerLiteral] -1 -# 7| 1: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] tmp1_flag -# 7| 1: [BooleanLiteral] false -# 7| 1: [WhenBranch] ... -> ... -# 7| 0: [ValueEQExpr] ... (value equals) ... -# 7| 0: [VarAccess] tmp2_index -# 7| 1: [IntegerLiteral] 0 -# 7| 1: [BlockStmt] { ... } -# 7| 0: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] tmp4_local0 -# 7| 1: [MethodCall] decodeStringElement(...) -# 7| -1: [VarAccess] tmp6_input -# 7| 0: [VarAccess] tmp0_desc -# 7| 1: [IntegerLiteral] 0 -# 7| 1: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] tmp3_bitMask0 -# 7| 1: [OrBitwiseExpr] ... | ... -# 7| 0: [VarAccess] tmp3_bitMask0 -# 7| 1: [IntegerLiteral] 1 -# 7| 2: [WhenBranch] ... -> ... -# 7| 0: [ValueEQExpr] ... (value equals) ... -# 7| 0: [VarAccess] tmp2_index -# 7| 1: [IntegerLiteral] 1 -# 7| 1: [BlockStmt] { ... } -# 7| 0: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] tmp5_local1 -# 7| 1: [MethodCall] decodeIntElement(...) -# 7| -1: [VarAccess] tmp6_input -# 7| 0: [VarAccess] tmp0_desc -# 7| 1: [IntegerLiteral] 1 -# 7| 1: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] tmp3_bitMask0 -# 7| 1: [OrBitwiseExpr] ... | ... -# 7| 0: [VarAccess] tmp3_bitMask0 -# 7| 1: [IntegerLiteral] 2 -# 7| 3: [WhenBranch] ... -> ... -# 7| 0: [BooleanLiteral] true -# 7| 1: [ThrowStmt] throw ... -# 7| 0: [ClassInstanceExpr] new UnknownFieldException(...) -# 7| -3: [TypeAccess] UnknownFieldException -# 7| 0: [VarAccess] tmp2_index -# 7| 8: [ExprStmt] ; -# 7| 0: [MethodCall] endStructure(...) -# 7| -1: [VarAccess] tmp6_input -# 7| 0: [VarAccess] tmp0_desc -# 7| 9: [ReturnStmt] return ... -# 7| 0: [ClassInstanceExpr] new Project(...) -# 7| -3: [TypeAccess] Project -# 7| 0: [VarAccess] tmp3_bitMask0 -# 7| 1: [VarAccess] tmp4_local0 -# 7| 2: [VarAccess] tmp5_local1 -# 7| 3: [NullLiteral] null -# 0| 4: [Method] getDescriptor +# 0| 3: [Method] getDescriptor #-----| 1: (Annotations) # 0| 1: [Annotation] NotNull # 0| 3: [TypeAccess] SerialDescriptor -# 0| 5: [BlockStmt] { ... } -# 0| 0: [ReturnStmt] return ... -# 0| 0: [VarAccess] this.descriptor -# 0| -1: [ThisAccess] this -# 0| 5: [Method] serialize +# 0| 4: [Method] serialize # 0| 3: [TypeAccess] Unit #-----| 4: (Parameters) # 0| 0: [Parameter] encoder @@ -423,55 +234,11 @@ app/src/main/kotlin/testProject/App.kt: #-----| -1: (Annotations) # 0| 1: [Annotation] NotNull # 0| 0: [TypeAccess] Project -# 7| 5: [BlockStmt] { ... } -# 7| 0: [LocalVariableDeclStmt] var ...; -# 7| 1: [LocalVariableDeclExpr] tmp0_desc -# 7| 0: [MethodCall] getDescriptor(...) -# 7| -1: [ThisAccess] this -# 7| 1: [LocalVariableDeclStmt] var ...; -# 7| 1: [LocalVariableDeclExpr] tmp1_output -# 7| 0: [MethodCall] beginStructure(...) -# 7| -1: [VarAccess] encoder -# 7| 0: [VarAccess] tmp0_desc -# 7| 2: [ExprStmt] ; -# 7| 0: [MethodCall] write$Self(...) -# 7| -1: [TypeAccess] Project -# 7| 0: [VarAccess] value -# 7| 1: [VarAccess] tmp1_output -# 7| 2: [VarAccess] tmp0_desc -# 7| 3: [ExprStmt] ; -# 7| 0: [MethodCall] endStructure(...) -# 7| -1: [VarAccess] tmp1_output -# 7| 0: [VarAccess] tmp0_desc -# 7| 6: [Constructor] $serializer +# 7| 5: [Constructor] $serializer # 7| 5: [BlockStmt] { ... } # 7| 0: [SuperConstructorInvocationStmt] super(...) # 7| 1: [BlockStmt] { ... } -# 7| 0: [LocalVariableDeclStmt] var ...; -# 7| 1: [LocalVariableDeclExpr] tmp0_serialDesc -# 7| 0: [ClassInstanceExpr] new PluginGeneratedSerialDescriptor(...) -# 7| -3: [TypeAccess] PluginGeneratedSerialDescriptor -# 7| 0: [StringLiteral] "testProject.Project" -# 7| 1: [ThisAccess] $serializer.this -# 7| 0: [TypeAccess] $serializer -# 7| 2: [IntegerLiteral] 2 -# 7| 1: [ExprStmt] ; -# 7| 0: [MethodCall] addElement(...) -# 7| -1: [VarAccess] tmp0_serialDesc -# 7| 0: [StringLiteral] "name" -# 7| 1: [BooleanLiteral] false -# 7| 2: [ExprStmt] ; -# 7| 0: [MethodCall] addElement(...) -# 7| -1: [VarAccess] tmp0_serialDesc -# 7| 0: [StringLiteral] "language" -# 7| 1: [BooleanLiteral] false -# 7| 3: [ExprStmt] ; -# 7| 0: [AssignExpr] ...=... -# 7| 0: [VarAccess] $serializer.this.descriptor -# 7| -1: [ThisAccess] $serializer.this -# 7| 0: [TypeAccess] $serializer -# 7| 1: [VarAccess] tmp0_serialDesc -# 7| 7: [Method] typeParametersSerializers +# 7| 6: [Method] typeParametersSerializers # 7| 3: [TypeAccess] KSerializer[] # 7| 0: [TypeAccess] KSerializer # 7| 0: [WildcardTypeAccess] ? ... @@ -486,9 +253,6 @@ app/src/main/kotlin/testProject/App.kt: # 0| 1: [Annotation] NotNull # 0| 3: [TypeAccess] KSerializer # 0| 0: [TypeAccess] Project -# 7| 5: [BlockStmt] { ... } -# 7| 0: [ReturnStmt] return ... -# 7| 0: [VarAccess] INSTANCE # 7| 2: [Constructor] Companion # 7| 5: [BlockStmt] { ... } # 7| 0: [SuperConstructorInvocationStmt] super(...) @@ -554,45 +318,6 @@ app/src/main/kotlin/testProject/App.kt: # 0| 0: [TypeAccess] String # 0| 2: [Parameter] serializationConstructorMarker # 0| 0: [TypeAccess] SerializationConstructorMarker -# 14| 5: [BlockStmt] { ... } -# 14| 0: [ExprStmt] ; -# 14| 0: [WhenExpr] when ... -# 14| 0: [WhenBranch] ... -> ... -# 14| 0: [ValueNEExpr] ... (value not-equals) ... -# 14| 0: [IntegerLiteral] 0 -# 14| 1: [AndBitwiseExpr] ... & ... -# 14| 0: [IntegerLiteral] 0 -# 14| 1: [VarAccess] seen1 -# 14| 1: [ExprStmt] ; -# 14| 0: [MethodCall] throwMissingFieldException(...) -# 14| -1: [TypeAccess] PluginExceptionsKt -# 14| 0: [VarAccess] seen1 -# 14| 1: [IntegerLiteral] 0 -# 14| 2: [MethodCall] getDescriptor(...) -# 14| -1: [VarAccess] INSTANCE -# 14| 1: [SuperConstructorInvocationStmt] super(...) -# 14| 2: [ExprStmt] ; -# 14| 0: [WhenExpr] when ... -# 14| 0: [WhenBranch] ... -> ... -# 14| 0: [ValueEQExpr] ... (value equals) ... -# 14| 0: [IntegerLiteral] 0 -# 14| 1: [AndBitwiseExpr] ... & ... -# 14| 0: [VarAccess] seen1 -# 14| 1: [IntegerLiteral] 1 -# 14| 1: [ExprStmt] ; -# 14| 0: [AssignExpr] ...=... -# 14| 0: [VarAccess] X.this.id -# 14| -1: [ThisAccess] X.this -# 14| 0: [TypeAccess] X -# 16| 1: [StringLiteral] "X" -# 14| 1: [WhenBranch] ... -> ... -# 14| 0: [BooleanLiteral] true -# 14| 1: [ExprStmt] ; -# 14| 0: [AssignExpr] ...=... -# 14| 0: [VarAccess] X.this.id -# 14| -1: [ThisAccess] X.this -# 14| 0: [TypeAccess] X -# 14| 1: [VarAccess] id # 0| 2: [Method] write$Self #-----| 1: (Annotations) # 0| 1: [Annotation] JvmStatic @@ -610,32 +335,6 @@ app/src/main/kotlin/testProject/App.kt: #-----| -1: (Annotations) # 0| 1: [Annotation] NotNull # 0| 0: [TypeAccess] SerialDescriptor -# 14| 5: [BlockStmt] { ... } -# 14| 0: [ExprStmt] ; -# 14| 0: [WhenExpr] when ... -# 14| 0: [WhenBranch] ... -> ... -# 14| 0: [WhenExpr] when ... -# 14| 0: [WhenBranch] ... -> ... -# 14| 0: [MethodCall] shouldEncodeElementDefault(...) -# 14| -1: [VarAccess] output -# 14| 0: [VarAccess] serialDesc -# 14| 1: [IntegerLiteral] 0 -# 14| 1: [ExprStmt] ; -# 14| 0: [BooleanLiteral] true -# 14| 1: [WhenBranch] ... -> ... -# 14| 0: [BooleanLiteral] true -# 14| 1: [ExprStmt] ; -# 14| 0: [ValueNEExpr] ... (value not-equals) ... -# 14| 0: [MethodCall] getId(...) -# 14| -1: [VarAccess] self -# 16| 1: [StringLiteral] "X" -# 14| 1: [ExprStmt] ; -# 14| 0: [MethodCall] encodeStringElement(...) -# 14| -1: [VarAccess] output -# 14| 0: [VarAccess] serialDesc -# 14| 1: [IntegerLiteral] 0 -# 14| 2: [MethodCall] getId(...) -# 14| -1: [VarAccess] self # 14| 3: [Class] $serializer #-----| -3: (Annotations) # 0| 1: [Annotation] Deprecated @@ -645,21 +344,13 @@ app/src/main/kotlin/testProject/App.kt: # 0| 2: [ArrayInit] {...} # 0| 3: [VarAccess] DeprecationLevel.HIDDEN # 0| -1: [TypeAccess] DeprecationLevel -# 0| 1: [FieldDeclaration] SerialDescriptor descriptor; -# 0| -1: [TypeAccess] SerialDescriptor -# 0| 2: [Method] childSerializers +# 0| 1: [Method] childSerializers #-----| 1: (Annotations) # 0| 1: [Annotation] NotNull # 0| 3: [TypeAccess] KSerializer[] # 0| 0: [TypeAccess] KSerializer # 0| 0: [WildcardTypeAccess] ? ... -# 14| 5: [BlockStmt] { ... } -# 14| 0: [ReturnStmt] return ... -# 14| 0: [ArrayCreationExpr] new KSerializer[] -# 14| -2: [ArrayInit] {...} -# 14| -1: [TypeAccess] KSerializer -# 14| 0: [IntegerLiteral] 1 -# 0| 3: [Method] deserialize +# 0| 2: [Method] deserialize #-----| 1: (Annotations) # 0| 1: [Annotation] NotNull # 0| 3: [TypeAccess] X @@ -668,112 +359,11 @@ app/src/main/kotlin/testProject/App.kt: #-----| -1: (Annotations) # 0| 1: [Annotation] NotNull # 0| 0: [TypeAccess] Decoder -# 14| 5: [BlockStmt] { ... } -# 14| 0: [LocalVariableDeclStmt] var ...; -# 14| 1: [LocalVariableDeclExpr] tmp0_desc -# 14| 0: [MethodCall] getDescriptor(...) -# 14| -1: [ThisAccess] this -# 14| 1: [LocalVariableDeclStmt] var ...; -# 14| 1: [LocalVariableDeclExpr] tmp1_flag -# 14| 0: [BooleanLiteral] true -# 14| 2: [LocalVariableDeclStmt] var ...; -# 14| 1: [LocalVariableDeclExpr] tmp2_index -# 14| 0: [IntegerLiteral] 0 -# 14| 3: [LocalVariableDeclStmt] var ...; -# 14| 1: [LocalVariableDeclExpr] tmp3_bitMask0 -# 14| 0: [IntegerLiteral] 0 -# 14| 4: [LocalVariableDeclStmt] var ...; -# 14| 1: [LocalVariableDeclExpr] tmp4_local0 -# 14| 0: [NullLiteral] null -# 14| 5: [LocalVariableDeclStmt] var ...; -# 14| 1: [LocalVariableDeclExpr] tmp5_input -# 14| 0: [MethodCall] beginStructure(...) -# 14| -1: [VarAccess] decoder -# 14| 0: [VarAccess] tmp0_desc -# 14| 6: [ExprStmt] ; -# 14| 0: [WhenExpr] when ... -# 14| 0: [WhenBranch] ... -> ... -# 14| 0: [MethodCall] decodeSequentially(...) -# 14| -1: [VarAccess] tmp5_input -# 14| 1: [BlockStmt] { ... } -# 14| 0: [BlockStmt] { ... } -# 14| 0: [ExprStmt] ; -# 14| 0: [AssignExpr] ...=... -# 14| 0: [VarAccess] tmp4_local0 -# 14| 1: [MethodCall] decodeStringElement(...) -# 14| -1: [VarAccess] tmp5_input -# 14| 0: [VarAccess] tmp0_desc -# 14| 1: [IntegerLiteral] 0 -# 14| 1: [ExprStmt] ; -# 14| 0: [AssignExpr] ...=... -# 14| 0: [VarAccess] tmp3_bitMask0 -# 14| 1: [OrBitwiseExpr] ... | ... -# 14| 0: [VarAccess] tmp3_bitMask0 -# 14| 1: [IntegerLiteral] 1 -# 14| 1: [WhenBranch] ... -> ... -# 14| 0: [BooleanLiteral] true -# 14| 1: [WhileStmt] while (...) -# 14| 0: [VarAccess] tmp1_flag -# 14| 1: [BlockStmt] { ... } -# 14| 0: [ExprStmt] ; -# 14| 0: [AssignExpr] ...=... -# 14| 0: [VarAccess] tmp2_index -# 14| 1: [MethodCall] decodeElementIndex(...) -# 14| -1: [VarAccess] tmp5_input -# 14| 0: [VarAccess] tmp0_desc -# 14| 1: [ExprStmt] ; -# 14| 0: [WhenExpr] when ... -# 14| 0: [WhenBranch] ... -> ... -# 14| 0: [ValueEQExpr] ... (value equals) ... -# 14| 0: [VarAccess] tmp2_index -# 14| 1: [IntegerLiteral] -1 -# 14| 1: [ExprStmt] ; -# 14| 0: [AssignExpr] ...=... -# 14| 0: [VarAccess] tmp1_flag -# 14| 1: [BooleanLiteral] false -# 14| 1: [WhenBranch] ... -> ... -# 14| 0: [ValueEQExpr] ... (value equals) ... -# 14| 0: [VarAccess] tmp2_index -# 14| 1: [IntegerLiteral] 0 -# 14| 1: [BlockStmt] { ... } -# 14| 0: [ExprStmt] ; -# 14| 0: [AssignExpr] ...=... -# 14| 0: [VarAccess] tmp4_local0 -# 14| 1: [MethodCall] decodeStringElement(...) -# 14| -1: [VarAccess] tmp5_input -# 14| 0: [VarAccess] tmp0_desc -# 14| 1: [IntegerLiteral] 0 -# 14| 1: [ExprStmt] ; -# 14| 0: [AssignExpr] ...=... -# 14| 0: [VarAccess] tmp3_bitMask0 -# 14| 1: [OrBitwiseExpr] ... | ... -# 14| 0: [VarAccess] tmp3_bitMask0 -# 14| 1: [IntegerLiteral] 1 -# 14| 2: [WhenBranch] ... -> ... -# 14| 0: [BooleanLiteral] true -# 14| 1: [ThrowStmt] throw ... -# 14| 0: [ClassInstanceExpr] new UnknownFieldException(...) -# 14| -3: [TypeAccess] UnknownFieldException -# 14| 0: [VarAccess] tmp2_index -# 14| 7: [ExprStmt] ; -# 14| 0: [MethodCall] endStructure(...) -# 14| -1: [VarAccess] tmp5_input -# 14| 0: [VarAccess] tmp0_desc -# 14| 8: [ReturnStmt] return ... -# 14| 0: [ClassInstanceExpr] new X(...) -# 14| -3: [TypeAccess] X -# 14| 0: [VarAccess] tmp3_bitMask0 -# 14| 1: [VarAccess] tmp4_local0 -# 14| 2: [NullLiteral] null -# 0| 4: [Method] getDescriptor +# 0| 3: [Method] getDescriptor #-----| 1: (Annotations) # 0| 1: [Annotation] NotNull # 0| 3: [TypeAccess] SerialDescriptor -# 0| 5: [BlockStmt] { ... } -# 0| 0: [ReturnStmt] return ... -# 0| 0: [VarAccess] this.descriptor -# 0| -1: [ThisAccess] this -# 0| 5: [Method] serialize +# 0| 4: [Method] serialize # 0| 3: [TypeAccess] Unit #-----| 4: (Parameters) # 0| 0: [Parameter] encoder @@ -784,50 +374,11 @@ app/src/main/kotlin/testProject/App.kt: #-----| -1: (Annotations) # 0| 1: [Annotation] NotNull # 0| 0: [TypeAccess] X -# 14| 5: [BlockStmt] { ... } -# 14| 0: [LocalVariableDeclStmt] var ...; -# 14| 1: [LocalVariableDeclExpr] tmp0_desc -# 14| 0: [MethodCall] getDescriptor(...) -# 14| -1: [ThisAccess] this -# 14| 1: [LocalVariableDeclStmt] var ...; -# 14| 1: [LocalVariableDeclExpr] tmp1_output -# 14| 0: [MethodCall] beginStructure(...) -# 14| -1: [VarAccess] encoder -# 14| 0: [VarAccess] tmp0_desc -# 14| 2: [ExprStmt] ; -# 14| 0: [MethodCall] write$Self(...) -# 14| -1: [TypeAccess] X -# 14| 0: [VarAccess] value -# 14| 1: [VarAccess] tmp1_output -# 14| 2: [VarAccess] tmp0_desc -# 14| 3: [ExprStmt] ; -# 14| 0: [MethodCall] endStructure(...) -# 14| -1: [VarAccess] tmp1_output -# 14| 0: [VarAccess] tmp0_desc -# 14| 6: [Constructor] $serializer +# 14| 5: [Constructor] $serializer # 14| 5: [BlockStmt] { ... } # 14| 0: [SuperConstructorInvocationStmt] super(...) # 14| 1: [BlockStmt] { ... } -# 14| 0: [LocalVariableDeclStmt] var ...; -# 14| 1: [LocalVariableDeclExpr] tmp0_serialDesc -# 14| 0: [ClassInstanceExpr] new PluginGeneratedSerialDescriptor(...) -# 14| -3: [TypeAccess] PluginGeneratedSerialDescriptor -# 14| 0: [StringLiteral] "testProject.X" -# 14| 1: [ThisAccess] $serializer.this -# 14| 0: [TypeAccess] $serializer -# 14| 2: [IntegerLiteral] 1 -# 14| 1: [ExprStmt] ; -# 14| 0: [MethodCall] addElement(...) -# 14| -1: [VarAccess] tmp0_serialDesc -# 14| 0: [StringLiteral] "id" -# 14| 1: [BooleanLiteral] true -# 14| 2: [ExprStmt] ; -# 14| 0: [AssignExpr] ...=... -# 14| 0: [VarAccess] $serializer.this.descriptor -# 14| -1: [ThisAccess] $serializer.this -# 14| 0: [TypeAccess] $serializer -# 14| 1: [VarAccess] tmp0_serialDesc -# 14| 7: [Method] typeParametersSerializers +# 14| 6: [Method] typeParametersSerializers # 14| 3: [TypeAccess] KSerializer[] # 14| 0: [TypeAccess] KSerializer # 14| 0: [WildcardTypeAccess] ? ... @@ -842,9 +393,6 @@ app/src/main/kotlin/testProject/App.kt: # 0| 1: [Annotation] NotNull # 0| 3: [TypeAccess] KSerializer # 0| 0: [TypeAccess] X -# 14| 5: [BlockStmt] { ... } -# 14| 0: [ReturnStmt] return ... -# 14| 0: [VarAccess] INSTANCE # 14| 2: [Constructor] Companion # 14| 5: [BlockStmt] { ... } # 14| 0: [SuperConstructorInvocationStmt] super(...) diff --git a/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/app/build.gradle b/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/app/build.gradle index 528b73cabc5a..2b13663941d1 100644 --- a/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/app/build.gradle +++ b/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/app/build.gradle @@ -1,6 +1,6 @@ plugins { - id 'org.jetbrains.kotlin.jvm' version '1.6.10' - id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.10' + id 'org.jetbrains.kotlin.jvm' version '1.8.10' + id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.10' } repositories { @@ -8,6 +8,5 @@ repositories { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-serialization:1.6.10" - implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2" + implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0" } diff --git a/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/diag.expected b/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/diag.expected index 96a297f9cb28..e69de29bb2d1 100644 --- a/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/diag.expected +++ b/java/ql/integration-tests/kotlin/all-platforms/gradle_kotlinx_serialization/diag.expected @@ -1,2 +0,0 @@ -| CodeQL Kotlin extractor | 5 | | Unbound symbol found, skipping extraction of expression | app/src/main/kotlin/testProject/App.kt:7:1:8:55 | app/src/main/kotlin/testProject/App.kt:7:1:8:55 | -| CodeQL Kotlin extractor | 5 | | Unbound symbol found, skipping extraction of expression | app/src/main/kotlin/testProject/App.kt:14:1:17:1 | app/src/main/kotlin/testProject/App.kt:14:1:17:1 |