From 40af891f84a2395b044475345e2d0611f07ad541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=99=8E=E9=B8=A3?= Date: Sun, 8 Mar 2026 17:53:33 +0800 Subject: [PATCH] chore: replace per-site @nowarn with scoped -Wconf in codegen Remove the `@nowarn("msg=is never used")` annotation from `CodeGenerator.registerExtensions` in the Scala-2.12 source tree and replace it with a precisely-scoped `-Wconf` compiler option in `project/Common.scala`. The `registerExtensions` method is a trait default implementation whose `registry: ExtensionRegistry` parameter goes unused. Scala 2.12's `-Ywarn-unused` fires on this; the per-site annotation silenced it. The new `-Wconf:src=.*/grpc/gen/CodeGenerator\.scala:msg=is never used` option targets only that single file and only the "is never used" message, keeping the full warning signal everywhere else. The Scala-2.13+ counterpart file has never needed an annotation. Upstream commit: https://github.com/akka/akka-grpc/commit/46bd59ff Upstream PR: https://github.com/akka/akka-grpc/pull/1699 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../main/scala/org/apache/pekko/grpc/gen/CodeGenerator.scala | 3 +-- project/Common.scala | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/codegen/src/main/scala/org/apache/pekko/grpc/gen/CodeGenerator.scala b/codegen/src/main/scala/org/apache/pekko/grpc/gen/CodeGenerator.scala index 5e758e4df..0859ce794 100644 --- a/codegen/src/main/scala/org/apache/pekko/grpc/gen/CodeGenerator.scala +++ b/codegen/src/main/scala/org/apache/pekko/grpc/gen/CodeGenerator.scala @@ -13,7 +13,6 @@ package org.apache.pekko.grpc.gen -import scala.annotation.nowarn import com.google.protobuf.ExtensionRegistry import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse @@ -33,7 +32,7 @@ trait CodeGenerator { /** Takes Scala binary version and returns suggested dependency Seq */ def suggestedDependencies: ScalaBinaryVersion => Seq[Artifact] - def registerExtensions(@nowarn("msg=is never used") registry: ExtensionRegistry): Unit = {} + def registerExtensions(registry: ExtensionRegistry): Unit = {} final def run(request: Array[Byte], logger: Logger): Array[Byte] = { val registry = ExtensionRegistry.newInstance diff --git a/project/Common.scala b/project/Common.scala index 82ba63ccd..45ca9d56a 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -67,6 +67,9 @@ object Common extends AutoPlugin { Seq( // Generated code for methods/fields marked 'deprecated' "-Wconf:msg=Marked as deprecated in proto file:silent", + // Suppress "parameter X is never used" in CodeGenerator's registerExtensions + // default trait impl. Uses precise path+msg filter to avoid masking real warnings. + "-Wconf:src=.*/grpc/gen/CodeGenerator\\.scala:msg=is never used:silent", // ignore imports in templates (FIXME why is that trailing .* needed?) "-Wconf:src=.*.txt.*:silent", "-Wconf:cat=unused-nowarn:silent")