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

-Wunused:all and private extractor objects #16682

Closed
amumurst opened this issue Jan 13, 2023 · 0 comments · Fixed by #16690
Closed

-Wunused:all and private extractor objects #16682

amumurst opened this issue Jan 13, 2023 · 0 comments · Fixed by #16690
Assignees
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug
Milestone

Comments

@amumurst
Copy link

amumurst commented Jan 13, 2023

I tried adding the new unused flag (from #16157) to my work codebase and was surprised that it warned about unused private member when used with the http library http4ss query parameter matching. A minimal reproducer independent of http4s is below.

Compiler version

With nightly: 3.3.0-RC1-bin-20230112-be10bc6-NIGHTLY

Minimized code

//> using scala "3.3.0-RC1-bin-20230112-be10bc6-NIGHTLY"
//> using option "-Wunused:all"

object myPackage:
   private object IntExtractor:
      def unapply(s: String): Option[Int] = s.toIntOption

   def isInt(s: String) = s match {
      case IntExtractor(i) => println(s"Number $i")
      case _ => println("NaN")
   }

myPackage.isInt("42")

Output

[warn] ./unused-extractor-object.sc:5:19: unused private member
[warn]    private object IntExtractor:
[warn]                   ^^^^^^^^^^^^

Expectation

IntExtractor is used when matching against the string, so it should not warn about it being unused.

@amumurst amumurst added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 13, 2023
@szymon-rd szymon-rd self-assigned this Jan 13, 2023
@szymon-rd szymon-rd added area:reporting Error reporting including formatting, implicit suggestions, etc and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 13, 2023
@Kordyjan Kordyjan added this to the 3.3.0 backports milestone Jan 13, 2023
szymon-rd added a commit that referenced this issue Jan 16, 2023
- Register every symbol and related (companion, module, etc.)
- Fixes #16682
- Update test suits

@szymon-rd
little-inferno pushed a commit to little-inferno/dotty that referenced this issue Jan 25, 2023
- Register every symbol and related (companion, module, etc.)
- Fix scala#16682
- Update test suits
@Kordyjan Kordyjan modified the milestones: 3.3.0 backports, 3.3.0 Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants