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

Spurious unused private member warning on type with parameters used in abstract refined type #19998

Open
mrdziuban opened this issue Mar 21, 2024 · 3 comments · May be fixed by #20894
Open

Spurious unused private member warning on type with parameters used in abstract refined type #19998

mrdziuban opened this issue Mar 21, 2024 · 3 comments · May be fixed by #20894
Labels
area:linting Linting warnings enabled with -W or -Xlint area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug

Comments

@mrdziuban
Copy link

mrdziuban commented Mar 21, 2024

Compiler version

3.3.3, 3.4.0, and the latest nightly 3.4.2-RC1-bin-20240320-0ea0eba-NIGHTLY

Minimized code

//> using scala 3.4.1
//> using options -Wunused:privates

trait Foo {
  type X[a]
}

trait Bar[X[_]] {
  private final type SelfX[a] = X[a]
  val foo: Foo { type X[a] = SelfX[a] }
}

Output

-- Error: /Users/matt/scala-unused-private-type/src/main/scala/example/Test.scala:6:21
6 |  private final type SelfX[a] = X[a]
  |                     ^^^^^
  |                     unused private member

Expectation

SelfX should not be reported as unused. Interestingly, the warning goes away if X does not have type parameters.

@mrdziuban mrdziuban added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 21, 2024
@Gedochao Gedochao added stat:cannot reproduce 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 Apr 3, 2024
@Gedochao
Copy link
Contributor

Gedochao commented Apr 3, 2024

@mrdziuban I can't seem to reproduce this.
Tried with Scala 3.3.3, 3.4.0, 3.4.1 and 9a5b9b4
Are you calling the compiler in a specific way? any flags?

@mrdziuban
Copy link
Author

@Gedochao yes, sorry I didn't include that initially, this happens with -Wunused:privates enabled. Here's a scastie that reproduces it: https://scastie.scala-lang.org/mrdziuban/t6lzDsO7RlSHtv1ONz9KBA

@Gedochao
Copy link
Contributor

Gedochao commented Apr 4, 2024

Indeed.
I added the missing option to the repro description.

@Gedochao Gedochao added area:linting Linting warnings enabled with -W or -Xlint and removed stat:cannot reproduce labels Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:linting Linting warnings enabled with -W or -Xlint area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants