Skip to content

Commit 240c08e

Browse files
committed
Updates rules_kotlin to support Kotlin v2.2.20
1 parent cdd8099 commit 240c08e

File tree

18 files changed

+201
-25
lines changed

18 files changed

+201
-25
lines changed

kotlin/internal/toolchains.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ _kt_toolchain = rule(
134134
),
135135
"language_version": attr.string(
136136
doc = "this is the -language_version flag [see](https://kotlinlang.org/docs/reference/compatibility.html)",
137-
default = "2.1",
137+
default = "2.2",
138138
values = [
139139
"1.1",
140140
"1.2",
@@ -147,11 +147,12 @@ _kt_toolchain = rule(
147147
"1.9",
148148
"2.0",
149149
"2.1",
150+
"2.2",
150151
],
151152
),
152153
"api_version": attr.string(
153154
doc = "this is the -api_version flag [see](https://kotlinlang.org/docs/reference/compatibility.html).",
154-
default = "2.1",
155+
default = "2.2",
155156
values = [
156157
"1.1",
157158
"1.2",
@@ -164,6 +165,7 @@ _kt_toolchain = rule(
164165
"1.9",
165166
"2.0",
166167
"2.1",
168+
"2.2",
167169
],
168170
),
169171
"debug": attr.string_list(

src/main/kotlin/bootstrap.bzl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def kt_bootstrap_library(name, deps = [], neverlink_deps = [], srcs = [], visibi
3737
**kwargs
3838
)
3939

40+
# Filter out kotlinc_opts from kwargs for ktlint rules (they don't support it)
41+
ktlint_kwargs = {k: v for k, v in kwargs.items() if k != "kotlinc_opts"}
42+
4043
_ktlint_test(
4144
name = "%s_ktlint_test" % name,
4245
srcs = srcs,
@@ -51,7 +54,7 @@ def kt_bootstrap_library(name, deps = [], neverlink_deps = [], srcs = [], visibi
5154
visibility = ["//visibility:private"],
5255
config = "//:ktlint_editorconfig",
5356
tags = ["no-ide", "ktlint"],
54-
**kwargs
57+
**ktlint_kwargs
5558
)
5659

5760
def kt_bootstrap_binary(

src/main/kotlin/io/bazel/kotlin/generate/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ kt_jvm_import(
1212
"//kotlin/compiler:kotlin-stdlib-jdk7",
1313
"//kotlin/compiler:kotlin-stdlib-jdk8",
1414
"//kotlin/compiler:kotlinx-coroutines-core-jvm",
15-
"//kotlin/compiler:trove4j",
1615
],
1716
)
1817

src/main/kotlin/io/bazel/kotlin/plugin/jdeps/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ kt_bootstrap_library(
2525
"k2/checker/declaration/*.kt",
2626
"k2/checker/expression/*.kt",
2727
]),
28+
kotlinc_opts = {
29+
"-Xcontext-parameters": "",
30+
},
2831
visibility = ["//src:__subpackages__"],
2932
deps = [
3033
"//kotlin/compiler:kotlin-compiler",

src/main/kotlin/io/bazel/kotlin/plugin/jdeps/k2/checker/declaration/BasicDeclarationChecker.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ import org.jetbrains.kotlin.fir.declarations.toAnnotationClassLikeSymbol
1111
internal class BasicDeclarationChecker(
1212
private val classUsageRecorder: ClassUsageRecorder,
1313
) : FirBasicDeclarationChecker(MppCheckerKind.Common) {
14+
context(context: CheckerContext, reporter: DiagnosticReporter)
1415
override fun check(
1516
declaration: FirDeclaration,
16-
context: CheckerContext,
17-
reporter: DiagnosticReporter,
1817
) {
1918
declaration.annotations.forEach { annotation ->
2019
annotation.toAnnotationClassLikeSymbol(context.session)?.let {

src/main/kotlin/io/bazel/kotlin/plugin/jdeps/k2/checker/declaration/CallableChecker.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ internal class CallableChecker(
1616
* Tracks the return type & type parameters of a callable declaration. Function parameters are
1717
* tracked in [FunctionChecker].
1818
*/
19+
context(context: CheckerContext, reporter: DiagnosticReporter)
1920
override fun check(
2021
declaration: FirCallableDeclaration,
21-
context: CheckerContext,
22-
reporter: DiagnosticReporter,
2322
) {
2423
// return type
2524
declaration.returnTypeRef.let { classUsageRecorder.recordTypeRef(it, context) }

src/main/kotlin/io/bazel/kotlin/plugin/jdeps/k2/checker/declaration/ClassLikeChecker.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ import org.jetbrains.kotlin.fir.resolve.getSuperTypes
1111
internal class ClassLikeChecker(
1212
private val classUsageRecorder: ClassUsageRecorder,
1313
) : FirClassLikeChecker(MppCheckerKind.Common) {
14+
context(context: CheckerContext, reporter: DiagnosticReporter)
1415
override fun check(
1516
declaration: FirClassLikeDeclaration,
16-
context: CheckerContext,
17-
reporter: DiagnosticReporter,
1817
) {
1918
declaration.symbol.let { classUsageRecorder.recordClass(it, context) }
2019
// [recordClass] also handles supertypes, but this marks direct supertypes as explicit

src/main/kotlin/io/bazel/kotlin/plugin/jdeps/k2/checker/declaration/FileChecker.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ import org.jetbrains.kotlin.name.ClassId
2222
internal class FileChecker(
2323
private val classUsageRecorder: ClassUsageRecorder,
2424
) : FirFileChecker(MppCheckerKind.Common) {
25+
context(context: CheckerContext, reporter: DiagnosticReporter)
2526
override fun check(
2627
declaration: FirFile,
27-
context: CheckerContext,
28-
reporter: DiagnosticReporter,
2928
) {
3029
declaration.imports.filterIsInstance<FirResolvedImport>().forEach { import ->
3130
// check for classlike import (class, interface, object, enum, annotation, etc)

src/main/kotlin/io/bazel/kotlin/plugin/jdeps/k2/checker/declaration/FunctionChecker.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ internal class FunctionChecker(
1414
* Tracks the value parameters of a function declaration. Return type & type parameters are
1515
* tracked in [CallableChecker].
1616
*/
17+
context(context: CheckerContext, reporter: DiagnosticReporter)
1718
override fun check(
1819
declaration: FirFunction,
19-
context: CheckerContext,
20-
reporter: DiagnosticReporter,
2120
) {
2221
// function parameters
2322
declaration.valueParameters.forEach { valueParam ->

src/main/kotlin/io/bazel/kotlin/plugin/jdeps/k2/checker/expression/QualifiedAccessChecker.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ import org.jetbrains.kotlin.KtSourceElement
2121
internal class QualifiedAccessChecker(
2222
private val classUsageRecorder: ClassUsageRecorder,
2323
) : FirQualifiedAccessExpressionChecker(MppCheckerKind.Common) {
24+
context(context: CheckerContext, reporter: DiagnosticReporter)
2425
override fun check(
2526
expression: FirQualifiedAccessExpression,
26-
context: CheckerContext,
27-
reporter: DiagnosticReporter,
2827
) {
2928
// track function's owning class
3029
val resolvedCallableSymbol = expression.toResolvedCallableSymbol()

0 commit comments

Comments
 (0)