Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register nowarn when inlining #22682

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

Fixes #22672

"Register" @nowarn annotations on inlined methods and also on expressions in inlined bodies.

registerNoWarn is refactored to run.suppressions for ease of use.

@som-snytt som-snytt requested a review from lrytz February 28, 2025 19:26
@som-snytt
Copy link
Contributor Author

It should be selective, since it's not necessary under joint compilation.

Also, I didn't look at why -Werror did not error on the ticket.

@lrytz
Copy link
Member

lrytz commented Mar 3, 2025

I assume deprecates are reported because they are handled in a phase after inlining, while other warnings are not issued because they are issued before? That seems arbitrary.

scala> inline def foo = { 1; Stream(1).head }
2 warnings found
-- [E129] Potential Issue Warning: ---------------------------------------------
1 |inline def foo = { 1; Stream(1).head }
  |                   ^
  |                   A pure expression does nothing in statement position
  |
  | longer explanation available when compiling with `-explain`
-- Deprecation Warning: --------------------------------------------------------
1 |inline def foo = { 1; Stream(1).head }
  |                      ^^^^^^
  |value Stream in package scala is deprecated since 2.13.0: Use LazyList instead of Stream
def foo: Int

scala> foo
1 warning found
-- Deprecation Warning: --------------------------------------------------------
1 |inline def foo = { 1; Stream(1).head }
  |                      ^^^^^^
  |value Stream in package scala is deprecated since 2.13.0: Use LazyList instead of Stream
val res0: Int = 1

scala>

Is there ever a good reason to issue warnings in inlined code?

@som-snytt
Copy link
Contributor Author

@lrytz I haven't crafted the test yet, but it could summon a deprecated given.

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.

@annotation.nowarn ignored/lost during inlining
2 participants