Skip to content

refactor: replace private[this] with private#1002

Open
He-Pin wants to merge 1 commit into
databricks:masterfrom
He-Pin:refactor/remove-private-this
Open

refactor: replace private[this] with private#1002
He-Pin wants to merge 1 commit into
databricks:masterfrom
He-Pin:refactor/remove-private-this

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Motivation

private[this] restricts access to the current instance only, but in
singleton objects there is only one instance, making it semantically
identical to private. In the final class StringBuilderWriter, the
builder field has no cross-instance access. Using private uniformly
simplifies the access modifier vocabulary without changing behavior.

Modification

  • Renderer.scala: private[this] val builder -> private val builder
    (no cross-instance .builder access exists).
  • SetModule.scala: 8 private[this] final val constants and 2
    @inline private[this] def methods -> private / @inline private.

Result

Cleaner, more idiomatic Scala with no semantic change. Compiles
cleanly on Scala 2.12/2.13/3.3 and all tests pass.

References

None — pure style refactor.

Motivation:
`private[this]` restricts access to the current instance only, but in
singleton objects there is only one instance, making it semantically
identical to `private`. In the final class `StringBuilderWriter`, the
`builder` field has no cross-instance access. Using `private` uniformly
simplifies the access modifier vocabulary without changing behavior.

Modification:
- Renderer.scala: `private[this] val builder` → `private val builder`
- SetModule.scala: 8 `private[this] final val` constants and 2
  `@inline private[this] def` methods → `private` / `@inline private`

Result:
Cleaner, more idiomatic Scala with no semantic change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant