Skip to content

Commit 6abbb55

Browse files
committed
chore: migrate syntaxic changes in the stdlib
1 parent 2f39bfa commit 6abbb55

File tree

181 files changed

+1753
-1747
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+1753
-1747
lines changed

library/src/scala/App.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ trait App extends DelayedInit {
7373
*/
7474
protected final def args: Array[String] = _args
7575

76-
private[this] var _args: Array[String] = _
76+
private var _args: Array[String] = compiletime.uninitialized
7777

78-
private[this] val initCode = new ListBuffer[() => Unit]
78+
private val initCode = new ListBuffer[() => Unit]
7979

8080
/** The init hook. This saves all initialization code for execution within `main`.
8181
* This method is normally never called directly from user code.

library/src/scala/Array.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ object Array {
152152
*
153153
* @see `java.util.Arrays#copyOf`
154154
*/
155-
def copyAs[A](original: Array[_], newLength: Int)(implicit ct: ClassTag[A]): Array[A] = {
155+
def copyAs[A](original: Array[?], newLength: Int)(implicit ct: ClassTag[A]): Array[A] = {
156156
val runtimeClass = ct.runtimeClass
157157
if (runtimeClass == Void.TYPE) newUnitArray(newLength).asInstanceOf[Array[A]]
158158
else {

library/src/scala/Console.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ import scala.util.DynamicVariable
126126
*
127127
*/
128128
object Console extends AnsiColor {
129-
private[this] val outVar = new DynamicVariable[PrintStream](java.lang.System.out)
130-
private[this] val errVar = new DynamicVariable[PrintStream](java.lang.System.err)
131-
private[this] val inVar = new DynamicVariable[BufferedReader](
129+
private val outVar = new DynamicVariable[PrintStream](java.lang.System.out)
130+
private val errVar = new DynamicVariable[PrintStream](java.lang.System.err)
131+
private val inVar = new DynamicVariable[BufferedReader](
132132
new BufferedReader(new InputStreamReader(java.lang.System.in)))
133133

134134
protected def setOutDirect(out: PrintStream): Unit = outVar.value = out
@@ -279,5 +279,5 @@ object Console extends AnsiColor {
279279
* @throws java.lang.IllegalArgumentException if there was a problem with the format string or arguments
280280
* @group console-output
281281
*/
282-
def printf(text: String, args: Any*): Unit = { out.print(text.format(args: _*)) }
282+
def printf(text: String, args: Any*): Unit = { out.print(text.format(args*)) }
283283
}

library/src/scala/Enumeration.scala

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ abstract class Enumeration (initial: Int) extends Serializable {
9999
/** The name of this enumeration.
100100
*/
101101
override def toString: String =
102-
((getClass.getName stripSuffix MODULE_SUFFIX_STRING split '.').last split
103-
Regex.quote(NAME_JOIN_STRING)).last
102+
getClass.getName
103+
.stripSuffix(MODULE_SUFFIX_STRING)
104+
.split('.')
105+
.last
106+
.split(Regex.quote(NAME_JOIN_STRING))
107+
.last
104108

105109
/** The mapping from the integer used to identify values to the actual
106110
* values. */
@@ -112,7 +116,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
112116

113117
/** The mapping from the integer used to identify values to their
114118
* names. */
115-
private[this] val nmap: mutable.Map[Int, String] = new mutable.HashMap
119+
private val nmap: mutable.Map[Int, String] = new mutable.HashMap
116120

117121
/** The values of this enumeration as a set.
118122
*/
@@ -128,18 +132,18 @@ abstract class Enumeration (initial: Int) extends Serializable {
128132
protected var nextId: Int = initial
129133

130134
/** The string to use to name the next created value. */
131-
protected var nextName: Iterator[String] = _
135+
protected var nextName: Iterator[String] = compiletime.uninitialized
132136

133137
private def nextNameOrNull: String | Null =
134138
if (nextName != null && nextName.hasNext) nextName.next() else null
135139

136140
/** The highest integer amongst those used to identify values in this
137141
* enumeration. */
138-
private[this] var topId = initial
142+
private var topId = initial
139143

140144
/** The lowest integer amongst those used to identify values in this
141145
* enumeration, but no higher than 0. */
142-
private[this] var bottomId = if(initial < 0) initial else 0
146+
private var bottomId = if(initial < 0) initial else 0
143147

144148
/** The one higher than the highest integer amongst those used to identify
145149
* values in this enumeration. */
@@ -190,7 +194,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
190194
protected final def Value(i: Int, name: String | Null): Value = new Val(i, name)
191195

192196
private def populateNameMap(): Unit = {
193-
@tailrec def getFields(clazz: Class[_] | Null, acc: Array[JField]): Array[JField] = {
197+
@tailrec def getFields(clazz: Class[?] | Null, acc: Array[JField]): Array[JField] = {
194198
if (clazz == null)
195199
acc
196200
else
@@ -285,7 +289,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
285289
* @define Coll `collection.immutable.SortedSet`
286290
*/
287291
@SerialVersionUID(7229671200427364242L)
288-
class ValueSet private[ValueSet] (private[this] var nnIds: immutable.BitSet)
292+
class ValueSet private[ValueSet] (private var nnIds: immutable.BitSet)
289293
extends immutable.AbstractSet[Value]
290294
with immutable.SortedSet[Value]
291295
with immutable.SortedSetOps[Value, immutable.SortedSet, ValueSet]
@@ -341,7 +345,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
341345
def fromBitMask(elems: Array[Long]): ValueSet = new ValueSet(immutable.BitSet.fromBitMask(elems))
342346
/** A builder object for value sets */
343347
def newBuilder: mutable.Builder[Value, ValueSet] = new mutable.Builder[Value, ValueSet] {
344-
private[this] val b = new mutable.BitSet
348+
private val b = new mutable.BitSet
345349
def addOne (x: Value) = { b += (x.id - bottomId); this }
346350
def clear() = b.clear()
347351
def result() = new ValueSet(b.toImmutable)

library/src/scala/MatchError.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class MatchError(@transient obj: Any) extends RuntimeException {
2222
/** There's no reason we need to call toString eagerly,
2323
* so defer it until getMessage is called or object is serialized
2424
*/
25-
private[this] lazy val objString: String = {
25+
private lazy val objString: String = {
2626
def ofClass = "of class " + obj.getClass.getName
2727
if (obj == null) "null"
2828
else

library/src/scala/PartialFunction.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ object PartialFunction {
341341
*
342342
* Here `fallback_fn` is used as both unique marker object and special fallback function that returns it.
343343
*/
344-
private[this] val fallback_fn: Any -> Any = _ => fallback_fn
344+
private val fallback_fn: Any -> Any = _ => fallback_fn
345345
private def checkFallback[B] = fallback_fn.asInstanceOf[Any => B]
346346
private def fallbackOccurred[B](x: B) = fallback_fn eq x.asInstanceOf[AnyRef]
347347

@@ -376,9 +376,9 @@ object PartialFunction {
376376
*/
377377
def fromFunction[A, B](f: A => B): PartialFunction[A, B]^{f} = { case x => f(x) }
378378

379-
private[this] val constFalse: Any -> Boolean = { _ => false}
379+
private val constFalse: Any -> Boolean = { _ => false}
380380

381-
private[this] val empty_pf: PartialFunction[Any, Nothing] = new PartialFunction[Any, Nothing] with Serializable {
381+
private val empty_pf: PartialFunction[Any, Nothing] = new PartialFunction[Any, Nothing] with Serializable {
382382
def isDefinedAt(x: Any) = false
383383
def apply(x: Any) = throw new MatchError(x)
384384
override def orElse[A1, B1](that: PartialFunction[A1, B1]^) = that

library/src/scala/Predef.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ object Predef extends LowPriorityImplicits {
498498
* @see [[scala.StringContext.f StringContext.f]]
499499
* @group console-output
500500
*/
501-
def printf(text: String, xs: Any*): Unit = Console.print(text.format(xs: _*))
501+
def printf(text: String, xs: Any*): Unit = Console.print(text.format(xs*))
502502

503503
// views --------------------------------------------------------------
504504

library/src/scala/Product.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ transparent trait Product extends Any with Equals {
3838
* @return in the default implementation, an `Iterator[Any]`
3939
*/
4040
def productIterator: Iterator[Any] = new scala.collection.AbstractIterator[Any] {
41-
private[this] var c: Int = 0
42-
private[this] val cmax = productArity
41+
private var c: Int = 0
42+
private val cmax = productArity
4343
def hasNext: Boolean = c < cmax
4444
def next(): Any = { val result = productElement(c); c += 1; result }
4545
}
@@ -66,8 +66,8 @@ transparent trait Product extends Any with Equals {
6666
/** An iterator over the names of all the elements of this product.
6767
*/
6868
def productElementNames: Iterator[String] = new scala.collection.AbstractIterator[String] {
69-
private[this] var c: Int = 0
70-
private[this] val cmax = productArity
69+
private var c: Int = 0
70+
private val cmax = productArity
7171
def hasNext: Boolean = c < cmax
7272
def next(): String = { val result = productElementName(c); c += 1; result }
7373
}

library/src/scala/Proxy.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait Proxy extends Any {
3434
case null => false
3535
case _ =>
3636
val x = that.asInstanceOf[AnyRef]
37-
(x eq this.asInstanceOf[AnyRef]) || (x eq self.asInstanceOf[AnyRef]) || (x equals self)
37+
(x eq this.asInstanceOf[AnyRef]) || (x eq self.asInstanceOf[AnyRef]) || (x.equals(self))
3838
}
3939
override def toString = "" + self
4040
}

library/src/scala/StringContext.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ object StringContext {
313313
s"""invalid unicode escape at index $index of $str"""
314314
)
315315

316-
private[this] def readUEscape(src: String, startindex: Int): (Char, Int) = {
316+
private def readUEscape(src: String, startindex: Int): (Char, Int) = {
317317
val len = src.length()
318318
def loop(uindex: Int): (Char, Int) = {
319319
def loopCP(dindex: Int, codepoint: Int): (Char, Int) = {
@@ -362,19 +362,19 @@ object StringContext {
362362
* @return The string with all escape sequences expanded.
363363
*/
364364
def processEscapes(str: String): String =
365-
str indexOf '\\' match {
365+
str.indexOf('\\') match {
366366
case -1 => str
367367
case i => replace(str, i)
368368
}
369369

370370
protected[scala] def processUnicode(str: String): String =
371-
str indexOf "\\u" match {
371+
str.indexOf("\\u") match {
372372
case -1 => str
373373
case i => replaceU(str, i)
374374
}
375375

376376
//replace escapes with given first escape
377-
private[this] def replace(str: String, first: Int): String = {
377+
private def replace(str: String, first: Int): String = {
378378
val len = str.length()
379379
val b = new JLSBuilder
380380
// append replacement starting at index `i`, with `next` backslash
@@ -399,7 +399,7 @@ object StringContext {
399399
val (ch, advance) = if (c == 'u') readUEscape(str, idx)
400400
else (c, 1)
401401
idx += advance
402-
b append ch
402+
b.append(ch)
403403
loop(idx, str.indexOf('\\', idx))
404404
} else {
405405
if (i < len) b.append(str, i, len)
@@ -423,7 +423,7 @@ object StringContext {
423423
* Otherwise, the backslash is not taken to introduce an escape and the
424424
* backslash is taken to be literal
425425
*/
426-
private[this] def replaceU(str: String, backslash: Int): String = {
426+
private def replaceU(str: String, backslash: Int): String = {
427427
val len = str.length()
428428
val b = new JLSBuilder
429429

@@ -458,8 +458,8 @@ object StringContext {
458458
val ai = args.iterator
459459
val bldr = new JLSBuilder(process(pi.next()))
460460
while (ai.hasNext) {
461-
bldr append ai.next()
462-
bldr append process(pi.next())
461+
bldr.append(ai.next())
462+
bldr.append(process(pi.next()))
463463
}
464464
bldr.toString
465465
}

0 commit comments

Comments
 (0)