Skip to content

Commit 0bf296e

Browse files
Merge pull request #7411 from dotty-staging/drop-local
Infer private[this]
2 parents bc07eec + 3843a27 commit 0bf296e

File tree

125 files changed

+562
-474
lines changed

Some content is hidden

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

125 files changed

+562
-474
lines changed

compiler/src/dotty/tools/backend/WorklistAlgorithm.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import scala.collection.mutable
1919
trait WorklistAlgorithm {
2020
type Elem
2121
class WList {
22-
private[this] var list: List[Elem] = Nil
22+
private var list: List[Elem] = Nil
2323
def isEmpty = list.isEmpty
2424
def nonEmpty = !isEmpty
2525
def push(e: Elem): Unit = { list = e :: list }

compiler/src/dotty/tools/backend/jvm/CoreBTypes.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ final class CoreBTypesProxy[BTFS <: BTypesFromSymbols[_ <: BackendInterface]](va
203203
import bTypes._
204204
import bTypes.int._
205205

206-
private[this] var _coreBTypes: CoreBTypes[bTypes.type] = _
206+
private var _coreBTypes: CoreBTypes[bTypes.type] = _
207207
def setBTypes(coreBTypes: CoreBTypes[BTFS]): Unit = {
208208
_coreBTypes = coreBTypes.asInstanceOf[CoreBTypes[bTypes.type]]
209209
}

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class GenBCode extends Phase {
3939
superCallsMap.update(sym, old + calls)
4040
}
4141

42-
private[this] var myOutput: AbstractFile = _
42+
private var myOutput: AbstractFile = _
4343

4444
private def outputDir(implicit ctx: Context): AbstractFile = {
4545
if (myOutput eq null)
@@ -68,14 +68,14 @@ object GenBCode {
6868

6969
class GenBCodePipeline(val int: DottyBackendInterface)(implicit val ctx: Context) extends BCodeSyncAndTry {
7070

71-
private[this] var tree: Tree = _
71+
private var tree: Tree = _
7272

73-
private[this] val sourceFile: SourceFile = ctx.compilationUnit.source
73+
private val sourceFile: SourceFile = ctx.compilationUnit.source
7474

7575
/** Convert a `dotty.tools.io.AbstractFile` into a
7676
* `dotty.tools.dotc.interfaces.AbstractFile`.
7777
*/
78-
private[this] def convertAbstractFile(absfile: dotty.tools.io.AbstractFile): interfaces.AbstractFile =
78+
private def convertAbstractFile(absfile: dotty.tools.io.AbstractFile): interfaces.AbstractFile =
7979
new interfaces.AbstractFile {
8080
override def name = absfile.name
8181
override def path = absfile.path
@@ -86,8 +86,8 @@ class GenBCodePipeline(val int: DottyBackendInterface)(implicit val ctx: Context
8686

8787
// class BCodePhase() {
8888

89-
private[this] var bytecodeWriter : BytecodeWriter = null
90-
private[this] var mirrorCodeGen : JMirrorBuilder = null
89+
private var bytecodeWriter : BytecodeWriter = null
90+
private var mirrorCodeGen : JMirrorBuilder = null
9191

9292
/* ---------------- q1 ---------------- */
9393

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class JSCodeGen()(implicit ctx: Context) {
8282
/* See genSuperCall()
8383
* TODO Can we avoid this unscoped var?
8484
*/
85-
private[this] var isModuleInitialized: Boolean = false
85+
private var isModuleInitialized: Boolean = false
8686

8787
private def currentClassType = encodeClassType(currentClassSym)
8888

compiler/src/dotty/tools/backend/sjs/JSDefinitions.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ final class JSDefinitions()(implicit ctx: Context) {
173173
@threadUnsafe lazy val Reflect_registerInstantiatableClassR = ReflectModule.requiredMethodRef("registerInstantiatableClass")
174174
def Reflect_registerInstantiatableClass(implicit ctx: Context) = Reflect_registerInstantiatableClassR.symbol
175175

176-
private[this] var allRefClassesCache: Set[Symbol] = _
176+
private var allRefClassesCache: Set[Symbol] = _
177177
def allRefClasses(implicit ctx: Context): Set[Symbol] = {
178178
if (allRefClassesCache == null) {
179179
val baseNames = List("Object", "Boolean", "Character", "Byte", "Short",

compiler/src/dotty/tools/backend/sjs/JSPositions.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ class JSPositions()(implicit ctx: Context) {
3535
implicit def implicitSourcePos2irPos(implicit sourcePos: SourcePosition): ir.Position =
3636
sourceAndSpan2irPos(sourcePos.source, sourcePos.span)
3737

38-
private[this] object span2irPosCache { // scalastyle:ignore
38+
private object span2irPosCache { // scalastyle:ignore
3939
import dotty.tools.dotc.util._
4040

41-
private[this] var lastDotcSource: SourceFile = null
42-
private[this] var lastIRSource: ir.Position.SourceFile = null
41+
private var lastDotcSource: SourceFile = null
42+
private var lastIRSource: ir.Position.SourceFile = null
4343

4444
def toIRSource(dotcSource: SourceFile): ir.Position.SourceFile = {
4545
if (dotcSource != lastDotcSource) {
@@ -49,7 +49,7 @@ class JSPositions()(implicit ctx: Context) {
4949
lastIRSource
5050
}
5151

52-
private[this] def convert(dotcSource: SourceFile): ir.Position.SourceFile = {
52+
private def convert(dotcSource: SourceFile): ir.Position.SourceFile = {
5353
dotcSource.file.file match {
5454
case null =>
5555
new java.net.URI(

compiler/src/dotty/tools/dotc/Bench.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import scala.annotation.internal.sharable
1212
*/
1313
object Bench extends Driver {
1414

15-
@sharable private[this] var numRuns = 1
15+
@sharable private var numRuns = 1
1616

1717
private def ntimes(n: Int)(op: => Reporter): Reporter =
1818
(0 until n).foldLeft(emptyReporter)((_, _) => op)

compiler/src/dotty/tools/dotc/Run.scala

+9-9
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
3939
* for type checking.
4040
* imports For each element of RootImports, an import context
4141
*/
42-
protected[this] def rootContext(implicit ctx: Context): Context = {
42+
protected def rootContext(implicit ctx: Context): Context = {
4343
ctx.initialize()(ctx)
4444
ctx.base.setPhasePlan(comp.phases)
4545
val rootScope = new MutableScope
@@ -59,19 +59,19 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
5959
defn.RootImportFns.foldLeft(start.setRun(this))(addImport)
6060
}
6161

62-
private[this] var compiling = false
62+
private var compiling = false
6363

64-
private[this] var myCtx = rootContext(ictx)
64+
private var myCtx = rootContext(ictx)
6565

6666
/** The context created for this run */
6767
def runContext: Context = myCtx
6868

69-
protected[this] implicit def ctx: Context = myCtx
69+
protected implicit def ctx: Context = myCtx
7070
assert(ctx.runId <= Periods.MaxPossibleRunId)
7171

72-
private[this] var myUnits: List[CompilationUnit] = _
73-
private[this] var myUnitsCached: List[CompilationUnit] = _
74-
private[this] var myFiles: Set[AbstractFile] = _
72+
private var myUnits: List[CompilationUnit] = _
73+
private var myUnitsCached: List[CompilationUnit] = _
74+
private var myFiles: Set[AbstractFile] = _
7575

7676
/** The compilation units currently being compiled, this may return different
7777
* results over time.
@@ -94,10 +94,10 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
9494
}
9595

9696
/** The source files of all late entered symbols, as a set */
97-
private[this] var lateFiles = mutable.Set[AbstractFile]()
97+
private var lateFiles = mutable.Set[AbstractFile]()
9898

9999
/** Actions that need to be performed at the end of the current compilation run */
100-
private[this] var finalizeActions = mutable.ListBuffer[() => Unit]()
100+
private var finalizeActions = mutable.ListBuffer[() => Unit]()
101101

102102
def compile(fileNames: List[String]): Unit = try {
103103
val sources = fileNames.map(ctx.getSource(_))

compiler/src/dotty/tools/dotc/ast/Desugar.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,14 @@ object desugar {
150150
* ==>
151151
* def x: Int = expr
152152
* def x_=($1: <TypeTree()>): Unit = ()
153+
*
154+
* Generate the setter only for non-private class members and all trait members.
153155
*/
154156
def valDef(vdef0: ValDef)(implicit ctx: Context): Tree = {
155157
val vdef @ ValDef(name, tpt, rhs) = transformQuotedPatternName(vdef0)
156158
val mods = vdef.mods
157159
val setterNeeded =
158-
mods.is(Mutable) && ctx.owner.isClass && (!mods.isAllOf(PrivateLocal) || ctx.owner.is(Trait))
160+
mods.is(Mutable) && ctx.owner.isClass && (!mods.is(Private) || ctx.owner.is(Trait))
159161
if (setterNeeded) {
160162
// TODO: copy of vdef as getter needed?
161163
// val getter = ValDef(mods, name, tpt, rhs) withPos vdef.pos?

compiler/src/dotty/tools/dotc/ast/PluggableTransformers.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ object PluggableTransformers {
99
abstract class PluggableTransformer[T] extends TreeTransformer[T, Context] {
1010
type PluginOp[-N <: Tree[T]] = N => Tree[T]
1111
12-
private[this] var _ctx: Context = _
13-
private[this] var _oldTree: Tree[T] = _
12+
private var _ctx: Context = _
13+
private var _oldTree: Tree[T] = _
1414
1515
protected implicit def ctx: Context = _ctx
1616
protected def oldTree: Tree[T] = _oldTree
@@ -44,7 +44,7 @@ object PluggableTransformers {
4444
4545
val EmptyPlugin = new Plugins
4646
47-
private[this] var _plugins: Plugins = EmptyPlugin
47+
private var _plugins: Plugins = EmptyPlugin
4848
4949
override def plugins: Plugins = _plugins
5050

compiler/src/dotty/tools/dotc/ast/Positioned.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import java.io.{ PrintWriter }
1818
*/
1919
abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Product with Cloneable {
2020

21-
private[this] var myUniqueId: Int = _
22-
private[this] var mySpan: Span = _
21+
private var myUniqueId: Int = _
22+
private var mySpan: Span = _
2323

2424
/** A unique identifier. Among other things, used for determining the source file
2525
* component of the position.

compiler/src/dotty/tools/dotc/ast/Trees.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ object Trees {
309309
trait DefTree[-T >: Untyped] extends DenotingTree[T] {
310310
type ThisTree[-T >: Untyped] <: DefTree[T]
311311

312-
private[this] var myMods: untpd.Modifiers = null
312+
private var myMods: untpd.Modifiers = null
313313

314314
private[dotc] def rawMods: untpd.Modifiers =
315315
if (myMods == null) untpd.EmptyModifiers else myMods

compiler/src/dotty/tools/dotc/ast/tpd.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
10801080
trait TreeProvider {
10811081
protected def computeRootTrees(implicit ctx: Context): List[Tree]
10821082

1083-
private[this] var myTrees: List[Tree] = null
1083+
private var myTrees: List[Tree] = null
10841084

10851085
/** Get trees defined by this provider. Cache them if -Yretain-trees is set. */
10861086
def rootTrees(implicit ctx: Context): List[Tree] =

compiler/src/dotty/tools/dotc/ast/untpd.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
276276
*/
277277
abstract class DerivedTypeTree(implicit @constructorOnly src: SourceFile) extends TypeTree {
278278

279-
private[this] var myWatched: Tree = EmptyTree
279+
private var myWatched: Tree = EmptyTree
280280

281281
/** The watched tree; used only for printing */
282282
def watched: Tree = myWatched

compiler/src/dotty/tools/dotc/classpath/AggregateClassPath.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ case class AggregateClassPath(aggregates: Seq[ClassPath]) extends ClassPath {
2323
case Some(x) => x
2424
}
2525
}
26-
private[this] val packageIndex: collection.mutable.Map[String, Seq[ClassPath]] = collection.mutable.Map()
26+
private val packageIndex: collection.mutable.Map[String, Seq[ClassPath]] = collection.mutable.Map()
2727
private def aggregatesForPackage(pkg: String): Seq[ClassPath] = packageIndex.synchronized {
2828
packageIndex.getOrElseUpdate(pkg, aggregates.filter(_.hasPackage(pkg)))
2929
}

compiler/src/dotty/tools/dotc/config/JavaPlatform.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import transform.ExplicitOuter, transform.SymUtils._
1111

1212
class JavaPlatform extends Platform {
1313

14-
private[this] var currentClassPath: Option[ClassPath] = None
14+
private var currentClassPath: Option[ClassPath] = None
1515

1616
def classPath(implicit ctx: Context): ClassPath = {
1717
if (currentClassPath.isEmpty)

compiler/src/dotty/tools/dotc/config/OutputDirs.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import io._
1212
*/
1313
class OutputDirs {
1414
/** Pairs of source directory - destination directory. */
15-
private[this] var outputDirs: List[(AbstractFile, AbstractFile)] = Nil
15+
private var outputDirs: List[(AbstractFile, AbstractFile)] = Nil
1616

1717
/** If this is not None, the output location where all
1818
* classes should go.
1919
*/
20-
private[this] var singleOutDir: Option[AbstractFile] = None
20+
private var singleOutDir: Option[AbstractFile] = None
2121

2222
/** Add a destination directory for sources found under srcdir.
2323
* Both directories should exits.

compiler/src/dotty/tools/dotc/config/Settings.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ object Settings {
2525
val OutputTag: ClassTag[AbstractFile] = ClassTag(classOf[AbstractFile])
2626

2727
class SettingsState(initialValues: Seq[Any]) {
28-
private[this] var values = ArrayBuffer(initialValues: _*)
29-
private[this] var _wasRead: Boolean = false
28+
private var values = ArrayBuffer(initialValues: _*)
29+
private var _wasRead: Boolean = false
3030

3131
override def toString: String = s"SettingsState(values: ${values.toList})"
3232

@@ -68,7 +68,7 @@ object Settings {
6868
depends: List[(Setting[?], Any)] = Nil,
6969
propertyClass: Option[Class[?]] = None)(private[Settings] val idx: Int) {
7070

71-
private[this] var changed: Boolean = false
71+
private var changed: Boolean = false
7272

7373
def withAbbreviation(abbrv: String): Setting[T] =
7474
copy(aliases = aliases :+ abbrv)(idx)
@@ -193,7 +193,7 @@ object Settings {
193193

194194
class SettingGroup {
195195

196-
private[this] val _allSettings = new ArrayBuffer[Setting[?]]
196+
private val _allSettings = new ArrayBuffer[Setting[?]]
197197
def allSettings: Seq[Setting[?]] = _allSettings.toSeq
198198

199199
def defaultState: SettingsState = new SettingsState(allSettings map (_.default))

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ object Annotations {
5151
override def symbol(implicit ctx: Context): Symbol
5252
def complete(implicit ctx: Context): Tree
5353

54-
private[this] var myTree: Tree = null
54+
private var myTree: Tree = null
5555
def tree(implicit ctx: Context): Tree = {
5656
if (myTree == null) myTree = complete(ctx)
5757
myTree
@@ -78,8 +78,8 @@ object Annotations {
7878

7979
case class LazyBodyAnnotation(private var bodyExpr: Context => Tree) extends BodyAnnotation {
8080
// TODO: Make `bodyExpr` an IFT once #6865 os in bootstrap
81-
private[this] var evaluated = false
82-
private[this] var myBody: Tree = _
81+
private var evaluated = false
82+
private var myBody: Tree = _
8383
def tree(implicit ctx: Context): Tree = {
8484
if (evaluated) assert(myBody != null)
8585
else {
@@ -127,7 +127,7 @@ object Annotations {
127127
/** Create an annotation where the symbol and the tree are computed lazily. */
128128
def deferredSymAndTree(symf: (given Context) => Symbol)(treeFn: (given Context) => Tree)(implicit ctx: Context): Annotation =
129129
new LazyAnnotation {
130-
private[this] var mySym: Symbol = _
130+
private var mySym: Symbol = _
131131

132132
override def symbol(implicit ctx: Context): Symbol = {
133133
if (mySym == null || mySym.defRunId != ctx.runId) {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object Comments {
2424
*/
2525
class ContextDocstrings {
2626

27-
private[this] val _docstrings: MutableSymbolMap[Comment] = newMutableSymbolMap
27+
private val _docstrings: MutableSymbolMap[Comment] = newMutableSymbolMap
2828

2929
val templateExpander: CommentExpander = new CommentExpander
3030

@@ -93,7 +93,7 @@ object Comments {
9393
* def foo: A = ???
9494
* }}}
9595
*/
96-
private[this] def decomposeUseCase(body: String, span: Span, start: Int, end: Int)(implicit ctx: Context): UseCase = {
96+
private def decomposeUseCase(body: String, span: Span, start: Int, end: Int)(implicit ctx: Context): UseCase = {
9797
def subPos(start: Int, end: Int) =
9898
if (span == NoSpan) NoSpan
9999
else {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait ConstraintHandling[AbstractContext] {
3434
protected def constraint: Constraint
3535
protected def constraint_=(c: Constraint): Unit
3636

37-
private[this] var addConstraintInvocations = 0
37+
private var addConstraintInvocations = 0
3838

3939
/** If the constraint is frozen we cannot add new bounds to the constraint. */
4040
protected var frozenConstraint: Boolean = false

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import Contexts._
55
import config.Printers.{default, typr}
66

77
trait ConstraintRunInfo { self: Run =>
8-
private[this] var maxSize = 0
9-
private[this] var maxConstraint: Constraint = _
8+
private var maxSize = 0
9+
private var maxConstraint: Constraint = _
1010
def recordConstraintSize(c: Constraint, size: Int): Unit =
1111
if (size > maxSize) {
1212
maxSize = size

0 commit comments

Comments
 (0)