diff --git a/MODULE.bazel b/MODULE.bazel index 8ba6c2fcd8c8..8396af644c7b 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,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", @@ -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", @@ -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") 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. diff --git a/java/kotlin-extractor/BUILD.bazel b/java/kotlin-extractor/BUILD.bazel index a714e06d4111..a4356af1835b 100644 --- a/java/kotlin-extractor/BUILD.bazel +++ b/java/kotlin-extractor/BUILD.bazel @@ -124,13 +124,7 @@ 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 - ), + resource_strip_prefix = v, resources = [ ":resources-%s" % v, ], 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-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-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-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-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/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/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(): diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index 72c766bb0828..f83d887eb56f 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") @@ -1342,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) }) { @@ -1644,7 +1645,7 @@ open class KotlinFileExtractor( extractMethodAndParameterTypeAccesses: Boolean, typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List? - ) = + ) : Label = forceExtractFunction( f, parentId, @@ -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) @@ -2834,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) } @@ -2973,13 +2975,23 @@ 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 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? val propId = tw.getFreshIdLabel() - tw.writeKtProperties(propId, s.name.asString()) - tw.writeHasLocation(propId, locId) - tw.writeKtPropertyDelegates(propId, useVariable(s.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 @@ -3332,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 83cbec771fc5..3994850fc756 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)), @@ -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 @@ -939,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()) } @@ -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 = 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 fb39b6675759..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,13 +20,14 @@ 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 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.* @@ -36,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()) @@ -61,7 +69,7 @@ private fun IrSimpleType.substituteTypeArguments( } } - return IrSimpleTypeImpl(classifier, isNullableCodeQL(), newArguments, annotations) + return codeqlIrSimpleTypeImpl(classifier, isNullableCodeQL(), newArguments, annotations) } /** @@ -111,6 +119,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 +134,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 +219,7 @@ fun IrClass.toRawType(): IrType { } fun IrTypeArgument.withQuestionMark(b: Boolean): IrTypeArgument = + @Suppress("REDUNDANT_ELSE_IN_WHEN") when (this) { is IrStarProjection -> this is IrTypeProjection -> 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_8_0/IrSimpleTypeImplCompat.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_0/IrSimpleTypeImplCompat.kt new file mode 100644 index 000000000000..ed0ad405e294 --- /dev/null +++ b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_8_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_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 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/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 +) diff --git a/java/kotlin-extractor/versions.bzl b/java/kotlin-extractor/versions.bzl index 95897f49cc81..b7ae04934e17 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", @@ -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): 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..9e7e2a195302 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.0.", "severity": "error", "source": { "extractorName": "java", 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 54% 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..df66ce2051ab 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,6 +1,6 @@ module( name = "rules_kotlin", - version = "2.1.3-codeql.1", + version = "2.2.0-codeql.1", compatibility_level = 1, repo_name = "rules_kotlin", ) @@ -8,9 +8,15 @@ 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_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", @@ -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") 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": {} }