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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 9 additions & 9 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

0 commit comments

Comments
 (0)