Skip to content

Commit 85d5d70

Browse files
committed
Rename withContext -> inContext
1 parent 9ebde7c commit 85d5d70

File tree

10 files changed

+19
-19
lines changed

10 files changed

+19
-19
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ object Trees {
12361236

12371237
abstract class TreeMap(val cpy: TreeCopier = inst.cpy) { self =>
12381238
def transform(tree: Tree)(using Context): Tree = {
1239-
withContext(
1239+
inContext(
12401240
if tree.source != ctx.source && tree.source.exists
12411241
then ctx.withSource(tree.source)
12421242
else ctx
@@ -1300,7 +1300,7 @@ object Trees {
13001300
case AppliedTypeTree(tpt, args) =>
13011301
cpy.AppliedTypeTree(tree)(transform(tpt), transform(args))
13021302
case LambdaTypeTree(tparams, body) =>
1303-
withContext(localCtx) {
1303+
inContext(localCtx) {
13041304
cpy.LambdaTypeTree(tree)(transformSub(tparams), transform(body))
13051305
}
13061306
case MatchTypeTree(bound, selector, cases) =>
@@ -1318,17 +1318,17 @@ object Trees {
13181318
case EmptyValDef =>
13191319
tree
13201320
case tree @ ValDef(name, tpt, _) =>
1321-
withContext(localCtx) {
1321+
inContext(localCtx) {
13221322
val tpt1 = transform(tpt)
13231323
val rhs1 = transform(tree.rhs)
13241324
cpy.ValDef(tree)(name, tpt1, rhs1)
13251325
}
13261326
case tree @ DefDef(name, tparams, vparamss, tpt, _) =>
1327-
withContext(localCtx) {
1327+
inContext(localCtx) {
13281328
cpy.DefDef(tree)(name, transformSub(tparams), vparamss mapConserve (transformSub(_)), transform(tpt), transform(tree.rhs))
13291329
}
13301330
case tree @ TypeDef(name, rhs) =>
1331-
withContext(localCtx) {
1331+
inContext(localCtx) {
13321332
cpy.TypeDef(tree)(name, transform(rhs))
13331333
}
13341334
case tree @ Template(constr, parents, self, _) if tree.derived.isEmpty =>
@@ -1429,7 +1429,7 @@ object Trees {
14291429
case AppliedTypeTree(tpt, args) =>
14301430
this(this(x, tpt), args)
14311431
case LambdaTypeTree(tparams, body) =>
1432-
withContext(localCtx) {
1432+
inContext(localCtx) {
14331433
this(this(x, tparams), body)
14341434
}
14351435
case MatchTypeTree(bound, selector, cases) =>
@@ -1445,15 +1445,15 @@ object Trees {
14451445
case UnApply(fun, implicits, patterns) =>
14461446
this(this(this(x, fun), implicits), patterns)
14471447
case tree @ ValDef(_, tpt, _) =>
1448-
withContext(localCtx) {
1448+
inContext(localCtx) {
14491449
this(this(x, tpt), tree.rhs)
14501450
}
14511451
case tree @ DefDef(_, tparams, vparamss, tpt, _) =>
1452-
withContext(localCtx) {
1452+
inContext(localCtx) {
14531453
this(this(vparamss.foldLeft(this(x, tparams))(apply), tpt), tree.rhs)
14541454
}
14551455
case TypeDef(_, rhs) =>
1456-
withContext(localCtx) {
1456+
inContext(localCtx) {
14571457
this(x, rhs)
14581458
}
14591459
case tree @ Template(constr, parents, self, _) if tree.derived.isEmpty =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ object PathResolver {
142142
println(Environment)
143143
println(Defaults)
144144
}
145-
else withContext(ContextBase().initialCtx) {
145+
else inContext(ContextBase().initialCtx) {
146146
val ArgsSummary(sstate, rest, errors, warnings) =
147147
ctx.settings.processArguments(args.toList, true)
148148
errors.foreach(println)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object Contexts {
5353
def ctx(using ctx: Context): Context = ctx
5454

5555
/** Run `op` with given context */
56-
inline def withContext[T](c: Context)(inline op: Context ?=> T): T =
56+
inline def inContext[T](c: Context)(inline op: Context ?=> T): T =
5757
op(using c)
5858

5959
/** A context is passed basically everywhere in dotc.

compiler/src/dotty/tools/dotc/transform/ContextFunctionResults.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ object ContextFunctionResults:
100100
* parameter count.
101101
*/
102102
def contextFunctionResultTypeCovering(meth: Symbol, paramCount: Int)(using Context) =
103-
withContext(ctx.withPhase(ctx.erasurePhase)) {
103+
inContext(ctx.withPhase(ctx.erasurePhase)) {
104104
// Recursive instances return pairs of context types and the
105105
// # of parameters they represent.
106106
def missingCR(tp: Type, crCount: Int): (Type, Int) =

compiler/src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ object Erasure {
454454
else implType.derivedLambdaType(resType = samResultType)
455455
val bridge = ctx.newSymbol(ctx.owner, AdaptedClosureName(meth.symbol.name.asTermName), Flags.Synthetic | Flags.Method, bridgeType)
456456
Closure(bridge, bridgeParamss =>
457-
withContext(ctx.withOwner(bridge)) {
457+
inContext(ctx.withOwner(bridge)) {
458458
val List(bridgeParams) = bridgeParamss
459459
assert(ctx.typer.isInstanceOf[Erasure.Typer])
460460
val rhs = Apply(meth, bridgeParams.lazyZip(implParamTypes).map(ctx.typer.adapt(_, _)))

compiler/src/dotty/tools/dotc/transform/Splicer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ object Splicer {
4343
val interpreter = new Interpreter(pos, classLoader)
4444
val macroOwner = ctx.newSymbol(ctx.owner, nme.MACROkw, Macro | Synthetic, defn.AnyType, coord = tree.span)
4545
try
46-
withContext(ctx.withOwner(macroOwner)) {
46+
inContext(ctx.withOwner(macroOwner)) {
4747
// Some parts of the macro are evaluated during the unpickling performed in quotedExprToTree
4848
val interpretedExpr = interpreter.interpret[scala.quoted.QuoteContext => scala.quoted.Expr[Any]](tree)
4949
val interpretedTree = interpretedExpr.fold(tree)(macroClosure => PickledQuotes.quotedExprToTree(macroClosure(QuoteContext())))

compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ trait ImportSuggestions:
149149
*/
150150
def shallowTest(ref: TermRef): Boolean =
151151
System.currentTimeMillis < deadLine
152-
&& withContext(ctx.fresh.setExploreTyperState()) {
152+
&& inContext(ctx.fresh.setExploreTyperState()) {
153153
def test(pt: Type): Boolean = pt match
154154
case ViewProto(argType, OrType(rt1, rt2)) =>
155155
// Union types do not constrain results, since comparison with a union

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Constants._
1313
import StagingContext._
1414
import StdNames._
1515
import transform.SymUtils._
16-
import Contexts.{Context, withContext, ctx}
16+
import Contexts.{Context, inContext, ctx}
1717
import Names.{Name, TermName}
1818
import NameKinds.{InlineAccessorName, InlineBinderName, InlineScrutineeName, BodyRetainerName}
1919
import ProtoTypes.selectionProto
@@ -1341,7 +1341,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
13411341
ctx.echo(i"suspension triggered by macro call to ${sym.showLocated} in ${sym.associatedFile}", call.sourcePos)
13421342
ctx.compilationUnit.suspend() // this throws a SuspendException
13431343

1344-
val evaluatedSplice = withContext(tastyreflect.MacroExpansion.context(inlinedFrom)) {
1344+
val evaluatedSplice = inContext(tastyreflect.MacroExpansion.context(inlinedFrom)) {
13451345
Splicer.splice(body, inlinedFrom.sourcePos, MacroClassLoader.fromContext)
13461346
}
13471347
val inlinedNormailizer = new TreeMap {

compiler/test/dotty/tools/AnnotationsTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AnnotationsTest:
1919
"public @interface Annot { String[] values() default {}; }"),
2020
VirtualJavaSource("A.java",
2121
"@Annot(values = {}) public class A {}")) { javaOutputDir =>
22-
withCompilerContext(javaOutputDir.toString + File.pathSeparator + TestConfiguration.basicClasspath) {
22+
inCompilerContext(javaOutputDir.toString + File.pathSeparator + TestConfiguration.basicClasspath) {
2323
(using ctx: Context) =>
2424
val defn = ctx.definitions
2525
val cls = ctx.requiredClass("A")

compiler/test/dotty/tools/compilerSupport.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import dotc.core.Comments.{ContextDoc, ContextDocstrings}
1313
/** Initialize a compiler context with the given classpath and
1414
* pass it to `op`.
1515
*/
16-
def withCompilerContext[T](classpath: String)(op: Context ?=> T): T =
16+
def inCompilerContext[T](classpath: String)(op: Context ?=> T): T =
1717
val compiler = Compiler()
1818
val run = compiler.newRun(initCtx(classpath))
1919
run.compileUnits(Nil) // Initialize phases

0 commit comments

Comments
 (0)