Skip to content

Commit a8f2a6d

Browse files
committed
Added one more test and better message
1 parent 746c245 commit a8f2a6d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/diagnostics/RpcDiagnosticRendererFactory.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ object GrpcDiagnosticRendererFactory : BaseDiagnosticRendererFactory() {
115115

116116
map.put(
117117
factory = FirGrpcDiagnostics.WRONG_SAFE_IDEMPOTENT_COMBINATION,
118-
message = "'safe = true' and 'idempotent = false' are mutually exclusive.",
118+
message = "'safe = true' and 'idempotent = false' are mutually exclusive. " +
119+
"If the method is safe, write explicitly 'idempotent = true'.",
119120
)
120121

121122
map.put(

tests/compiler-plugin-tests/src/testData/diagnostics/grpc.fir.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ FILE: module_main_grpc.kt
6565

6666
@R|kotlinx/rpc/grpc/annotations/Grpc.Method|(name = <strcat>(String(wrongName), String(+3))) public abstract suspend fun wrongName3(): R|kotlin/Unit|
6767

68-
@R|kotlinx/rpc/grpc/annotations/Grpc.Method|(safe = Boolean(true), idempotent = Boolean(false)) public abstract suspend fun wrongSafeIdempotent(): R|kotlin/Unit|
68+
@R|kotlinx/rpc/grpc/annotations/Grpc.Method|(safe = Boolean(true), idempotent = Boolean(false)) public abstract suspend fun wrongSafeIdempotent1(): R|kotlin/Unit|
69+
70+
@R|kotlinx/rpc/grpc/annotations/Grpc.Method|(safe = Boolean(true)) public abstract suspend fun wrongSafeIdempotent2(): R|kotlin/Unit|
6971

7072
public final class $rpcServiceStub : R|kotlin/Any| {
7173
public final companion object Companion : R|kotlin/Any| {

tests/compiler-plugin-tests/src/testData/diagnostics/grpc.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,8 @@ interface WrongAnnotations4 {
5353
suspend fun wrongName3()
5454

5555
@Grpc.Method<!WRONG_SAFE_IDEMPOTENT_COMBINATION!>(safe = true, idempotent = false)<!>
56-
suspend fun wrongSafeIdempotent()
56+
suspend fun wrongSafeIdempotent1()
57+
58+
@Grpc.Method<!WRONG_SAFE_IDEMPOTENT_COMBINATION!>(safe = true)<!>
59+
suspend fun wrongSafeIdempotent2()
5760
}

0 commit comments

Comments
 (0)