Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ the bottom of this file. Restoration ships incrementally per feature area.
compiles).
- `enum` was renamed to `e` at one call site in `GenKeyCodec` (`enum` is reserved in Scala 3).
- `@targetName` annotation added to `CloseableIterator` overloaded methods.
- `private[this]` qualifier dropped on ~64 members across core / hocon / mongo. Plain
`private` has identical semantics in Scala 3 (the dialect deprecates `private[this]`
since 3.4.0). No access-level change for downstream callers; for `private[this] var`
fields the JVM-level accessor synthesis is now equivalent to a plain `private var`
(Scala 3 inlines `private` vars directly — no perf delta vs. the old qualifier).

### mongo

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class ObservableBlockingIterator[T](

import ObservableBlockingIterator._

@volatile private[this] var last: Any = Empty
@volatile private[this] var ackPromise: Promise[Ack] = _
@volatile private var last: Any = Empty
@volatile private var ackPromise: Promise[Ack] = _
private val queue = new ArrayBlockingQueue[Any](bufferSize)
private val cancelable = observable.subscribe(this)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ object GuavaInterop extends GuavaInterop {
p.future
}

private[this] def unwrapFailures(expr: => T): T =
private def unwrapFailures(expr: => T): T =
try expr
catch {
case ee: ExecutionException => throw ee.getCause
Expand Down Expand Up @@ -144,7 +144,7 @@ object GuavaInterop extends GuavaInterop {
def isCancelled: Boolean =
false

private[this] def wrapFailures(expr: => T): T =
private def wrapFailures(expr: => T): T =
try expr
catch {
case NonFatal(e) => throw new ExecutionException(e)
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/scala/com/avsystem/commons/SharedExtensions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,10 @@ object SharedExtensionsUtils extends SharedExtensions {

def collectWhileDefined[B](pf: PartialFunction[A, B]): Iterator[B] =
new AbstractIterator[B] {
private[this] var fetched = false
private[this] var value: NOpt[B] = _
private var fetched = false
private var value: NOpt[B] = _

private[this] def fetch(): Unit =
private def fetch(): Unit =
if (it.hasNext) {
value = pf.applyNOpt(it.next())
} else {
Expand Down Expand Up @@ -745,8 +745,8 @@ object SharedExtensionsUtils extends SharedExtensions {
object IteratorCompanionOps {
def untilEmpty[T](elem: => Opt[T]): Iterator[T] =
new AbstractIterator[T] {
private[this] var fetched = false
private[this] var value = Opt.empty[T]
private var fetched = false
private var value = Opt.empty[T]

def hasNext: Boolean = {
if (!fetched) {
Expand All @@ -772,8 +772,8 @@ object SharedExtensionsUtils extends SharedExtensions {

def iterateUntilEmpty[T](start: Opt[T])(nextFun: T => Opt[T]): Iterator[T] =
new AbstractIterator[T] {
private[this] var fetched = true
private[this] var value = start
private var fetched = true
private var value = start

def hasNext: Boolean = {
if (!fetched) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.avsystem.commons
package collection

final class MutableStack[T] {
private[this] var ssize: Int = 0
private[this] var stack = List.empty[T]
private var ssize: Int = 0
private var stack = List.empty[T]

def push(elem: T): Unit = {
stack ::= elem
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/com/avsystem/commons/di/Component.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class Component[+T](
*/
lazy val dependencies: IndexedSeq[Component[_]] = deps

private[this] val storage: AtomicReference[Future[T]] =
private val storage: AtomicReference[Future[T]] =
cachedStorage.getOrElse(new AtomicReference)

private def sameStorage(otherStorage: AtomicReference[_]): Boolean =
Expand Down Expand Up @@ -183,7 +183,7 @@ object Component {
def emptyDestroy[T]: DestroyFunction[T] =
reusableEmptyDestroy.asInstanceOf[DestroyFunction[T]]

private[this] val reusableEmptyDestroy: DestroyFunction[Any] =
private val reusableEmptyDestroy: DestroyFunction[Any] =
_ => _ => Future.unit

def async[T](definition: => T): ExecutionContext => Future[T] =
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/scala/com/avsystem/commons/meta/metadata.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ final case class ParamFlags(rawFlags: Int) extends AnyVal {
}

object ParamFlags extends HasGenCodec[ParamFlags] {
private[this] var currentFlag: Int = 1
private[this] def nextFlag(): ParamFlags = {
private var currentFlag: Int = 1
private def nextFlag(): ParamFlags = {
val flag = currentFlag
currentFlag = currentFlag << 1
new ParamFlags(flag)
Expand Down Expand Up @@ -152,8 +152,8 @@ final case class TypeFlags(rawFlags: Int) extends AnyVal {
}

object TypeFlags extends HasGenCodec[TypeFlags] {
private[this] var currentFlag: Int = 1
private[this] def nextFlag(): TypeFlags = {
private var currentFlag: Int = 1
private def nextFlag(): TypeFlags = {
val flag = currentFlag
currentFlag = currentFlag << 1
new TypeFlags(flag)
Expand Down Expand Up @@ -212,8 +212,8 @@ final case class MethodFlags(rawFlags: Int) extends AnyVal {
}
}
object MethodFlags extends HasGenCodec[MethodFlags] {
private[this] var currentFlag: Int = 1
private[this] def nextFlag(): MethodFlags = {
private var currentFlag: Int = 1
private def nextFlag(): MethodFlags = {
val flag = currentFlag
currentFlag = currentFlag << 1
new MethodFlags(flag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object AnnotationsOf {
@implicitNotFound("${T} is not annotated with ${A}")
final class HasAnnotation[A, T] private ()
object HasAnnotation {
private[this] val reusable = new HasAnnotation
private val reusable = new HasAnnotation
def create[A, T]: HasAnnotation[A, T] = reusable.asInstanceOf[HasAnnotation[A, T]]

// TODO[scala3-port]: HasAnnotation.materialize (Scala 2 macro def) (L)
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/scala/com/avsystem/commons/misc/ValueEnum.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ sealed trait EnumCtx extends Any {
trait ValueEnumCompanion[T <: ValueEnum] extends NamedEnumCompanion[T] { companion =>
type Value = T

private[this] val registryBuilder = IIndexedSeq.newBuilder[T]
private[this] var currentOrdinal: Int = 0
private[this] var finished: Boolean = false
private[this] var awaitingRegister: Boolean = false
private val registryBuilder = IIndexedSeq.newBuilder[T]
private var currentOrdinal: Int = 0
private var finished: Boolean = false
private var awaitingRegister: Boolean = false

/** Holds an indexed sequence of all enum values, ordered by their ordinal (`values(i).ordinal` is always equal to
* `i`).
Expand All @@ -104,7 +104,7 @@ trait ValueEnumCompanion[T <: ValueEnum] extends NamedEnumCompanion[T] { compani
}
awaitingRegister = true

private[this] var registered = false
private var registered = false

override def register(value: ValueEnum): Unit = companion.synchronized {
if (finished)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ final class DefaultCaseObjectInput(firstField: FieldInput, actualInput: ObjectIn

override def knownSize: Int = actualInput.knownSize

private[this] var atFirstField = true
private var atFirstField = true

def hasNext: Boolean = atFirstField || actualInput.hasNext
def nextField(): FieldInput =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package serialization
/** Wrapper over [[ObjectInput]] that lets you peek next field name without advancing the input.
*/
final class PeekingObjectInput(original: ObjectInput) extends ObjectInput {
private[this] var peekedField: FieldInput = _
private var peekedField: FieldInput = _

override def knownSize: Int = original.knownSize

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class StreamInput(is: DataInputStream) extends InputAndSimpleInput {
class StreamFieldInput(val fieldName: String, is: DataInputStream) extends StreamInput(is) with FieldInput

private class StreamListInput(is: DataInputStream) extends ListInput {
private[this] var currentInput: Opt[StreamInput] = Opt.empty
private var currentInput: Opt[StreamInput] = Opt.empty

private def ensureInput(): Unit =
if (currentInput == Opt.empty) currentInput = Opt.some(new StreamInput(is))
Expand All @@ -159,7 +159,7 @@ private class StreamObjectInput(is: DataInputStream) extends ObjectInput {

import StreamObjectInput._

private[this] var currentField: FieldInput = NoneYet
private var currentField: FieldInput = NoneYet

private def ensureInput(): Unit = {
if (currentField eq NoneYet) {
Expand Down Expand Up @@ -216,8 +216,8 @@ private object StreamObjectInput {

class StreamOutput(os: DataOutputStream) extends OutputAndSimpleOutput {

private[this] val streamList = new StreamListOutput(os, this)
private[this] val streamObject = new StreamObjectOutput(os, this)
private val streamList = new StreamListOutput(os, this)
private val streamObject = new StreamObjectOutput(os, this)

def writeNull(): Unit = os.write(NullMarker)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java.nio.charset.StandardCharsets
import scala.annotation.tailrec

final class CborReader(val data: RawCbor) {
private[this] var idx = 0
private var idx = 0

def index: Int = idx

Expand Down Expand Up @@ -87,7 +87,7 @@ final class CborReader(val data: RawCbor) {
res
}

private[this] var openIndefs = 0 // number of currently open values of indefinite length
private var openIndefs = 0 // number of currently open values of indefinite length

def openIndefinites: Int =
openIndefs
Expand Down Expand Up @@ -402,7 +402,7 @@ class CborInput(reader: CborReader, keyCodec: CborKeyCodec) extends InputAndSimp
class CborFieldInput(val fieldName: String, reader: CborReader, keyCodec: CborKeyCodec)
extends CborInput(reader, keyCodec) with FieldInput

abstract class CborSequentialInput(reader: CborReader, private[this] var size: Int) extends SequentialInput {
abstract class CborSequentialInput(reader: CborReader, private var size: Int) extends SequentialInput {

private val indefDepth = reader.openIndefinites

Expand Down Expand Up @@ -440,8 +440,8 @@ class CborListInput(reader: CborReader, size: Int, keyCodec: CborKeyCodec)
class CborObjectInput(reader: CborReader, size: Int, keyCodec: CborKeyCodec)
extends CborSequentialInput(reader, size) with ObjectInput {

private[this] var forcedKeyCodec: CborKeyCodec = _
private[this] def currentKeyCodec = if (forcedKeyCodec != null) forcedKeyCodec else keyCodec
private var forcedKeyCodec: CborKeyCodec = _
private def currentKeyCodec = if (forcedKeyCodec != null) forcedKeyCodec else keyCodec

/** Returns a [[CborOutput]] for reading a raw CBOR field key. This is an extension over standard [[ObjectOutput]]
* which only allows string-typed keys. If this method is used to read the key then value MUST be read with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ class CborObjectOutput(
) extends CborSequentialOutput(out, sizePolicy)
with ObjectOutput {

private[this] var forcedKeyCodec: CborKeyCodec = _
private[this] def currentKeyCodec = if (forcedKeyCodec != null) forcedKeyCodec else keyCodec
private var forcedKeyCodec: CborKeyCodec = _
private def currentKeyCodec = if (forcedKeyCodec != null) forcedKeyCodec else keyCodec

/** Returns a [[CborOutput]] for writing an arbitrary CBOR map key. This method is an extension of standard [[Output]]
* which only allows string-typed keys. If a key is written using this method then its corresponding value MUST be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class JsonStringInput(
) extends InputAndSimpleInput
with AfterElement {

private[this] val startIdx: Int = reader.parseValue()
private[this] var endIdx: Int = _
private val startIdx: Int = reader.parseValue()
private var endIdx: Int = _

reader.jsonType match {
case JsonType.list | JsonType.`object` =>
Expand Down Expand Up @@ -207,7 +207,7 @@ final class JsonStringFieldInput(
final class JsonListInput(reader: JsonReader, options: JsonOptions, callback: AfterElement)
extends ListInput with AfterElement {

private[this] var end = false
private var end = false

prepareForNext(first = true)

Expand All @@ -230,12 +230,12 @@ final class JsonListInput(reader: JsonReader, options: JsonOptions, callback: Af
final class JsonObjectInput(reader: JsonReader, options: JsonOptions, callback: AfterElement)
extends ObjectInput with AfterElement {

private[this] var end = false
private var end = false

prepareForNext(first = true)

private[this] var peekIdx = if (end) -1 else reader.index
private[this] var peekedFields: CrossUtils.NativeDict[Int] = _
private var peekIdx = if (end) -1 else reader.index
private var peekedFields: CrossUtils.NativeDict[Int] = _

private def prepareForNext(first: Boolean): Unit = {
reader.skipWs()
Expand Down Expand Up @@ -314,9 +314,9 @@ final class JsonObjectInput(reader: JsonReader, options: JsonOptions, callback:
final class JsonReader(val json: String) {
json.checkNotNull("null JSON string")

private[this] var i: Int = 0
private[this] var value: Any = _
private[this] var tpe: JsonType = _
private var i: Int = 0
private var value: Any = _
private var tpe: JsonType = _

def index: Int = i
def currentValue: Any = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ final class JsonListOutput(builder: JStringBuilder, options: JsonOptions, depth:

override def sizePolicy: SizePolicy = SizePolicy.Ignored

private[this] var first = true
private var first = true

def writeElement(): JsonStringOutput = {
builder.append(if (first) '[' else ',')
Expand All @@ -165,7 +165,7 @@ final class JsonObjectOutput(builder: JStringBuilder, options: JsonOptions, dept

override def sizePolicy: SizePolicy = SizePolicy.Ignored

private[this] var first = true
private var first = true

def writeField(key: String): JsonStringOutput = {
builder.append(if (first) '{' else ',')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract class ApplyUnapplyCodec[T](
protected def dependencies: Array[GenCodec[_]]
protected def instantiate(fieldValues: FieldValues): T

private[this] lazy val deps = dependencies
private lazy val deps = dependencies

protected final def writeField[A](output: ObjectOutput, idx: Int, value: A): Unit =
writeField(fieldNames(idx), output, value, deps(idx).asInstanceOf[GenCodec[A]])
Expand Down Expand Up @@ -154,7 +154,7 @@ abstract class NestedSealedHierarchyCodec[T](

def caseDependencies: Array[GenCodec[_]]

private[this] lazy val caseDeps = caseDependencies
private lazy val caseDeps = caseDependencies

final def writeObject(output: ObjectOutput, value: T): Unit = {
val caseIdx = caseIndexByValue(value)
Expand Down Expand Up @@ -188,8 +188,8 @@ abstract class FlatSealedHierarchyCodec[T](
def oooDependencies: Array[GenCodec[_]]
def caseDependencies: Array[OOOFieldsObjectCodec[_]]

private[this] lazy val oooDeps = oooDependencies
private[this] lazy val caseDeps = caseDependencies
private lazy val oooDeps = oooDependencies
private lazy val caseDeps = caseDependencies

final def writeObject(output: ObjectOutput, value: T): Unit = {
val caseIdx = caseIndexByValue(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HParser(tokens: IndexedSeq[HToken]) {
import HTokenType._
import HTree._

private[this] var idx = 0
private var idx = 0

private def fail(): Nothing =
if (eof) throw new EOFException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ object HTokenType extends SealedEnumCompanion[HTokenType] {
}

class HLexer(input: SourceFile) {
private[this] val chars = input.contents
private[this] var tokenIdx = 0
private[this] var off = -1
private val chars = input.contents
private var tokenIdx = 0
private var off = -1

def next(): HToken =
if (off == -1) {
Expand Down
Loading
Loading