Skip to content

chore: replace per-site @nowarn with scoped -Wconf in codegen#648

Draft
He-Pin wants to merge 1 commit intoapache:mainfrom
He-Pin:port/1-nowarn-wconf
Draft

chore: replace per-site @nowarn with scoped -Wconf in codegen#648
He-Pin wants to merge 1 commit intoapache:mainfrom
He-Pin:port/1-nowarn-wconf

Conversation

@He-Pin
Copy link
Member

@He-Pin He-Pin commented Mar 8, 2026

Motivation

In the Scala 2.12 codegen module, @nowarn("cat=unused-params") was applied per-site to silence a compiler warning about an unused parameter in registerExtensions. This annotation approach is fragile — it must be remembered at every call site and couples source files to specific warning categories.

Modification

  • Removed the per-site @nowarn annotation from CodeGenerator.scala (Scala 2.12 version)
  • Added a precise, scoped compiler option -Wconf:src=.*/grpc/gen/CodeGenerator\.scala:msg=is never used:silent to project/Common.scala, targeting only the specific file and message pattern

Result

The unused parameter warning is suppressed via compiler configuration instead of per-site annotations. This is more maintainable, less intrusive, and follows Scala compiler best practices.

References

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: akka/akka-grpc@46bd59ff
Upstream PR:     akka/akka-grpc#1699

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@He-Pin He-Pin marked this pull request as ready for review March 8, 2026 11:30
@He-Pin He-Pin marked this pull request as draft March 8, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant