Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Kotlin: Support Kotlin 2.3.0-Beta2#20965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
andersfugmann wants to merge6 commits intomain
base:main
Choose a base branch
Loading
fromandersfugmann/kotlin_2.3.0-beta2
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletionsMODULE.bazel
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.19.2-codeql.1")
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
Expand DownExpand Up@@ -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",
Expand All@@ -234,10 +230,7 @@ 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-2.3.0-Beta2",
"kotlin-compiler-embeddable-1.8.0",
"kotlin-compiler-embeddable-1.9.0-Beta",
"kotlin-compiler-embeddable-1.9.20-Beta",
Expand All@@ -247,10 +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-stdlib-1.6.0",
"kotlin-stdlib-1.6.20",
"kotlin-stdlib-1.7.0",
"kotlin-stdlib-1.7.20",
"kotlin-compiler-embeddable-2.3.0-Beta2",
"kotlin-stdlib-1.8.0",
"kotlin-stdlib-1.9.0-Beta",
"kotlin-stdlib-1.9.20-Beta",
Expand All@@ -260,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")
Expand Down
7 changes: 0 additions & 7 deletionsjava/kotlin-extractor/BUILD.bazel
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,13 +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`
resource_strip_prefix = (
("../%s/" % repo_name() if repo_name() else "") +
("%s/" % package_name() if package_name() else "") +
v
),
resources = [
":resources-%s" % v,
],
Expand Down
3 changes: 0 additions & 3 deletionsjava/kotlin-extractor/deps/kotlin-compiler-1.6.0.jar
View file
Open in desktop

This file was deleted.

3 changes: 0 additions & 3 deletionsjava/kotlin-extractor/deps/kotlin-compiler-1.6.20.jar
View file
Open in desktop

This file was deleted.

3 changes: 0 additions & 3 deletionsjava/kotlin-extractor/deps/kotlin-compiler-1.7.0.jar
View file
Open in desktop

This file was deleted.

3 changes: 0 additions & 3 deletionsjava/kotlin-extractor/deps/kotlin-compiler-1.7.20.jar
View file
Open in desktop

This file was deleted.

View file
Open in desktop
Git LFS file not shown
View file
Open in desktop

This file was deleted.

View file
Open in desktop

This file was deleted.

View file
Open in desktop

This file was deleted.

View file
Open in desktop

This file was deleted.

View file
Open in desktop
Git LFS file not shown
3 changes: 0 additions & 3 deletionsjava/kotlin-extractor/deps/kotlin-stdlib-1.6.0.jar
View file
Open in desktop

This file was deleted.

3 changes: 0 additions & 3 deletionsjava/kotlin-extractor/deps/kotlin-stdlib-1.6.20.jar
View file
Open in desktop

This file was deleted.

3 changes: 0 additions & 3 deletionsjava/kotlin-extractor/deps/kotlin-stdlib-1.7.0.jar
View file
Open in desktop

This file was deleted.

3 changes: 0 additions & 3 deletionsjava/kotlin-extractor/deps/kotlin-stdlib-1.7.20.jar
View file
Open in desktop

This file was deleted.

3 changes: 3 additions & 0 deletionsjava/kotlin-extractor/deps/kotlin-stdlib-2.3.0-Beta2.jar
View file
Open in desktop
Git LFS file not shown
18 changes: 15 additions & 3 deletionsjava/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -415,6 +415,7 @@ open class KotlinFileExtractor(

private fun extractClassModifiers(c: IrClass, id: Label<out DbClassorinterface>) {
with("class modifiers", c) {
@Suppress("REDUNDANT_ELSE_IN_WHEN")
when (c.modality) {
Modality.FINAL -> addModifiers(id, "final")
Modality.SEALED -> addModifiers(id, "sealed")
Expand DownExpand Up@@ -1644,7 +1645,7 @@ open class KotlinFileExtractor(
extractMethodAndParameterTypeAccesses: Boolean,
typeSubstitution: TypeSubstitution?,
classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?
) =
): Label<out DbCallable>=
forceExtractFunction(
f,
parentId,
Expand DownExpand Up@@ -2801,6 +2802,7 @@ open class KotlinFileExtractor(

private fun extractBody(b: IrBody, callable: Label<out DbCallable>) {
with("body", b) {
@Suppress("REDUNDANT_ELSE_IN_WHEN")
when (b) {
is IrBlockBody -> extractBlockBody(b, callable)
is IrSyntheticBody -> extractSyntheticBody(b, callable)
Expand DownExpand Up@@ -2973,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.delegate is not-nullable. Cast to a be nullable,
Copy link
Contributor

Choose a reason for hiding this comment

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

Removea inCast 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
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know why it is now nullable? Is that actually an error?


@Suppress("USELESS_CAST")
val delegate = (s.delegate as IrVariable?) ?: run {
logger.errorElement("Local delegated property is missing delegate", s)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we want to just skip the next few lines, continuing at// Getter:, rather than returning?

}
extractVariable(delegate, callable, blockId, 0)

val propId = tw.getFreshIdLabel<DbKt_property>()
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)
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand DownExpand Up@@ -1836,6 +1833,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 =
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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 ->
Expand All@@ -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 ->
Expand DownExpand Up@@ -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 ->
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
// For ComponentRegistrar
@file:Suppress("DEPRECATION","DEPRECATION_ERROR")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just add the newDEPRECATION_ERROR suppression to thev_1_9_0-Beta? Or was it not supported back then?


packagecom.github.codeql

importorg.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
importorg.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi

@OptIn(ExperimentalCompilerApi::class)
abstractclassKotlin2ComponentRegistrar :ComponentRegistrar {
overrideval supportsK2:Boolean
get()=true
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
packagecom.github.codeql.utils.versions

importorg.jetbrains.kotlin.descriptors.*
importorg.jetbrains.kotlin.load.kotlin.JvmPackagePartSource
importorg.jetbrains.kotlin.metadata.deserialization.*
importorg.jetbrains.kotlin.metadata.jvm.deserialization.*
importorg.jetbrains.kotlin.metadata.jvm.JvmProtoBuf
importorg.jetbrains.kotlin.resolve.DescriptorUtils.*
importorg.jetbrains.kotlin.serialization.deserialization.descriptors.*

fungetJvmModuleNameForDeserializedDescriptor(descriptor:CallableMemberDescriptor):String? {
val parent= getParentOfType(descriptor,ClassOrPackageFragmentDescriptor::class.java,false)

when {
parentisDeserializedClassDescriptor-> {
val classProto= parent.classProto
val nameResolver= parent.c.nameResolver
return classProto.getExtensionOrNull(JvmProtoBuf.classModuleName)
?.let(nameResolver::getString)
?:JvmProtoBufUtil.DEFAULT_MODULE_NAME
}
descriptorisDeserializedMemberDescriptor-> {
val source= descriptor.containerSource
if (sourceisJvmPackagePartSource) {
return source.moduleName
}
}
}

returnnull
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this identical to thev_2_2_20-Beta2 file? Why do we need it?

5 changes: 1 addition & 4 deletionsjava/kotlin-extractor/versions.bzl
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -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",
Expand All@@ -13,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):
Expand Down
View file
Open in desktop

This file was deleted.

Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
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_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",
Expand All@@ -21,15 +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",
)

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")
Original file line numberDiff line numberDiff line change
@@ -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.bzl2000-01-01 01:00:00.000000000 +0100
+++ b/src/main/starlark/core/options/opts.kotlinc.bzl2025-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(
Expand All@@ -28,5 +26,5 @@ index 76df826..ef2d6ca 100644
+ map_value_to_flag = _map_language_version_to_flag,
+ ),
}

def _merge(key, rule_defined):
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
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",
- build_setting_default = True, # Upstream default behavior
+ build_setting_default = False,
visibility = ["//visibility:public"],
)

Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp