Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ use_repo(
"kotlin-compiler-2.3.20",
"kotlin-compiler-2.4.0",
"kotlin-compiler-2.4.20",
"kotlin-compiler-2.5.0-RC2",
"kotlin-compiler-embeddable-1.8.0",
"kotlin-compiler-embeddable-1.9.0-Beta",
"kotlin-compiler-embeddable-1.9.20-Beta",
Expand All @@ -337,6 +338,7 @@ use_repo(
"kotlin-compiler-embeddable-2.3.20",
"kotlin-compiler-embeddable-2.4.0",
"kotlin-compiler-embeddable-2.4.20",
"kotlin-compiler-embeddable-2.5.0-RC2",
"kotlin-stdlib-1.8.0",
"kotlin-stdlib-1.9.0-Beta",
"kotlin-stdlib-1.9.20-Beta",
Expand All @@ -350,6 +352,7 @@ use_repo(
"kotlin-stdlib-2.3.20",
"kotlin-stdlib-2.4.0",
"kotlin-stdlib-2.4.20",
"kotlin-stdlib-2.5.0-RC2",
)

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
Expand Down
2 changes: 1 addition & 1 deletion docs/codeql/reusables/supported-versions-compilers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Java,"Java 7 to 27 [5]_","javac (OpenJDK and Oracle JDK),

Eclipse compiler for Java (ECJ) [6]_",``.java``
Kotlin,"Kotlin 1.8.0 to 2.4.2\ *x*","kotlinc",``.kt``
Kotlin,"Kotlin 1.8.0 to 2.5.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`` [7]_"
Python [8]_,"2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, 3.14",Not applicable,``.py``
Ruby,"up to 3.3",Not applicable,"``.rb``, ``.erb``, ``.gemspec``, ``Gemfile``"
Expand Down
3 changes: 3 additions & 0 deletions java/kotlin-extractor/deps/kotlin-compiler-2.5.0-RC2.jar
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions java/kotlin-extractor/deps/kotlin-stdlib-2.5.0-RC2.jar
Git LFS file not shown
33 changes: 16 additions & 17 deletions java/kotlin-extractor/src/main/kotlin/KotlinExtractorExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class KotlinExtractorExtension(
} ?: "kotlin-extractor/src"
)
srcDir.mkdirs()
val globalExtensionState = KotlinExtractorGlobalState()
val globalExtensionState = KotlinExtractorGlobalState(moduleFragment)
moduleFragment.files.mapIndexed { index: Int, file: IrFile ->
val fileExtractionProblems = FileExtractionProblems(invocationExtractionProblems)
val fileTrapWriter = tw.makeSourceFileTrapWriter(file, true)
Expand Down Expand Up @@ -264,7 +264,7 @@ class KotlinExtractorExtension(
}
}

class KotlinExtractorGlobalState {
class KotlinExtractorGlobalState(val moduleFragment: IrModuleFragment) {
// These three record mappings of classes, functions and fields that should be replaced wherever
// they are found.
// As of now these are only used to fix IR generated by the Gradle Android Extensions plugin,
Expand Down Expand Up @@ -331,21 +331,20 @@ This function determines whether 2 TRAP files should be considered to be
equivalent. It returns `true` iff all of their non-comment lines are
identical.
*/
private fun equivalentTrap(r1: BufferedReader, r2: BufferedReader): Boolean {
r1.use { br1 ->
r2.use { br2 ->
while (true) {
val l1 = br1.readLine()
val l2 = br2.readLine()
if (l1 == null && l2 == null) {
return true
} else if (l1 == null || l2 == null) {
return false
} else if (l1 != l2) {
if (!l1.startsWith("//") || !l2.startsWith("//")) {
return false
}
}
private fun equivalentTrap(r1: BufferedReader, r2: BufferedReader): Boolean =
r1.use { br1 -> r2.use { br2 -> equivalentTrapLines(br1, br2) } }

private fun equivalentTrapLines(br1: BufferedReader, br2: BufferedReader): Boolean {
while (true) {
val l1 = br1.readLine()
val l2 = br2.readLine()
if (l1 == null && l2 == null) {
return true
} else if (l1 == null || l2 == null) {
return false
} else if (l1 != l2) {
if (!l1.startsWith("//") || !l2.startsWith("//")) {
return false
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.semmle.extractor.java.OdasaOutput
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.backend.common.ir.*
import org.jetbrains.kotlin.backend.jvm.ir.*
import org.jetbrains.kotlin.codegen.JvmCodegenUtil
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.declarations.*
Expand Down Expand Up @@ -1055,7 +1054,7 @@ open class KotlinUsesExtractor(
private fun getJvmModuleName(f: IrFunction) =
NameUtils.sanitizeAsJavaIdentifier(
getJvmModuleNameForDeserializedDescriptor(f.descriptor)
?: JvmCodegenUtil.getModuleName(pluginContext.moduleDescriptor)
?: getCurrentJvmModuleName(pluginContext, globalExtensionState.moduleFragment)
)

fun getFunctionShortName(f: IrFunction): FunctionNames {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.ir.builders.declarations.buildClass
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.expressions.impl.*
Expand Down Expand Up @@ -177,7 +176,7 @@ object RawTypeAnnotation {
val annotationConstructor: IrConstructorCall by lazy {
val irInternalPackage = FqName("kotlin.internal.ir")
val parent =
IrExternalPackageFragmentImpl(
createExternalPackageFragment(
DescriptorlessExternalPackageFragmentSymbol(),
irInternalPackage
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.github.codeql.utils.versions

import org.jetbrains.kotlin.ir.declarations.IrExternalPackageFragment
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
import org.jetbrains.kotlin.ir.symbols.IrExternalPackageFragmentSymbol
import org.jetbrains.kotlin.name.FqName

fun createExternalPackageFragment(
symbol: IrExternalPackageFragmentSymbol,
fqName: FqName
): IrExternalPackageFragment = IrExternalPackageFragmentImpl(symbol, fqName)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.github.codeql.utils.versions

import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.codegen.JvmCodegenUtil
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment

@OptIn(ObsoleteDescriptorBasedAPI::class)
@Suppress("UNUSED_PARAMETER")
fun getCurrentJvmModuleName(
pluginContext: IrPluginContext,
moduleFragment: IrModuleFragment
): String =
JvmCodegenUtil.getModuleName(pluginContext.moduleDescriptor)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.github.codeql.utils.versions

import org.jetbrains.kotlin.ir.declarations.IrExternalPackageFragment
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
import org.jetbrains.kotlin.ir.symbols.IrExternalPackageFragmentSymbol
import org.jetbrains.kotlin.ir.util.IrErrorModuleFragment
import org.jetbrains.kotlin.name.FqName

// The fragment now needs a module. As in the compiler's own
// `JvmIrSpecialAnnotationSymbolProvider`, a placeholder module is sufficient for the synthetic
// packages we create.
fun createExternalPackageFragment(
symbol: IrExternalPackageFragmentSymbol,
fqName: FqName
): IrExternalPackageFragment =
IrExternalPackageFragmentImpl(symbol, fqName, IrErrorModuleFragment)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.github.codeql.utils.versions

import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment

// `JvmCodegenUtil` and `IrPluginContext.moduleDescriptor` no longer exist, so this mirrors what
// `JvmCodegenUtil.getModuleName(pluginContext.moduleDescriptor)` used to do.
@OptIn(ObsoleteDescriptorBasedAPI::class)
@Suppress("UNUSED_PARAMETER")
fun getCurrentJvmModuleName(
pluginContext: IrPluginContext,
moduleFragment: IrModuleFragment
): String {
val module = moduleFragment.descriptor
return (module.stableName ?: module.name).asString().removeSurrounding("<", ">")
}
3 changes: 2 additions & 1 deletion java/kotlin-extractor/versions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ VERSIONS = [
"2.3.20",
"2.4.0",
"2.4.20",
"2.5.0-RC2",
]

def _version_to_tuple(v):
Expand Down Expand Up @@ -42,6 +43,6 @@ def get_compatilibity_sources(version, dir):
compat_version = d[len(prefix):].replace("_", ".")
if version_less(version, compat_version):
break
files = native.glob(["%s/*.kt" % d])
files = native.glob(["%s/*.kt" % d], allow_empty = True)
srcs |= {_basename(f): f for f in files}
return srcs.values()
Original file line number Diff line number Diff line change
@@ -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.4.30.",
"markdownMessage": "The Kotlin version installed (`999.999.999`) is too recent for this version of CodeQL. Install a version lower than 2.5.10.",
"severity": "error",
"source": {
"extractorName": "java",
Expand Down
4 changes: 4 additions & 0 deletions java/ql/lib/change-notes/2026-11-30-kotlin-2.5.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Support for Kotlin 2.5.0 has been added.
Loading