Skip to content

Document behaviour of private modifier for top level classes #11323

Open
@kynthus

Description

@kynthus

I referred to #7780.

In Scala 3, A private global class in the field or return type of a method,
I interpreted that the members themselves do not need to be kept private.

// pkg/Factory.scala

package pkg

protected class Protected // Visible from pkg or its subpackages
private   class Private   // Same as above in Scala3(???)

object Factory {

  def createProtected: Protected = new Protected()
  def createPrivate  : Private   = new Private() // Error in Scala 2, but OK in Scala 3

}

So, I think that protected and private in the global class have the same meaning.
Is this correct?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions