Skip to content
Merged
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
6 changes: 3 additions & 3 deletions library/src/scala/App.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import scala.collection.mutable.ListBuffer
* }
* }}}
*/
@nowarn("""cat=deprecation&origin=scala\.DelayedInit""")
@nowarn("cat=deprecation")
trait App extends DelayedInit {

/** The time when the execution of this program started, in milliseconds since 1
Expand All @@ -73,9 +73,9 @@ trait App extends DelayedInit {
*/
protected final def args: Array[String] = _args

private[this] var _args: Array[String] = _
private var _args: Array[String] = compiletime.uninitialized

private[this] val initCode = new ListBuffer[() => Unit]
private val initCode = new ListBuffer[() => Unit]

/** The init hook. This saves all initialization code for execution within `main`.
* This method is normally never called directly from user code.
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/Array.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ object Array {
*
* @see `java.util.Arrays#copyOf`
*/
def copyAs[A](original: Array[_], newLength: Int)(implicit ct: ClassTag[A]): Array[A] = {
def copyAs[A](original: Array[?], newLength: Int)(implicit ct: ClassTag[A]): Array[A] = {
val runtimeClass = ct.runtimeClass
if (runtimeClass == Void.TYPE) newUnitArray(newLength).asInstanceOf[Array[A]]
else {
Expand Down
8 changes: 4 additions & 4 deletions library/src/scala/Console.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ import scala.util.DynamicVariable
*
*/
object Console extends AnsiColor {
private[this] val outVar = new DynamicVariable[PrintStream](java.lang.System.out)
private[this] val errVar = new DynamicVariable[PrintStream](java.lang.System.err)
private[this] val inVar = new DynamicVariable[BufferedReader](
private val outVar = new DynamicVariable[PrintStream](java.lang.System.out)
private val errVar = new DynamicVariable[PrintStream](java.lang.System.err)
private val inVar = new DynamicVariable[BufferedReader](
new BufferedReader(new InputStreamReader(java.lang.System.in)))

protected def setOutDirect(out: PrintStream): Unit = outVar.value = out
Expand Down Expand Up @@ -279,5 +279,5 @@ object Console extends AnsiColor {
* @throws java.lang.IllegalArgumentException if there was a problem with the format string or arguments
* @group console-output
*/
def printf(text: String, args: Any*): Unit = { out.print(text.format(args: _*)) }
def printf(text: String, args: Any*): Unit = { out.print(text.format(args*)) }
}
22 changes: 13 additions & 9 deletions library/src/scala/Enumeration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ abstract class Enumeration (initial: Int) extends Serializable {
/** The name of this enumeration.
*/
override def toString: String =
((getClass.getName stripSuffix MODULE_SUFFIX_STRING split '.').last split
Regex.quote(NAME_JOIN_STRING)).last
getClass.getName
.stripSuffix(MODULE_SUFFIX_STRING)
.split('.')
.last
.split(Regex.quote(NAME_JOIN_STRING))
.last

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

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

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

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

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

/** The highest integer amongst those used to identify values in this
* enumeration. */
private[this] var topId = initial
private var topId = initial

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

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

private def populateNameMap(): Unit = {
@tailrec def getFields(clazz: Class[_] | Null, acc: Array[JField]): Array[JField] = {
@tailrec def getFields(clazz: Class[?] | Null, acc: Array[JField]): Array[JField] = {
if (clazz == null)
acc
else
Expand Down Expand Up @@ -285,7 +289,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
* @define Coll `collection.immutable.SortedSet`
*/
@SerialVersionUID(7229671200427364242L)
class ValueSet private[ValueSet] (private[this] var nnIds: immutable.BitSet)
class ValueSet private[ValueSet] (private var nnIds: immutable.BitSet)
extends immutable.AbstractSet[Value]
with immutable.SortedSet[Value]
with immutable.SortedSetOps[Value, immutable.SortedSet, ValueSet]
Expand Down Expand Up @@ -341,7 +345,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
def fromBitMask(elems: Array[Long]): ValueSet = new ValueSet(immutable.BitSet.fromBitMask(elems))
/** A builder object for value sets */
def newBuilder: mutable.Builder[Value, ValueSet] = new mutable.Builder[Value, ValueSet] {
private[this] val b = new mutable.BitSet
private val b = new mutable.BitSet
def addOne (x: Value) = { b += (x.id - bottomId); this }
def clear() = b.clear()
def result() = new ValueSet(b.toImmutable)
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/MatchError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class MatchError(@transient obj: Any) extends RuntimeException {
/** There's no reason we need to call toString eagerly,
* so defer it until getMessage is called or object is serialized
*/
private[this] lazy val objString: String = {
private lazy val objString: String = {
def ofClass = "of class " + obj.getClass.getName
if (obj == null) "null"
else
Expand Down
18 changes: 10 additions & 8 deletions library/src/scala/PartialFunction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import scala.language.`2.13`
import scala.annotation.nowarn

import language.experimental.captureChecking
import scala.util.boundary
import scala.util.boundary.break

/** A partial function of type `PartialFunction[A, B]` is a unary function
* where the domain does not necessarily include all values of type `A`.
Expand Down Expand Up @@ -262,12 +264,12 @@ trait PartialFunction[-A, +B] extends Function1[A, B] { self: PartialFunction[A,
object PartialFunction {

final class ElementWiseExtractor[-A, +B] private[PartialFunction] (private val pf: PartialFunction[A, B]^) extends AnyVal { this: ElementWiseExtractor[A, B]^ =>
@nowarn("cat=lint-nonlocal-return")
def unapplySeq(seq: Seq[A]): Option[Seq[B]] = {
Some(seq.map {
case pf(b) => b
case _ => return None
})
boundary:
Some(seq.map:
case pf(b) => b
case _ => boundary.break(None)
)
}
}

Expand Down Expand Up @@ -341,7 +343,7 @@ object PartialFunction {
*
* Here `fallback_fn` is used as both unique marker object and special fallback function that returns it.
*/
private[this] val fallback_fn: Any -> Any = _ => fallback_fn
private val fallback_fn: Any -> Any = _ => fallback_fn
private def checkFallback[B] = fallback_fn.asInstanceOf[Any => B]
private def fallbackOccurred[B](x: B) = fallback_fn eq x.asInstanceOf[AnyRef]

Expand Down Expand Up @@ -376,9 +378,9 @@ object PartialFunction {
*/
def fromFunction[A, B](f: A => B): PartialFunction[A, B]^{f} = { case x => f(x) }

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

private[this] val empty_pf: PartialFunction[Any, Nothing] = new PartialFunction[Any, Nothing] with Serializable {
private val empty_pf: PartialFunction[Any, Nothing] = new PartialFunction[Any, Nothing] with Serializable {
def isDefinedAt(x: Any) = false
def apply(x: Any) = throw new MatchError(x)
override def orElse[A1, B1](that: PartialFunction[A1, B1]^) = that
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/Predef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ object Predef extends LowPriorityImplicits {
* @see [[scala.StringContext.f StringContext.f]]
* @group console-output
*/
def printf(text: String, xs: Any*): Unit = Console.print(text.format(xs: _*))
def printf(text: String, xs: Any*): Unit = Console.print(text.format(xs*))

// views --------------------------------------------------------------

Expand Down
8 changes: 4 additions & 4 deletions library/src/scala/Product.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ transparent trait Product extends Any with Equals {
* @return in the default implementation, an `Iterator[Any]`
*/
def productIterator: Iterator[Any] = new scala.collection.AbstractIterator[Any] {
private[this] var c: Int = 0
private[this] val cmax = productArity
private var c: Int = 0
private val cmax = productArity
def hasNext: Boolean = c < cmax
def next(): Any = { val result = productElement(c); c += 1; result }
}
Expand All @@ -66,8 +66,8 @@ transparent trait Product extends Any with Equals {
/** An iterator over the names of all the elements of this product.
*/
def productElementNames: Iterator[String] = new scala.collection.AbstractIterator[String] {
private[this] var c: Int = 0
private[this] val cmax = productArity
private var c: Int = 0
private val cmax = productArity
def hasNext: Boolean = c < cmax
def next(): String = { val result = productElementName(c); c += 1; result }
}
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/Proxy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait Proxy extends Any {
case null => false
case _ =>
val x = that.asInstanceOf[AnyRef]
(x eq this.asInstanceOf[AnyRef]) || (x eq self.asInstanceOf[AnyRef]) || (x equals self)
(x eq this.asInstanceOf[AnyRef]) || (x eq self.asInstanceOf[AnyRef]) || (x.equals(self))
}
override def toString = "" + self
}
Expand Down
9 changes: 9 additions & 0 deletions library/src/scala/ScalaReflectionException.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package scala

import scala.language.`2.13`

/** An exception that indicates an error during Scala reflection */
case class ScalaReflectionException(msg: String) extends Exception(msg)

object ScalaReflectionException extends scala.runtime.AbstractFunction1[String, ScalaReflectionException]:
override def toString: String = "ScalaReflectionException"
16 changes: 8 additions & 8 deletions library/src/scala/StringContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ object StringContext {
s"""invalid unicode escape at index $index of $str"""
)

private[this] def readUEscape(src: String, startindex: Int): (Char, Int) = {
private def readUEscape(src: String, startindex: Int): (Char, Int) = {
val len = src.length()
def loop(uindex: Int): (Char, Int) = {
def loopCP(dindex: Int, codepoint: Int): (Char, Int) = {
Expand Down Expand Up @@ -362,19 +362,19 @@ object StringContext {
* @return The string with all escape sequences expanded.
*/
def processEscapes(str: String): String =
str indexOf '\\' match {
str.indexOf('\\') match {
case -1 => str
case i => replace(str, i)
}

protected[scala] def processUnicode(str: String): String =
str indexOf "\\u" match {
str.indexOf("\\u") match {
case -1 => str
case i => replaceU(str, i)
}

//replace escapes with given first escape
private[this] def replace(str: String, first: Int): String = {
private def replace(str: String, first: Int): String = {
val len = str.length()
val b = new JLSBuilder
// append replacement starting at index `i`, with `next` backslash
Expand All @@ -399,7 +399,7 @@ object StringContext {
val (ch, advance) = if (c == 'u') readUEscape(str, idx)
else (c, 1)
idx += advance
b append ch
b.append(ch)
loop(idx, str.indexOf('\\', idx))
} else {
if (i < len) b.append(str, i, len)
Expand All @@ -423,7 +423,7 @@ object StringContext {
* Otherwise, the backslash is not taken to introduce an escape and the
* backslash is taken to be literal
*/
private[this] def replaceU(str: String, backslash: Int): String = {
private def replaceU(str: String, backslash: Int): String = {
val len = str.length()
val b = new JLSBuilder

Expand Down Expand Up @@ -458,8 +458,8 @@ object StringContext {
val ai = args.iterator
val bldr = new JLSBuilder(process(pi.next()))
while (ai.hasNext) {
bldr append ai.next()
bldr append process(pi.next())
bldr.append(ai.next())
bldr.append(process(pi.next()))
}
bldr.toString
}
Expand Down
12 changes: 6 additions & 6 deletions library/src/scala/Symbol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ private[scala] abstract class UniquenessCache[K, V] {
import java.util.WeakHashMap
import java.util.concurrent.locks.ReentrantReadWriteLock

private[this] val rwl = new ReentrantReadWriteLock()
private[this] val rlock = rwl.readLock
private[this] val wlock = rwl.writeLock
private[this] val map = new WeakHashMap[K, WeakReference[V]]
private val rwl = new ReentrantReadWriteLock()
private val rlock = rwl.readLock
private val wlock = rwl.writeLock
private val map = new WeakHashMap[K, WeakReference[V]]

protected def valueFromKey(k: K): V
protected def keyFromValue(v: V): Option[K]
Expand All @@ -53,7 +53,7 @@ private[scala] abstract class UniquenessCache[K, V] {
def cached(): V | Null = {
rlock.lock
try {
val reference = map get name
val reference = map.get(name)
if (reference == null) null
else reference.get // will be null if we were gc-ed
}
Expand All @@ -69,7 +69,7 @@ private[scala] abstract class UniquenessCache[K, V] {
// wind up with one String as the key and a different String as
// the name field in the Symbol, which can lead to surprising GC
// behavior and duplicate Symbols. See scala/bug#6706.
map remove name
map.remove(name)
val sym = valueFromKey(name)
map.put(name, new WeakReference(sym))
sym
Expand Down
Loading
Loading