Skip to content

Commit b270f20

Browse files
committed
Omit redundant (using ctx)
1 parent 4830522 commit b270f20

22 files changed

+78
-69
lines changed

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ class GenBCode extends Phase {
4646
myOutput
4747
}
4848

49-
def run(using Context): Unit = {
50-
new GenBCodePipeline(new DottyBackendInterface(
51-
outputDir, superCallsMap.toMap)(using ctx))(using ctx).run(ctx.compilationUnit.tpdTree)
52-
}
49+
def run(using Context): Unit =
50+
new GenBCodePipeline(
51+
new DottyBackendInterface(
52+
outputDir, superCallsMap.toMap
53+
)
54+
).run(ctx.compilationUnit.tpdTree)
55+
5356

5457
override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] = {
5558
try super.runOn(units)

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dotty.tools
22
package dotc
33

4-
import core.Contexts.{Context, ctx}
4+
import core.Contexts.{Context, ctx, inContext}
55
import reporting.Reporter
66
import java.io.EOFException
77
import scala.annotation.tailrec
@@ -41,7 +41,7 @@ class Resident extends Driver {
4141
final override def process(args: Array[String], rootCtx: Context): Reporter = {
4242
@tailrec def loop(args: Array[String], prevCtx: Context): Reporter = {
4343
var (fileNames, ctx) = setup(args, prevCtx)
44-
doCompile(residentCompiler, fileNames)(using ctx)
44+
inContext(ctx){doCompile(residentCompiler, fileNames)}
4545
var nextCtx = ctx
4646
var line = getLine()
4747
while (line == reset) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ class Definitions {
10121012
else if (isErased)
10131013
ctx.requiredClass("scala.ErasedFunction" + n.toString)
10141014
else if (n <= MaxImplementedFunctionArity)
1015-
FunctionClassPerRun()(using ctx)(n)
1015+
FunctionClassPerRun()(n)
10161016
else
10171017
ctx.requiredClass("scala.Function" + n.toString)
10181018

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ object SymbolLoaders {
285285

286286
enterFlatClasses = Some { ctx =>
287287
enterFlatClasses = None
288-
enterClasses(root, packageName, flat = true)(using ctx)
288+
inContext(ctx){enterClasses(root, packageName, flat = true)}
289289
}
290290
enterClasses(root, packageName, flat = false)
291291
if (!root.isEmptyPackage)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class TyperState(private val previous: TyperState /* | Null */) {
113113
testReporter.inUse = true
114114
testReporter
115115
}
116-
try op(using ctx)
116+
try op
117117
finally {
118118
testReporter.inUse = false
119119
resetConstraintTo(savedConstraint)

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -964,8 +964,9 @@ class TreeUnpickler(reader: TastyReader,
964964
readImport()
965965
case PACKAGE =>
966966
val start = currentAddr
967-
processPackage { (pid, end) => implicit ctx =>
968-
setSpan(start, PackageDef(pid, readIndexedStats(exprOwner, end)(using ctx)))
967+
processPackage { (pid, end) => ctx =>
968+
given Context = ctx
969+
setSpan(start, PackageDef(pid, readIndexedStats(exprOwner, end)))
969970
}
970971
case _ =>
971972
readTerm()(using ctx.withOwner(exprOwner))
@@ -1054,7 +1055,7 @@ class TreeUnpickler(reader: TastyReader,
10541055
ConstFold(untpd.Select(qual, name).withType(tpe))
10551056

10561057
def completeSelect(name: Name, sig: Signature): Select =
1057-
val qual = readTerm()(using ctx)
1058+
val qual = readTerm()
10581059
val denot = accessibleDenot(qual.tpe.widenIfUnstable, name, sig)
10591060
makeSelect(qual, name, denot)
10601061

compiler/src/dotty/tools/dotc/interactive/Interactive.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ object Interactive {
269269
case first :: _ if first eq stat =>
270270
ctx.exprContext(stat, exprOwner)
271271
case (imp: Import) :: rest =>
272-
contextOfStat(rest, stat, exprOwner, ctx.importContext(imp, imp.symbol(using ctx)))
272+
contextOfStat(rest, stat, exprOwner, ctx.importContext(imp, inContext(ctx){imp.symbol}))
273273
case _ :: rest =>
274274
contextOfStat(rest, stat, exprOwner, ctx)
275275
}

compiler/src/dotty/tools/dotc/reporting/Reporter.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ trait Reporting { thisCtx: Context =>
146146
error(msg.mapMsg("Implementation restriction: " + _), pos)
147147

148148
def incompleteInputError(msg: Message, pos: SourcePosition = NoSourcePosition)(using Context): Unit =
149-
reporter.incomplete(new Error(msg, pos))(using ctx)
149+
reporter.incomplete(new Error(msg, pos))
150150

151151
/** Log msg if settings.log contains the current phase.
152152
* See [[config.CompilerCommand#explainAdvanced]] for the exact meaning of

compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ private class ExtractDependenciesCollector extends tpd.TreeTraverser { thisTreeT
415415
* The tests in sbt `types-in-used-names-a`, `types-in-used-names-b`,
416416
* `as-seen-from-a` and `as-seen-from-b` rely on this.
417417
*/
418-
private abstract class TypeDependencyTraverser(using Context) extends TypeTraverser()(using ctx) {
418+
private abstract class TypeDependencyTraverser(using Context) extends TypeTraverser() {
419419
protected def addDependency(symbol: Symbol): Unit
420420

421421
val seen = new mutable.HashSet[Type]

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CtxLazy[T](expr: Context ?=> T) {
1616
private var forced = false
1717
def apply()(using Context): T = {
1818
if (!forced) {
19-
myValue = expr(using ctx)
19+
myValue = expr
2020
forced = true
2121
}
2222
myValue

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
153153

154154
// val x$lzy = new scala.runtime.LazyInt()
155155
val holderName = LazyLocalName.fresh(xname)
156-
val holderImpl = defn.LazyHolder()(using ctx)(tpe.typeSymbol)
156+
val holderImpl = defn.LazyHolder()(tpe.typeSymbol)
157157
val holderSymbol = ctx.newSymbol(x.symbol.owner, holderName, containerFlags, holderImpl.typeRef, coord = x.span)
158158
val holderTree = ValDef(holderSymbol, New(holderImpl.typeRef, Nil))
159159

0 commit comments

Comments
 (0)