Skip to content

Commit 54f5144

Browse files
Address review
1 parent 6b3b9d3 commit 54f5144

20 files changed

+36
-36
lines changed

compiler/src/dotty/tools/dotc/core/TyperState.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class TyperState(previous: TyperState /* | Null */) {
7272
new TyperState(this).setReporter(new StoreReporter(reporter)).setCommittable(isCommittable)
7373

7474
/** The uninstantiated variables */
75-
def uninstVars: Seq[Types.TypeVar] = constraint.uninstVars
75+
def uninstVars: Seq[TypeVar] = constraint.uninstVars
7676

7777
/** The set of uninstantiated type variables which have this state as their owning state */
7878
private[this] var myOwnedVars: TypeVars = SimpleIdentitySet.empty

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,7 +3412,7 @@ object Types {
34123412
abstract case class TermParamRef(binder: TermLambda, paramNum: Int) extends ParamRef with SingletonType {
34133413
type BT = TermLambda
34143414
def kindString: String = "Term"
3415-
def copyBoundType(bt: BT): bt.ParamRefType = bt.paramRefs(paramNum)
3415+
def copyBoundType(bt: BT): Type = bt.paramRefs(paramNum)
34163416
}
34173417

34183418
private final class TermParamRefImpl(binder: TermLambda, paramNum: Int) extends TermParamRef(binder, paramNum)
@@ -3423,7 +3423,7 @@ object Types {
34233423
abstract case class TypeParamRef(binder: TypeLambda, paramNum: Int) extends ParamRef {
34243424
type BT = TypeLambda
34253425
def kindString: String = "Type"
3426-
def copyBoundType(bt: BT): bt.ParamRefType = bt.paramRefs(paramNum)
3426+
def copyBoundType(bt: BT): Type = bt.paramRefs(paramNum)
34273427

34283428
/** Optimized version of occursIn, avoid quadratic blowup when solving
34293429
* constraints over large ground types.
@@ -4875,7 +4875,7 @@ object Types {
48754875

48764876
@sharable var debugTrace: Boolean = false
48774877

4878-
val watchList: List[Names.TypeName] = List[String](
4878+
val watchList: List[TypeName] = List[String](
48794879
) map (_.toTypeName)
48804880

48814881
def isWatched(tp: Type)(implicit ctx: Context): Boolean = tp match {

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class ClassfileParser(
6868
protected var pool: ConstantPool = _ // the classfile's constant pool
6969

7070
protected var currentClassName: SimpleName = _ // JVM name of the current class
71-
protected var classTParams: Map[Name, Symbol] = Map[Name, Symbol]()
71+
protected var classTParams: Map[Name, Symbol] = Map()
7272

7373
private[this] var Scala2UnpicklingMode = Mode.Scala2Unpickling
7474

compiler/src/dotty/tools/dotc/core/tasty/PositionUnpickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ package core
44
package tasty
55

66
import util.Positions._
7-
import collection.mutable
7+
import collection.{mutable, Map}
88
import TastyBuffer.Addr
99

1010
/** Unpickler for tree positions */
1111
class PositionUnpickler(reader: TastyReader) {
1212
import reader._
1313

14-
private[tasty] lazy val positions: mutable.HashMap[Addr, Position] = {
14+
private[tasty] lazy val positions: Map[Addr, Position] = {
1515
val positions = new mutable.HashMap[Addr, Position]
1616
var curIndex = 0
1717
var curStart = 0

compiler/src/dotty/tools/dotc/core/tasty/TastyBuffer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object TastyBuffer {
2222
def relativeTo(base: Addr): Addr = this - base.index - AddrWidth
2323
}
2424

25-
val NoAddr: TastyBuffer.Addr = Addr(-1)
25+
val NoAddr: Addr = Addr(-1)
2626

2727
/** The maximal number of address bytes.
2828
* Since addresses are written as base-128 natural numbers,
@@ -41,7 +41,7 @@ import TastyBuffer._
4141
class TastyBuffer(initialSize: Int) {
4242

4343
/** The current byte array, will be expanded as needed */
44-
var bytes: Array[Byte] = new Array[Byte](initialSize)
44+
var bytes: Array[Byte] = new Array(initialSize)
4545

4646
/** The number of bytes written */
4747
var length: Int = 0
@@ -155,7 +155,7 @@ class TastyBuffer(initialSize: Int) {
155155
}
156156

157157
/** The address (represented as a natural number) at address `at` */
158-
def getAddr(at: Addr): TastyBuffer.Addr = Addr(getNat(at))
158+
def getAddr(at: Addr): Addr = Addr(getNat(at))
159159

160160
/** The smallest address equal to or following `at` which points to a non-zero byte */
161161
final def skipZeroes(at: Addr): Addr =

compiler/src/dotty/tools/dotc/core/tasty/TastyPickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TastyPickler(val rootCls: ClassSymbol) {
1616

1717
val nameBuffer: NameBuffer = new NameBuffer
1818

19-
def newSection(name: String, buf: TastyBuffer): mutable.ArrayBuffer[(NameRef, TastyBuffer)] =
19+
def newSection(name: String, buf: TastyBuffer): Unit =
2020
sections += ((nameBuffer.nameIndex(name.toTermName), buf))
2121

2222
def assembleParts(): Array[Byte] = {

compiler/src/dotty/tools/dotc/core/tasty/TastyReader.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TastyReader(val bytes: Array[Byte], start: Int, end: Int, val base: Int =
2020

2121
private[this] var bp: Int = start
2222

23-
def addr(idx: Int): TastyBuffer.Addr = Addr(idx - base)
23+
def addr(idx: Int): Addr = Addr(idx - base)
2424
def index(addr: Addr): Int = addr.index + base
2525

2626
/** The address of the first byte to read, respectively byte that was read */
@@ -105,10 +105,10 @@ class TastyReader(val bytes: Array[Byte], start: Int, end: Int, val base: Int =
105105
}
106106

107107
/** Read a natural number and return as a NameRef */
108-
def readNameRef(): TastyBuffer.NameRef = NameRef(readNat())
108+
def readNameRef(): NameRef = NameRef(readNat())
109109

110110
/** Read a natural number and return as an address */
111-
def readAddr(): TastyBuffer.Addr = Addr(readNat())
111+
def readAddr(): Addr = Addr(readNat())
112112

113113
/** Read a length number and return the absolute end address implied by it,
114114
* given as <address following length field> + <length-value-read>.

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
243243
}
244244

245245
/** The `decls` scope associated with given symbol */
246-
protected def symScope(sym: Symbol): Scopes.Scope = symScopes.getOrElseUpdate(sym, newScope)
246+
protected def symScope(sym: Symbol): Scope = symScopes.getOrElseUpdate(sym, newScope)
247247

248248
/** Does entry represent an (internal) symbol */
249249
protected def isSymbolEntry(i: Int)(implicit ctx: Context): Boolean = {
@@ -611,7 +611,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
611611
loadTypeParams
612612
}
613613

614-
def rootClassUnpickler(start: Coord, cls: Symbol, module: Symbol, infoRef: Int): ClassUnpickler with SymbolLoaders.SecondCompleter =
614+
def rootClassUnpickler(start: Coord, cls: Symbol, module: Symbol, infoRef: Int): ClassUnpickler =
615615
(new ClassUnpickler(infoRef) with SymbolLoaders.SecondCompleter {
616616
override def startCoord(denot: SymDenotation): Coord = start
617617
}) withDecls symScope(cls) withSourceModule (_ => module)

compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,6 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
265265
}
266266

267267
object InteractiveDriver {
268-
def toUri(source: SourceFile): java.net.URI = Paths.get(source.file.path).toUri
268+
def toUri(source: SourceFile): URI = Paths.get(source.file.path).toUri
269269
}
270270

compiler/src/dotty/tools/dotc/parsing/JavaScanners.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,5 +534,5 @@ object JavaScanners {
534534
nextToken()
535535
}
536536

537-
val ((lastKeywordStart: Int), (kwArray: Array[Int])) = buildKeywordArray(keywords)
537+
private val ((lastKeywordStart: Int), (kwArray: Array[Int])) = buildKeywordArray(keywords)
538538
}

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ object Parsers {
299299
case _ => accept(SEMI)
300300
}
301301

302-
def acceptStatSepUnlessAtEnd(altEnd: Token = EOF): AnyVal =
302+
def acceptStatSepUnlessAtEnd(altEnd: Token = EOF): Unit =
303303
if (!isStatSeqEnd)
304304
in.token match {
305305
case EOF =>

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ object Scanners {
8282

8383
/** A character buffer for literals
8484
*/
85-
val litBuf: mutable.StringBuilder = new StringBuilder
85+
protected val litBuf: mutable.StringBuilder = new StringBuilder
8686

8787
/** append Unicode character to "litBuf" buffer
8888
*/
@@ -194,7 +194,7 @@ object Scanners {
194194
def getDocComment(pos: Int): Option[Comment] = docstringMap.get(pos)
195195

196196
/** A buffer for comments */
197-
val commentBuf: mutable.StringBuilder = new StringBuilder
197+
private[this] val commentBuf: mutable.StringBuilder = new StringBuilder
198198

199199
private def handleMigration(keyword: Token): Token =
200200
if (!isScala2Mode) keyword

compiler/src/dotty/tools/dotc/parsing/xml/MarkupParsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ object MarkupParsers {
5858

5959
def mkAttributes(name: String, other: NamespaceType): AttributesType = xAttributes
6060

61-
val eof: Boolean = false
61+
def eof: Boolean = false
6262

6363
def truncatedError(msg: String): Nothing = throw TruncatedXMLControl
6464
def xHandleError(that: Char, msg: String): Unit =

compiler/src/dotty/tools/dotc/printing/Highlighting.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object Highlighting {
3131
}
3232

3333
case class HighlightBuffer(hl: Highlight)(implicit ctx: Context) {
34-
val buffer: mutable.ListBuffer[String] = new mutable.ListBuffer[String]
34+
private[this] val buffer: mutable.ListBuffer[String] = new mutable.ListBuffer[String]
3535

3636
buffer += hl.show
3737

compiler/src/dotty/tools/dotc/printing/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package object printing {
1919
*
2020
* -Xprint will print `sym.name` instead of `sym.originalName`
2121
*/
22-
val XprintMode: Key[Unit] = new Key[Unit]
22+
val XprintMode: Key[Unit] = new Key
2323

2424
/** @pre `nel` is non-empty list */
2525
private[printing] implicit class ListOps[A](val nel: List[A]) extends AnyVal {

compiler/src/dotty/tools/dotc/profile/Profiler.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dotty.tools.dotc.profile
22

33
import java.io.{FileWriter, PrintWriter}
4-
import java.lang.management.{ManagementFactory, GarbageCollectorMXBean}
4+
import java.lang.management.{ManagementFactory, GarbageCollectorMXBean, RuntimeMXBean, MemoryMXBean, ClassLoadingMXBean, CompilationMXBean}
55
import java.util.concurrent.TimeUnit
66
import java.util.concurrent.atomic.AtomicInteger
77
import javax.management.openmbean.CompositeData
@@ -81,11 +81,11 @@ private [profile] object NoOpProfiler extends Profiler {
8181
}
8282
private [profile] object RealProfiler {
8383
import scala.collection.JavaConverters._
84-
val runtimeMx: management.RuntimeMXBean = ManagementFactory.getRuntimeMXBean
85-
val memoryMx: management.MemoryMXBean = ManagementFactory.getMemoryMXBean
84+
val runtimeMx: RuntimeMXBean = ManagementFactory.getRuntimeMXBean
85+
val memoryMx: MemoryMXBean = ManagementFactory.getMemoryMXBean
8686
val gcMx: List[GarbageCollectorMXBean] = ManagementFactory.getGarbageCollectorMXBeans.asScala.toList
87-
val classLoaderMx: management.ClassLoadingMXBean = ManagementFactory.getClassLoadingMXBean
88-
val compileMx: management.CompilationMXBean = ManagementFactory.getCompilationMXBean
87+
val classLoaderMx: ClassLoadingMXBean = ManagementFactory.getClassLoadingMXBean
88+
val compileMx: CompilationMXBean = ManagementFactory.getCompilationMXBean
8989
val threadMx: ExtendedThreadMxBean = ExtendedThreadMxBean.proxy
9090
if (threadMx.isThreadCpuTimeSupported) threadMx.setThreadCpuTimeEnabled(true)
9191
private val idGen = new AtomicInteger()

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
164164
api.Annotated.of(tp, Array(marker))
165165
private def marker(name: String) =
166166
api.Annotation.of(api.Constant.of(Constants.emptyType, name), Array())
167-
val orMarker: xsbti.api.Annotation = marker("Or")
168-
val byNameMarker: xsbti.api.Annotation = marker("ByName")
169-
val matchMarker: xsbti.api.Annotation = marker("Match")
167+
private val orMarker = marker("Or")
168+
private val byNameMarker = marker("ByName")
169+
private val matchMarker = marker("Match")
170170

171171
/** Extract the API representation of a source file */
172172
def apiSource(tree: Tree): Seq[api.ClassLike] = {

compiler/src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Erasure extends Phase with DenotTransformer {
9090
ref.derivedSingleDenotation(ref.symbol, transformInfo(ref.symbol, ref.symbol.info))
9191
}
9292

93-
val eraser: Erasure.Typer = new Erasure.Typer(this)
93+
private val eraser: Erasure.Typer = new Erasure.Typer(this)
9494

9595
def run(implicit ctx: Context): Unit = {
9696
val unit = ctx.compilationUnit

compiler/src/dotty/tools/dotc/transform/FunctionalInterfaces.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class FunctionalInterfaces extends MiniPhase {
2323

2424
def phaseName: String = FunctionalInterfaces.name
2525

26-
val functionName: TermName = "JFunction".toTermName
27-
val functionPackage: TermName = "scala.compat.java8.".toTermName
26+
private val functionName: TermName = "JFunction".toTermName
27+
private val functionPackage: TermName = "scala.compat.java8.".toTermName
2828

2929
override def transformClosure(tree: Closure)(implicit ctx: Context): Tree = {
3030
val cls = tree.tpe.widen.classSymbol.asClass

compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class HoistSuperArgs extends MiniPhase with IdentityDenotTransformer { thisPhase
5555
* Hoisted superarg methods are collected in `superArgDefs`
5656
*/
5757
class Hoister(cls: Symbol)(implicit ctx: Context) {
58-
val superArgDefs: mutable.ListBuffer[DefDef] = new mutable.ListBuffer[DefDef]
58+
val superArgDefs: mutable.ListBuffer[DefDef] = new mutable.ListBuffer
5959

6060
/** If argument is complex, hoist it out into its own method and refer to the
6161
* method instead.

0 commit comments

Comments
 (0)