Skip to content

Commit c6cc4c0

Browse files
authored
Merge pull request #19402 from smowton/smowton/admin/kotlin-2.2.0-support
Add support for Kotlin 2.2.0; drop Kotlin 1.5.x
2 parents fa79423 + fecad02 commit c6cc4c0

File tree

67 files changed

+848
-796
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+848
-796
lines changed

MODULE.bazel

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bazel_dep(name = "bazel_skylib", version = "1.7.1")
2424
bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "absl")
2525
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
2626
bazel_dep(name = "fmt", version = "10.0.0")
27-
bazel_dep(name = "rules_kotlin", version = "2.0.0-codeql.1")
27+
bazel_dep(name = "rules_kotlin", version = "2.1.3-codeql.1")
2828
bazel_dep(name = "gazelle", version = "0.40.0")
2929
bazel_dep(name = "rules_dotnet", version = "0.17.4")
3030
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
@@ -193,10 +193,6 @@ use_repo(
193193
kotlin_extractor_deps,
194194
"codeql_kotlin_defaults",
195195
"codeql_kotlin_embeddable",
196-
"kotlin-compiler-1.5.0",
197-
"kotlin-compiler-1.5.10",
198-
"kotlin-compiler-1.5.20",
199-
"kotlin-compiler-1.5.30",
200196
"kotlin-compiler-1.6.0",
201197
"kotlin-compiler-1.6.20",
202198
"kotlin-compiler-1.7.0",
@@ -208,10 +204,7 @@ use_repo(
208204
"kotlin-compiler-2.0.20-Beta2",
209205
"kotlin-compiler-2.1.0-Beta1",
210206
"kotlin-compiler-2.1.20-Beta1",
211-
"kotlin-compiler-embeddable-1.5.0",
212-
"kotlin-compiler-embeddable-1.5.10",
213-
"kotlin-compiler-embeddable-1.5.20",
214-
"kotlin-compiler-embeddable-1.5.30",
207+
"kotlin-compiler-2.2.0-Beta1",
215208
"kotlin-compiler-embeddable-1.6.0",
216209
"kotlin-compiler-embeddable-1.6.20",
217210
"kotlin-compiler-embeddable-1.7.0",
@@ -223,10 +216,7 @@ use_repo(
223216
"kotlin-compiler-embeddable-2.0.20-Beta2",
224217
"kotlin-compiler-embeddable-2.1.0-Beta1",
225218
"kotlin-compiler-embeddable-2.1.20-Beta1",
226-
"kotlin-stdlib-1.5.0",
227-
"kotlin-stdlib-1.5.10",
228-
"kotlin-stdlib-1.5.20",
229-
"kotlin-stdlib-1.5.30",
219+
"kotlin-compiler-embeddable-2.2.0-Beta1",
230220
"kotlin-stdlib-1.6.0",
231221
"kotlin-stdlib-1.6.20",
232222
"kotlin-stdlib-1.7.0",
@@ -238,6 +228,7 @@ use_repo(
238228
"kotlin-stdlib-2.0.20-Beta2",
239229
"kotlin-stdlib-2.1.0-Beta1",
240230
"kotlin-stdlib-2.1.20-Beta1",
231+
"kotlin-stdlib-2.2.0-Beta1",
241232
)
242233

243234
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")

docs/codeql/reusables/supported-versions-compilers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
Java,"Java 7 to 24 [6]_","javac (OpenJDK and Oracle JDK),
2222

2323
Eclipse compiler for Java (ECJ) [7]_",``.java``
24-
Kotlin,"Kotlin 1.5.0 to 2.1.2\ *x*","kotlinc",``.kt``
24+
Kotlin,"Kotlin 1.6.0 to 2.2.0\ *x*","kotlinc",``.kt``
2525
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]_"
2626
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``
2727
Ruby [10]_,"up to 3.3",Not applicable,"``.rb``, ``.erb``, ``.gemspec``, ``Gemfile``"

java/kotlin-extractor/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ sourceSets {
5555
}
5656

5757
jar {
58-
archiveName = "${OUTPUT_JAR_NAME}"
58+
archiveBaseName = "${OUTPUT_JAR_NAME}"
5959
}
6060

6161
task getHomeDir {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:5cabb8d9f7621865fb0300773bd0cb6dcd91412d0026342c6aacdf23bdb7cf0b
3+
size 57574890
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:046daac99684ac0fbe3f8c9780651192fb23061a27b72f1e948c25d160d7b147
3+
size 56134176
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:51aefa2b8d09b2d32cd65056a0f1485556447c764574115981474fa9716a124a
3+
size 1730638

java/kotlin-extractor/dev/wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import io
2828
import os
2929

30-
DEFAULT_VERSION = "2.0.0"
30+
DEFAULT_VERSION = "2.1.20"
3131

3232

3333
def options():

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
2121
import org.jetbrains.kotlin.ir.backend.js.utils.realOverrideTarget
2222
import org.jetbrains.kotlin.ir.builders.declarations.*
2323
import org.jetbrains.kotlin.ir.declarations.*
24-
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyFunction
2524
import org.jetbrains.kotlin.ir.expressions.*
2625
import org.jetbrains.kotlin.ir.expressions.impl.*
2726
import org.jetbrains.kotlin.ir.symbols.*
@@ -1609,7 +1608,7 @@ open class KotlinFileExtractor(
16091608
cls.origin != IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB
16101609

16111610
private fun needsInterfaceForwarder(f: IrFunction) =
1612-
// jvmDefaultModeEnabledIsEnabled means that -Xjvm-default=all or all-compatibility was
1611+
// jvmDefaultModeIsNoCompatibility means that -Xjvm-default=all or =no-compatibility was
16131612
// used, in which case real Java default interfaces are used, and we don't need to do
16141613
// anything.
16151614
// Otherwise, for a Kotlin-defined method inheriting a Kotlin-defined default, we need to
@@ -1619,9 +1618,7 @@ open class KotlinFileExtractor(
16191618
// (NB. kotlinc's actual implementation strategy is different -- it makes an inner class
16201619
// called InterfaceWithDefault$DefaultImpls and stores the default methods
16211620
// there to allow default method usage in Java < 8, but this is hopefully niche.
1622-
!jvmDefaultModeEnabledIsEnabled(
1623-
pluginContext.languageVersionSettings
1624-
.getFlag(JvmAnalysisFlags.jvmDefaultMode)) &&
1621+
!jvmDefaultModeIsNoCompatibility(getJvmDefaultMode(pluginContext.languageVersionSettings)) &&
16251622
f.parentClassOrNull.let {
16261623
it != null &&
16271624
it.origin != IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB &&
@@ -6011,11 +6008,7 @@ open class KotlinFileExtractor(
60116008
is IrGetValue -> {
60126009
val exprParent = parent.expr(e, callable)
60136010
val owner = e.symbol.owner
6014-
if (
6015-
owner is IrValueParameter &&
6016-
owner.index == -1 &&
6017-
!owner.isExtensionReceiver()
6018-
) {
6011+
if (owner is IrValueParameter && isDispatchReceiver(owner)) {
60196012
extractThisAccess(e, owner.parent, exprParent, callable)
60206013
} else {
60216014
val isAnnotationClassParameter =
@@ -6966,11 +6959,6 @@ open class KotlinFileExtractor(
69666959
}
69676960
}
69686961

6969-
private fun IrValueParameter.isExtensionReceiver(): Boolean {
6970-
val parentFun = parent as? IrFunction ?: return false
6971-
return parentFun.extensionReceiverParameter == this
6972-
}
6973-
69746962
private open inner class GeneratedClassHelper(
69756963
protected val locId: Label<DbLocation>,
69766964
protected val ids: GeneratedClassLabels

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,7 @@ open class KotlinUsesExtractor(
21362136
}
21372137
val parentId = parent ?: overriddenParentAttributes?.id ?: useDeclarationParentOf(vp, false)
21382138

2139-
val idxBase = overriddenParentAttributes?.valueParameters?.indexOf(vp) ?: vp.index
2139+
val idxBase = overriddenParentAttributes?.valueParameters?.indexOf(vp) ?: parameterIndexExcludingReceivers(vp)
21402140
val idxOffset =
21412141
if (
21422142
declarationParent is IrFunction &&

java/kotlin-extractor/src/main/kotlin/comments/CommentExtractor.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ package com.github.codeql.comments
22

33
import com.github.codeql.*
44
import com.github.codeql.utils.isLocalFunction
5+
import com.github.codeql.utils.versions.isDispatchReceiver
56
import org.jetbrains.kotlin.ir.IrElement
67
import org.jetbrains.kotlin.ir.declarations.*
78
import org.jetbrains.kotlin.ir.expressions.IrBody
89
import org.jetbrains.kotlin.ir.expressions.IrExpression
910
import org.jetbrains.kotlin.ir.util.parentClassOrNull
1011

12+
private fun IrValueParameter.isExtensionReceiver(): Boolean {
13+
val parentFun = parent as? IrFunction ?: return false
14+
return parentFun.extensionReceiverParameter == this
15+
}
16+
1117
open class CommentExtractor(
1218
protected val fileExtractor: KotlinFileExtractor,
1319
protected val file: IrFile,
@@ -19,7 +25,7 @@ open class CommentExtractor(
1925
protected fun getLabel(element: IrElement): Label<out DbTop>? {
2026
if (element == file) return fileLabel
2127

22-
if (element is IrValueParameter && element.index == -1) {
28+
if (element is IrValueParameter && (isDispatchReceiver(element) || element.isExtensionReceiver())) {
2329
// Don't attribute comments to the implicit `this` parameter of a function.
2430
return null
2531
}

0 commit comments

Comments
 (0)