Skip to content

Commit 444a189

Browse files
committed
Replace private var by private[this] var where possible
1 parent 7ca9ac3 commit 444a189

File tree

76 files changed

+179
-179
lines changed

Some content is hidden

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

76 files changed

+179
-179
lines changed

compiler/sjs/backend/sjs/JSCodeGen.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class JSCodeGen()(implicit ctx: Context) {
7272
/* See genSuperCall()
7373
* TODO Can we avoid this unscoped var?
7474
*/
75-
private var isModuleInitialized: Boolean = false
75+
private[this] var isModuleInitialized: Boolean = false
7676

7777
private def currentClassType = encodeClassType(currentClassSym)
7878

compiler/sjs/backend/sjs/ScopedVar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import language.implicitConversions
55
class ScopedVar[A](init: A) {
66
import ScopedVar.Assignment
77

8-
private var value = init
8+
private[this] var value = init
99

1010
def this()(implicit ev: Null <:< A) = this(ev(null))
1111

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
7777

7878
// class BCodePhase() {
7979

80-
private var bytecodeWriter : BytecodeWriter = null
81-
private var mirrorCodeGen : JMirrorBuilder = null
82-
private var beanInfoCodeGen : JBeanInfoBuilder = null
80+
private[this] var bytecodeWriter : BytecodeWriter = null
81+
private[this] var mirrorCodeGen : JMirrorBuilder = null
82+
private[this] var beanInfoCodeGen : JBeanInfoBuilder = null
8383

8484
/* ---------------- q1 ---------------- */
8585

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import reporting.Reporter
1010
*/
1111
object Bench extends Driver {
1212

13-
@sharable private var numRuns = 1
13+
@sharable private[this] var numRuns = 1
1414

1515
private def ntimes(n: Int)(op: => Reporter): Reporter =
1616
(emptyReporter /: (0 until n)) ((_, _) => op)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object Trees {
3333
/** Property key for trees with documentation strings attached */
3434
val DocComment = new Property.Key[Comment]
3535

36-
@sharable private var nextId = 0 // for debugging
36+
@sharable private[this] var nextId = 0 // for debugging
3737

3838
type LazyTree = AnyRef /* really: Tree | Lazy[Tree] */
3939
type LazyTreeList = AnyRef /* really: List[Tree] | Lazy[List[Tree]] */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
209209
*/
210210
abstract class DerivedTypeTree extends TypeTree {
211211

212-
private var myWatched: Tree = EmptyTree
212+
private[this] var myWatched: Tree = EmptyTree
213213

214214
/** The watched tree; used only for printing */
215215
def watched: Tree = myWatched

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

Lines changed: 1 addition & 1 deletion
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 var currentClassPath: Option[ClassPath] = None
14+
private[this] 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

Lines changed: 2 additions & 2 deletions
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 var outputDirs: List[(AbstractFile, AbstractFile)] = Nil
15+
private[this] 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 var singleOutDir: Option[AbstractFile] = None
20+
private[this] 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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ object Settings {
2525
val DirectoryTag = ClassTag(classOf[Directory])
2626

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

3131
override def toString = 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 var changed: Boolean = false
71+
private[this] var changed: Boolean = false
7272

7373
def withAbbreviation(abbrv: String): Setting[T] =
7474
copy(aliases = aliases :+ abbrv)(idx)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object Annotations {
3838
override def symbol(implicit ctx: Context): Symbol
3939
def complete(implicit ctx: Context): Tree
4040

41-
private var myTree: Tree = null
41+
private[this] var myTree: Tree = null
4242
def tree(implicit ctx: Context) = {
4343
if (myTree == null) myTree = complete(ctx)
4444
myTree
@@ -62,8 +62,8 @@ object Annotations {
6262
}
6363

6464
case class LazyBodyAnnotation(private var bodyExpr: Context => Tree) extends BodyAnnotation {
65-
private var evaluated = false
66-
private var myBody: Tree = _
65+
private[this] var evaluated = false
66+
private[this] var myBody: Tree = _
6767
def tree(implicit ctx: Context) = {
6868
if (evaluated) assert(myBody != null)
6969
else {

0 commit comments

Comments
 (0)