From c11d82737ab44c21965ce9e6f29f542c3bd24468 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Mon, 8 Jun 2026 16:19:10 +0200 Subject: [PATCH] Kotlin 2.4.0: Fix bazel formatting, change-note category, and internal query style - Fix BUILD.bazel formatting (buildifier line wrapping) - Fix change-note category: 'deprecation' -> 'deprecated' - Replace unsafe list casts with filterIsInstance to satisfy the possiblyThrowingExpressions internal query Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- java/kotlin-extractor/BUILD.bazel | 7 +++++-- .../src/main/kotlin/utils/versions/v_2_4_0/IrCompat.kt | 8 +++----- java/ql/lib/change-notes/2026-06-08-kotlin-drop-1x.md | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/java/kotlin-extractor/BUILD.bazel b/java/kotlin-extractor/BUILD.bazel index 21ba2bea1aa..9882b173c07 100644 --- a/java/kotlin-extractor/BUILD.bazel +++ b/java/kotlin-extractor/BUILD.bazel @@ -114,8 +114,11 @@ kt_javac_options( "cp $(execpath %s) $(RULEDIR)/%s/%s" % (source, v, target) for source, target in _resources ] + ( - ["cp $(execpath %s) $(RULEDIR)/%s/%s" % (_compiler_plugin_registrar_service[0], v, _compiler_plugin_registrar_service[1])] - if not version_less(v, "2.4.0") else [] + ["cp $(execpath %s) $(RULEDIR)/%s/%s" % ( + _compiler_plugin_registrar_service[0], + v, + _compiler_plugin_registrar_service[1], + )] if not version_less(v, "2.4.0") else [] )), ), kt_jvm_library( diff --git a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_0/IrCompat.kt b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_0/IrCompat.kt index 7e461e6da62..d836eb3aecb 100644 --- a/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_0/IrCompat.kt +++ b/java/kotlin-extractor/src/main/kotlin/utils/versions/v_2_4_0/IrCompat.kt @@ -86,15 +86,13 @@ val IrMemberAccessExpression<*>.codeQlTypeArgumentsCount: Int fun IrMemberAccessExpression<*>.codeQlGetTypeArgument(index: Int): IrType? = typeArguments[index] // addAnnotations compat: in 2.4.0, addAnnotations expects List -// IrAnnotation extends IrConstructorCall, so we cast -@Suppress("UNCHECKED_CAST") +// IrConstructorCall implements IrAnnotation in 2.4.0, so filterIsInstance is identity fun IrType.codeQlAddAnnotations(annotations: List): IrType = - addAnnotations(annotations as List) + addAnnotations(annotations.filterIsInstance()) // IrMutableAnnotationContainer.annotations setter: in 2.4.0, expects List -@Suppress("UNCHECKED_CAST") fun codeQlSetAnnotations(container: org.jetbrains.kotlin.ir.declarations.IrMutableAnnotationContainer, annotations: List) { - container.annotations = annotations as List + container.annotations = annotations.filterIsInstance() } // IrFunction: set dispatch receiver parameter diff --git a/java/ql/lib/change-notes/2026-06-08-kotlin-drop-1x.md b/java/ql/lib/change-notes/2026-06-08-kotlin-drop-1x.md index 19a75b1df32..0d38db5b91a 100644 --- a/java/ql/lib/change-notes/2026-06-08-kotlin-drop-1x.md +++ b/java/ql/lib/change-notes/2026-06-08-kotlin-drop-1x.md @@ -1,4 +1,4 @@ --- -category: deprecation +category: deprecated --- * Kotlin versions below 2.0.0 are no longer supported for analysis. The minimum supported version is now Kotlin 2.0.0.