- Notifications
You must be signed in to change notification settings - Fork 1.9k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base:main
Are you sure you want to change the base?
Changes from all commits
3c81d5ac7d65ef90dd3b9144510cecc8a912e8db58File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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") | ||
| @@ -1644,7 +1645,7 @@ open class KotlinFileExtractor( | ||
| extractMethodAndParameterTypeAccesses: Boolean, | ||
| typeSubstitution: TypeSubstitution?, | ||
| classTypeArgsIncludingOuterClasses: List<IrTypeArgument>? | ||
| ) = | ||
| ) : Label<out DbCallable> = | ||
| forceExtractFunction( | ||
| f, | ||
| parentId, | ||
| @@ -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) | ||
| @@ -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, | ||
| // 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 | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| } | ||
| 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) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // For ComponentRegistrar | ||
| @file:Suppress("DEPRECATION", "DEPRECATION_ERROR") | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just add the new | ||
| 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 number | Diff line number | Diff 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{ | ||
| parent isDeserializedClassDescriptor->{ | ||
| val classProto = parent.classProto | ||
| val nameResolver = parent.c.nameResolver | ||
| return classProto.getExtensionOrNull(JvmProtoBuf.classModuleName) | ||
| ?.let(nameResolver::getString) | ||
| ?:JvmProtoBufUtil.DEFAULT_MODULE_NAME | ||
| } | ||
| descriptor isDeserializedMemberDescriptor->{ | ||
| val source = descriptor.containerSource | ||
| if (source isJvmPackagePartSource){ | ||
| return source.moduleName | ||
| } | ||
| } | ||
| } | ||
| returnnull | ||
| } | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this identical to the | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff 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"], | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
ainCast to a be nullable?