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

Private types trigger false positive with -Ywarn-unused:-privates #11387

Open
eatkins opened this Issue Jan 31, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@eatkins
Copy link

eatkins commented Jan 31, 2019

The following code will generate the error "private type Alias in object Foo is never used" in scala 2.12.8:

class Foo
object Foo {
  private type Alias = Foo
  def x: Foo = new Alias
}

This issue also came up in the example provided by @varming in the discussion of
#10313.

@SethTisue

This comment has been minimized.

Copy link
Member

SethTisue commented Jan 31, 2019

I'm an unclear on why this should be a separate ticket from #10313?

@SethTisue SethTisue added this to the Backlog milestone Jan 31, 2019

@som-snytt

This comment has been minimized.

Copy link

som-snytt commented Jan 31, 2019

The other example from the other ticket:

scala> object X { private class Y ; class Z extends Y }
                                                    ^
       error: private class Y escapes its defining scope as part of type X.Y

scala> object X { private class Y ; private type YY = Y ; class Z extends YY }
defined object X

I don't know if it's the same symptom. I see YY is unused after uncurry.

Edit: the other ticket was arguably about interaction with macros, but a better mechanism would probably address both bugs.

@eatkins

This comment has been minimized.

Copy link
Author

eatkins commented Feb 1, 2019

I see that @som-snytt already chimed in, but it was his suggestion at the bottom of #10313 that prompted my opening this issue. I have run into the issue multiple times in sbt which has both -Xfatal-warnings and -Ywarn-unused:-private set. I'd have no problem with unifying the two issues either in #10313 itself or a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment