Skip to content

private[this] doesn't work #19339

Closed
@Bersier

Description

@Bersier

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions