Skip to content

Commit ebea9c2

Browse files
committed
Rename curCtx -> ctx
1 parent c7d39fa commit ebea9c2

21 files changed

+93
-81
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools
22
package dotc
33

44
import core._
5-
import Contexts.{Context, curCtx}
5+
import Contexts.{Context, ctx}
66
import SymDenotations.ClassDenotation
77
import Symbols._
88
import util.{FreshNameCreator, SourceFile, NoSource}
@@ -45,10 +45,10 @@ class CompilationUnit protected (val source: SourceFile) {
4545

4646
def suspend()(using Context): Nothing =
4747
if !suspended then
48-
if (curCtx.settings.XprintSuspension.value)
49-
curCtx.echo(i"suspended: $this")
48+
if (ctx.settings.XprintSuspension.value)
49+
ctx.echo(i"suspended: $this")
5050
suspended = true
51-
curCtx.run.suspendedUnits += this
51+
ctx.run.suspendedUnits += this
5252
throw CompilationUnit.SuspendException()
5353

5454
private var myAssignmentSpans: Map[Int, List[Span]] = null

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ object desugar {
980980
case Some(DefDef(name, _, (vparam :: _) :: _, _, _)) =>
981981
s"extension_${name}_${inventTypeName(vparam.tpt)}"
982982
case _ =>
983-
curCtx.error(AnonymousInstanceCannotBeEmpty(impl), impl.sourcePos)
983+
ctx.error(AnonymousInstanceCannotBeEmpty(impl), impl.sourcePos)
984984
nme.ERROR.toString
985985
else
986986
impl.parents.map(inventTypeName(_)).mkString("given_", "_", "")

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ object MainProxies {
4747

4848
def addArgs(call: untpd.Tree, mt: MethodType, idx: Int): untpd.Tree =
4949
if (mt.isImplicitMethod) {
50-
curCtx.error(s"@main method cannot have implicit parameters", pos)
50+
ctx.error(s"@main method cannot have implicit parameters", pos)
5151
call
5252
}
5353
else {
@@ -65,7 +65,7 @@ object MainProxies {
6565
mt.resType match {
6666
case restpe: MethodType =>
6767
if (mt.paramInfos.lastOption.getOrElse(NoType).isRepeatedParam)
68-
curCtx.error(s"varargs parameter of @main method must come last", pos)
68+
ctx.error(s"varargs parameter of @main method must come last", pos)
6969
addArgs(call1, restpe, idx + args.length)
7070
case _ =>
7171
call1
@@ -74,17 +74,17 @@ object MainProxies {
7474

7575
var result: List[TypeDef] = Nil
7676
if (!mainFun.owner.isStaticOwner)
77-
curCtx.error(s"@main method is not statically accessible", pos)
77+
ctx.error(s"@main method is not statically accessible", pos)
7878
else {
7979
var call = ref(mainFun.termRef)
8080
mainFun.info match {
8181
case _: ExprType =>
8282
case mt: MethodType =>
8383
call = addArgs(call, mt, 0)
8484
case _: PolyType =>
85-
curCtx.error(s"@main method cannot have type parameters", pos)
85+
ctx.error(s"@main method cannot have type parameters", pos)
8686
case _ =>
87-
curCtx.error(s"@main can only annotate a method", pos)
87+
ctx.error(s"@main can only annotate a method", pos)
8888
}
8989
val errVar = Ident(nme.error)
9090
val handler = CaseDef(
@@ -99,7 +99,7 @@ object MainProxies {
9999
val mainTempl = Template(emptyConstructor, Nil, Nil, EmptyValDef, mainMeth :: Nil)
100100
val mainCls = TypeDef(mainFun.name.toTypeName, mainTempl)
101101
.withFlags(Final)
102-
if (!curCtx.reporter.hasErrors) result = mainCls.withSpan(mainAnnotSpan) :: Nil
102+
if (!ctx.reporter.hasErrors) result = mainCls.withSpan(mainAnnotSpan) :: Nil
103103
}
104104
result
105105
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
13521352
* Used to make arguments for methods that accept varargs.
13531353
*/
13541354
def repeated(trees: List[Tree], tpt: Tree)(using Context): Tree =
1355-
curCtx.typeAssigner.arrayToRepeated(JavaSeqLiteral(trees, tpt))
1355+
ctx.typeAssigner.arrayToRepeated(JavaSeqLiteral(trees, tpt))
13561356

13571357
/** Create a tree representing a list containing all
13581358
* the elements of the argument list. A "list of tree to
@@ -1370,5 +1370,5 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
13701370

13711371

13721372
protected def FunProto(args: List[Tree], resType: Type)(using Context) =
1373-
ProtoTypes.FunProtoTyped(args, resType)(curCtx.typer, isUsingApply = false)
1373+
ProtoTypes.FunProtoTyped(args, resType)(ctx.typer, isUsingApply = false)
13741374
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
254254
else if compatible(this.flags, flags) then this | flags
255255
else
256256
val what = if flags.isTermFlags then "values" else "types"
257-
curCtx.error(em"${(flags & ModifierFlags).flagsString} $what cannot be ${this.flags.flagsString}", curCtx.source.atSpan(span))
257+
ctx.error(em"${(flags & ModifierFlags).flagsString} $what cannot be ${this.flags.flagsString}", ctx.source.atSpan(span))
258258
Modifiers(flags)
259259

260260
/** Modifiers with given list of Mods. It is checked that
@@ -761,5 +761,5 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
761761
}
762762

763763
protected def FunProto(args: List[Tree], resType: Type)(using Context) =
764-
ProtoTypes.FunProto(args, resType)(curCtx.typer, isUsingApply = false)
764+
ProtoTypes.FunProto(args, resType)(ctx.typer, isUsingApply = false)
765765
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ object Annotations {
5555
private def annotCtx(using Context): Context =
5656
// We should always produce the same annotation tree, no matter when the
5757
// annotation is evaluated. Setting the phase to a pre-transformation phase
58-
// seems to be enough to ensure this (note that after erasure, `curCtx.typer`
58+
// seems to be enough to ensure this (note that after erasure, `ctx.typer`
5959
// will be the Erasure typer, but that doesn't seem to affect the annotation
6060
// trees we create, so we leave it as is)
61-
curCtx.withPhaseNoLater(curCtx.picklerPhase)
61+
ctx.withPhaseNoLater(ctx.picklerPhase)
6262

6363
abstract class LazyAnnotation extends Annotation {
6464
protected var mySym: Symbol | (Context => Symbol)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ object Contexts {
5050
private val initialStore = store8
5151

5252
/** The current context */
53-
def curCtx(using ctx: Context): Context = ctx
53+
def ctx(using ctx: Context): Context = ctx
5454

5555
/** A context is passed basically everywhere in dotc.
5656
* This is convenient but carries the risk of captured contexts in

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Definitions {
3838
import Definitions._
3939

4040
private var initCtx: Context = _
41-
private given ctx[Dummy_so_its_a_def] as Context = initCtx
41+
private given currentContext[Dummy_so_its_a_def] as Context = initCtx
4242

4343
private def newSymbol[N <: Name](owner: Symbol, name: N, flags: FlagSet, info: Type) =
4444
ctx.newSymbol(owner, name, flags | Permanent, info)
@@ -1275,8 +1275,8 @@ class Definitions {
12751275
*/
12761276
object ContextFunctionType:
12771277
def unapply(tp: Type)(using Context): Option[(List[Type], Type, Boolean)] =
1278-
if curCtx.erasedTypes then
1279-
unapply(tp)(using curCtx.withPhase(curCtx.erasurePhase))
1278+
if ctx.erasedTypes then
1279+
unapply(tp)(using ctx.withPhase(ctx.erasurePhase))
12801280
else
12811281
val tp1 = tp.dealias
12821282
if isContextFunctionClass(tp1.typeSymbol) then

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,11 +2432,11 @@ object Types {
24322432
* based tests.
24332433
*/
24342434
def canDropAlias(using Context) =
2435-
if myCanDropAliasPeriod != curCtx.period then
2435+
if myCanDropAliasPeriod != ctx.period then
24362436
myCanDropAlias =
24372437
!symbol.canMatchInheritedSymbols
24382438
|| !prefix.baseClasses.exists(_.info.decls.lookup(name).is(Deferred))
2439-
myCanDropAliasPeriod = curCtx.period
2439+
myCanDropAliasPeriod = ctx.period
24402440
myCanDropAlias
24412441

24422442
override def designator: Designator = myDesignator
@@ -2633,7 +2633,7 @@ object Types {
26332633
* Can be called only as long as the ref is still undefined.
26342634
*/
26352635
def update(tp: Type)(using Context) =
2636-
assert(myRef == null || curCtx.reporter.errorsReported)
2636+
assert(myRef == null || ctx.reporter.errorsReported)
26372637
myRef = tp
26382638
computed = true
26392639
refFn = null
@@ -3012,7 +3012,7 @@ object Types {
30123012
def apply(tp: Type)(using Context) =
30133013
OrType(tp, defn.NullType)
30143014
def unapply(tp: Type)(using Context): Option[Type] =
3015-
if (curCtx.explicitNulls) {
3015+
if (ctx.explicitNulls) {
30163016
val tp1 = tp.stripNull()
30173017
if tp1 ne tp then Some(tp1) else None
30183018
}
@@ -3030,7 +3030,7 @@ object Types {
30303030
def apply(tp: Type)(using Context) =
30313031
OrType(tp, defn.UncheckedNullAliasType)
30323032
def unapply(tp: Type)(using Context): Option[Type] =
3033-
if (curCtx.explicitNulls) {
3033+
if (ctx.explicitNulls) {
30343034
val tp1 = tp.stripUncheckedNull
30353035
if tp1 ne tp then Some(tp1) else None
30363036
}
@@ -4653,10 +4653,10 @@ object Types {
46534653
def apply(m: Message)(using Context): ErrorType =
46544654
val et = new ErrorType:
46554655
def msg(using Context): Message =
4656-
curCtx.base.errorTypeMsg.get(this) match
4656+
ctx.base.errorTypeMsg.get(this) match
46574657
case Some(m) => m
46584658
case None => "error message from previous run no longer available"
4659-
curCtx.base.errorTypeMsg(et) = m
4659+
ctx.base.errorTypeMsg(et) = m
46604660
et
46614661
end ErrorType
46624662

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ object Formatting {
256256
}
257257

258258
private def errorMessageCtx(using Context): Context =
259-
curCtx.property(MessageLimiter) match
260-
case Some(_: ErrorMessageLimiter) => curCtx
261-
case _ => curCtx.fresh.setProperty(MessageLimiter, ErrorMessageLimiter())
259+
ctx.property(MessageLimiter) match
260+
case Some(_: ErrorMessageLimiter) => ctx
261+
case _ => ctx.fresh.setProperty(MessageLimiter, ErrorMessageLimiter())
262262

263263
/** Context with correct printer set for explanations */
264264
private def explainCtx(seen: Seen)(implicit ctx: Context): Context =

0 commit comments

Comments
 (0)