Skip to content

Commit 47bde05

Browse files
committed
Rename ctx values
We would like to distinguish between `ctx` referring to an enclosing parameter and `ctx` referring to a field. This is so that we can at some point drop `ctx` as a parameter name and just use (using Context). The `ctx` would then go to an imported def in `Contexts`. But any other use of `ctx` does does not follow strict nesting discipline can then change meaning, so we should get these out of the way first.
1 parent a0690e1 commit 47bde05

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ object GenBCode {
6969
val name: String = "genBCode"
7070
}
7171

72-
class GenBCodePipeline(val int: DottyBackendInterface)(implicit val ctx: Context) extends BCodeSyncAndTry {
72+
class GenBCodePipeline(val int: DottyBackendInterface)(implicit ctx: Context) extends BCodeSyncAndTry {
7373

7474
private var tree: Tree = _
7575

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

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/* NSC -- new Scala compiler
2-
* Copyright 2005-2012 LAMP/EPFL
3-
* @author Martin Odersky
4-
*/
5-
61
package dotty.tools
72
package backend.jvm
83

@@ -35,7 +30,7 @@ import scala.collection.immutable
3530
*
3631
* Inspired from the `scalac` compiler.
3732
*/
38-
class DottyPrimitives(ctx: Context) {
33+
class DottyPrimitives(ictx: Context) {
3934
import dotty.tools.backend.ScalaPrimitivesOps._
4035

4136
@threadUnsafe private lazy val primitives: immutable.Map[Symbol, Int] = init
@@ -124,7 +119,7 @@ class DottyPrimitives(ctx: Context) {
124119
/** Initialize the primitive map */
125120
private def init: immutable.Map[Symbol, Int] = {
126121

127-
implicit val ctx = this.ctx
122+
given Context = ictx
128123

129124
import Symbols.defn
130125
val primitives = Symbols.newMutableSymbolMap[Int]
@@ -401,14 +396,14 @@ class DottyPrimitives(ctx: Context) {
401396
primitives.toMap
402397
}
403398

404-
def isPrimitive(fun: Tree): Boolean = {
405-
(primitives contains fun.symbol(ctx)) ||
406-
(fun.symbol(ctx) == NoSymbol // the only trees that do not have a symbol assigned are array.{update,select,length,clone}}
407-
&& (fun match {
408-
case Select(_, StdNames.nme.clone_) => false // but array.clone is NOT a primitive op.
409-
case _ => true
410-
}))
411-
}
412-
399+
def isPrimitive(fun: Tree): Boolean =
400+
given Context = ictx
401+
primitives.contains(fun.symbol)
402+
|| (fun.symbol == NoSymbol // the only trees that do not have a symbol assigned are array.{update,select,length,clone}}
403+
&& {
404+
fun match
405+
case Select(_, StdNames.nme.clone_) => false // but array.clone is NOT a primitive op.
406+
case _ => true
407+
})
413408
}
414409

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ class Driver {
6464
protected def sourcesRequired: Boolean = true
6565

6666
def setup(args: Array[String], rootCtx: Context): (List[String], Context) = {
67-
val ctx = rootCtx.fresh
68-
val summary = CompilerCommand.distill(args)(ctx)
69-
ctx.setSettings(summary.sstate)
70-
MacroClassLoader.init(ctx)
71-
Positioned.updateDebugPos(ctx)
67+
val ictx = rootCtx.fresh
68+
val summary = CompilerCommand.distill(args)(ictx)
69+
ictx.setSettings(summary.sstate)
70+
MacroClassLoader.init(ictx)
71+
Positioned.updateDebugPos(ictx)
7272

73-
if (!ctx.settings.YdropComments.value(ctx) || ctx.mode.is(Mode.ReadComments))
74-
ctx.setProperty(ContextDoc, new ContextDocstrings)
73+
if (!ictx.settings.YdropComments.value(ictx) || ictx.mode.is(Mode.ReadComments))
74+
ictx.setProperty(ContextDoc, new ContextDocstrings)
7575

76-
val fileNames = CompilerCommand.checkUsage(summary, sourcesRequired)(ctx)
77-
fromTastySetup(fileNames, ctx)
76+
val fileNames = CompilerCommand.checkUsage(summary, sourcesRequired)(ictx)
77+
fromTastySetup(fileNames, ictx)
7878
}
7979

8080
/** Setup extra classpath and figure out class names for tasty file inputs */

0 commit comments

Comments
 (0)