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

private[this] doesn't work #19339

Closed
Bersier opened this issue Dec 28, 2023 · 2 comments · Fixed by #19393
Closed

private[this] doesn't work #19339

Bersier opened this issue Dec 28, 2023 · 2 comments · Fixed by #19393

Comments

@Bersier
Copy link
Contributor

Bersier commented Dec 28, 2023

Compiler version

3.3.1

Minimized code

class A:
  private[this] def foo: Int = 1

  def bar(other: A): Int = other.foo

Compiler output

Compiles fine.

Expectation

Compiler warning or error, either

  1. about foo not being visible on other (as in Scala 2).
  2. about private[this] being deprecated/dropped in Scala 3, and having the same meaning as private.

In Scala 3.4.0 Nightly, the compiler warning still does not mention the unexpected semantics of [this] in this context, which doesn't seem documented anywhere. Being deprecated is not the same as being ignored.

@Bersier Bersier added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 28, 2023
@hamzaremmal
Copy link
Member

Related to #18819

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Jan 8, 2024

The migration warning was added in 3.4. I will update the documentation to mke this clear.

The current warning is

-- Warning: t/Test.scala:2:16 --------------------------------------------------
2 |  private[this] def foo: Int = 1
  |                ^
  |The [this] qualifier will be deprecated in the future; it should be dropped.
  |See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
  |This construct can be rewritten automatically under -rewrite -source 3.4-migration.

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

Successfully merging a pull request may close this issue.

4 participants