Skip to content

Commit

Permalink
Prevent dotty to remove unused private fields. Ref: lampepfl/dotty 8579
Browse files Browse the repository at this point in the history
  • Loading branch information
giabao committed Jul 11, 2020
1 parent c0f5e32 commit 26394d4
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ private[akka] class RepointableActorRef(
*/
@silent @volatile private var _cellDoNotCallMeDirectly: Cell = _
@silent @volatile private var _lookupDoNotCallMeDirectly: Cell = _
@silent private def _dotty_pls_dont_remove_my_unused_private = {
_cellDoNotCallMeDirectly
_lookupDoNotCallMeDirectly
}

def underlying: Cell = Unsafe.instance.getObjectVolatile(this, cellOffset).asInstanceOf[Cell]
def lookup = Unsafe.instance.getObjectVolatile(this, lookupOffset).asInstanceOf[Cell]
Expand Down
6 changes: 6 additions & 0 deletions akka-actor/src/main/scala/akka/actor/dungeon/Children.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ private[akka] trait Children { this: ActorCell =>
}

@silent @volatile private var _nextNameDoNotCallMeDirectly = 0L
@silent private def _dotty_pls_dont_remove_my_unused_private = {
_childrenRefsDoNotCallMeDirectly
_functionRefsDoNotCallMeDirectly
_nextNameDoNotCallMeDirectly
}

final protected def randomName(sb: java.lang.StringBuilder): String = {
val num = Unsafe.instance.getAndAddLong(this, AbstractActorCell.nextNameOffset, 1)
Helpers.base64(num, sb)
Expand Down
2 changes: 2 additions & 0 deletions akka-actor/src/main/scala/akka/actor/dungeon/Dispatch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ private[akka] trait Dispatch { this: ActorCell =>
@silent @volatile private var _mailboxDoNotCallMeDirectly
: Mailbox = _ //This must be volatile since it isn't protected by the mailbox status

@silent private def _dotty_pls_dont_remove_my_unused_private = _mailboxDoNotCallMeDirectly

@inline final def mailbox: Mailbox =
Unsafe.instance.getObjectVolatile(this, AbstractActorCell.mailboxOffset).asInstanceOf[Mailbox]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ abstract class MessageDispatcher(val configurator: MessageDispatcherConfigurator

@silent @volatile private[this] var _inhabitantsDoNotCallMeDirectly: Long = _ // DO NOT TOUCH!
@silent @volatile private[this] var _shutdownScheduleDoNotCallMeDirectly: Int = _ // DO NOT TOUCH!
@silent private def _dotty_pls_dont_remove_my_unused_private = {
_inhabitantsDoNotCallMeDirectly
_shutdownScheduleDoNotCallMeDirectly
}

private final def addInhabitants(add: Long): Long = {
val old = Unsafe.instance.getAndAddLong(this, inhabitantsOffset, add)
Expand Down
5 changes: 5 additions & 0 deletions akka-actor/src/main/scala/akka/pattern/AskSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,11 @@ private[akka] final class PromiseActorRef private (
@silent("never used")
private[this] var _watchedByDoNotCallMeDirectly: Set[ActorRef] = ActorCell.emptyActorRefSet

@silent private def _dotty_pls_dont_remove_my_unused_private = {
_stateDoNotCallMeDirectly
_watchedByDoNotCallMeDirectly
}

@inline
private[this] def watchedBy: Set[ActorRef] =
Unsafe.instance.getObjectVolatile(this, watchedByOffset).asInstanceOf[Set[ActorRef]]
Expand Down
4 changes: 4 additions & 0 deletions akka-actor/src/main/scala/akka/pattern/CircuitBreaker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ class CircuitBreaker(
@volatile
@silent("never used")
private[this] var _currentResetTimeoutDoNotCallMeDirectly: FiniteDuration = resetTimeout
@silent private def _dotty_pls_dont_remove_my_unused_private = {
_currentStateDoNotCallMeDirectly
_currentResetTimeoutDoNotCallMeDirectly
}

/**
* Helper method for access to underlying state via Unsafe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ private[remote] class Association(
@volatile
@silent("never used")
private[this] var _sharedStateDoNotCallMeDirectly: AssociationState = AssociationState()
@silent private def _dotty_pls_dont_remove_my_unused_private = {
_sharedStateDoNotCallMeDirectly
}

/**
* Helper method for access to underlying state via Unsafe
Expand Down

0 comments on commit 26394d4

Please sign in to comment.