Skip to content

Commit edb4869

Browse files
committed
Convert other dotc classes (1)
1 parent ce9aa2d commit edb4869

27 files changed

+91
-90
lines changed

compiler/src/dotty/tools/backend/sjs/JUnitBootstrappers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ class JUnitBootstrappers extends MiniPhase {
235235
if timeoutName.toString == "timeout" => Some(timeoutLiteral)
236236
case other => {
237237
val shownName = other match {
238-
case NamedArg(name, _) => name.show(ctx)
239-
case other => other.show(ctx)
238+
case NamedArg(name, _) => name.show(using ctx)
239+
case other => other.show(using ctx)
240240
}
241241
ctx.error(s"$shownName is an unsupported argument for the JUnit @Test annotation in this position", other.sourcePos)
242242
None

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Bench extends Driver {
1717
private def ntimes(n: Int)(op: => Reporter): Reporter =
1818
(0 until n).foldLeft(emptyReporter)((_, _) => op)
1919

20-
override def doCompile(compiler: Compiler, fileNames: List[String])(implicit ctx: Context): Reporter =
20+
override def doCompile(compiler: Compiler, fileNames: List[String])(using Context): Reporter =
2121
ntimes(numRuns) {
2222
val start = System.nanoTime()
2323
val r = super.doCompile(compiler, fileNames)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ object CompilationUnit {
7979
class SuspendException extends Exception
8080

8181
/** Make a compilation unit for top class `clsd` with the contents of the `unpickled` tree */
82-
def apply(clsd: ClassDenotation, unpickled: Tree, forceTrees: Boolean)(implicit ctx: Context): CompilationUnit =
82+
def apply(clsd: ClassDenotation, unpickled: Tree, forceTrees: Boolean)(using Context): CompilationUnit =
8383
apply(new SourceFile(clsd.symbol.associatedFile, Array.empty[Char]), unpickled, forceTrees)
8484

8585
/** Make a compilation unit, given picked bytes and unpickled tree */
86-
def apply(source: SourceFile, unpickled: Tree, forceTrees: Boolean)(implicit ctx: Context): CompilationUnit = {
86+
def apply(source: SourceFile, unpickled: Tree, forceTrees: Boolean)(using Context): CompilationUnit = {
8787
assert(!unpickled.isEmpty, unpickled)
8888
val unit1 = new CompilationUnit(source)
8989
unit1.tpdTree = unpickled
@@ -98,7 +98,7 @@ object CompilationUnit {
9898
/** Create a compilation unit corresponding to `source`.
9999
* If `mustExist` is true, this will fail if `source` does not exist.
100100
*/
101-
def apply(source: SourceFile, mustExist: Boolean = true)(implicit ctx: Context): CompilationUnit = {
101+
def apply(source: SourceFile, mustExist: Boolean = true)(using Context): CompilationUnit = {
102102
val src =
103103
if (!mustExist)
104104
source
@@ -117,7 +117,7 @@ object CompilationUnit {
117117
/** Force the tree to be loaded */
118118
private class Force extends TreeTraverser {
119119
var needsStaging = false
120-
def traverse(tree: Tree)(implicit ctx: Context): Unit = {
120+
def traverse(tree: Tree)(using Context): Unit = {
121121
if (tree.symbol.isQuote)
122122
needsStaging = true
123123
traverseChildren(tree)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ class Compiler {
138138
runId += 1; runId
139139
}
140140

141-
def reset()(implicit ctx: Context): Unit = {
141+
def reset()(using Context): Unit = {
142142
ctx.base.reset()
143143
if (ctx.run != null) ctx.run.reset()
144144
}
145145

146-
def newRun(implicit ctx: Context): Run = {
146+
def newRun(using Context): Run = {
147147
reset()
148148
val rctx =
149149
if ctx.settings.Ysemanticdb.value

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ import fromtasty.{TASTYCompiler, TastyFileUtil}
2525
*/
2626
class Driver {
2727

28-
protected def newCompiler(implicit ctx: Context): Compiler =
28+
protected def newCompiler(using Context): Compiler =
2929
if (ctx.settings.fromTasty.value) new TASTYCompiler
3030
else new Compiler
3131

3232
protected def emptyReporter: Reporter = new StoreReporter(null)
3333

34-
protected def doCompile(compiler: Compiler, fileNames: List[String])(implicit ctx: Context): Reporter =
34+
protected def doCompile(compiler: Compiler, fileNames: List[String])(using Context): Reporter =
3535
if (fileNames.nonEmpty)
3636
try
3737
val run = compiler.newRun
@@ -191,7 +191,7 @@ class Driver {
191191
*/
192192
def process(args: Array[String], rootCtx: Context): Reporter = {
193193
val (fileNames, compileCtx) = setup(args, rootCtx)
194-
doCompile(newCompiler(compileCtx), fileNames)(compileCtx)
194+
doCompile(newCompiler(using compileCtx), fileNames)(using compileCtx)
195195
}
196196

197197
def main(args: Array[String]): Unit = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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)(ctx)
44+
doCompile(residentCompiler, fileNames)(using ctx)
4545
var nextCtx = ctx
4646
var line = getLine()
4747
while (line == reset) {

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
5959
* for type checking.
6060
* imports For each element of RootImports, an import context
6161
*/
62-
protected def rootContext(implicit ctx: Context): Context = {
62+
protected def rootContext(using Context): Context = {
6363
ctx.initialize()
6464
ctx.base.setPhasePlan(comp.phases)
6565
val rootScope = new MutableScope
@@ -80,7 +80,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
8080

8181
private var compiling = false
8282

83-
private var myCtx = rootContext(ictx)
83+
private var myCtx = rootContext(using ictx)
8484

8585
/** The context created for this run */
8686
given runContext[Dummy_so_its_a_def] as Context = myCtx
@@ -152,7 +152,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
152152
compileUnits()(using ctx)
153153
}
154154

155-
private def compileUnits()(implicit ctx: Context) = Stats.maybeMonitored {
155+
private def compileUnits()(using Context) = Stats.maybeMonitored {
156156
if (!ctx.mode.is(Mode.Interactive)) // IDEs might have multi-threaded access, accesses are synchronized
157157
ctx.base.checkSingleThreaded()
158158

@@ -168,7 +168,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
168168
ctx.settings.Yskip.value, ctx.settings.YstopBefore.value, stopAfter, ctx.settings.Ycheck.value)
169169
ctx.base.usePhases(phases)
170170

171-
def runPhases(implicit ctx: Context) = {
171+
def runPhases(using Context) = {
172172
var lastPrintedTree: PrintedTree = NoPrintedTree
173173
val profiler = ctx.profiler
174174

@@ -182,7 +182,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
182182
if (ctx.settings.Xprint.value.containsPhase(phase))
183183
for (unit <- units)
184184
lastPrintedTree =
185-
printTree(lastPrintedTree)(ctx.fresh.setPhase(phase.next).setCompilationUnit(unit))
185+
printTree(lastPrintedTree)(using ctx.fresh.setPhase(phase.next).setCompilationUnit(unit))
186186
ctx.informTime(s"$phase ", start)
187187
Stats.record(s"total trees at end of $phase", ast.Trees.ntrees)
188188
for (unit <- units)
@@ -195,7 +195,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
195195
val runCtx = ctx.fresh
196196
runCtx.setProfiler(Profiler())
197197
ctx.phases.foreach(_.initContext(runCtx))
198-
runPhases(runCtx)
198+
runPhases(using runCtx)
199199
if (!ctx.reporter.hasErrors) Rewrites.writeBack()
200200
while (finalizeActions.nonEmpty) {
201201
val action = finalizeActions.remove(0)
@@ -209,11 +209,11 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
209209
* If `typeCheck = true`, also run typer on the compilation unit, and set
210210
* `rootTreeOrProvider`.
211211
*/
212-
def lateCompile(file: AbstractFile, typeCheck: Boolean)(implicit ctx: Context): Unit =
212+
def lateCompile(file: AbstractFile, typeCheck: Boolean)(using Context): Unit =
213213
if (!files.contains(file) && !lateFiles.contains(file)) {
214214
lateFiles += file
215215
val unit = CompilationUnit(ctx.getSource(file.path))
216-
def process()(implicit ctx: Context) = {
216+
def process()(using Context) = {
217217
unit.untpdTree =
218218
if (unit.isJava) new JavaParser(unit.source).parse()
219219
else new Parser(unit.source).parse()
@@ -226,18 +226,18 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
226226
if (typeCheck)
227227
if (compiling) finalizeActions += (() => processUnit()) else processUnit()
228228
}
229-
process()(runContext.fresh.setCompilationUnit(unit))
229+
process()(using runContext.fresh.setCompilationUnit(unit))
230230
}
231231

232232
private sealed trait PrintedTree
233233
private /*final*/ case class SomePrintedTree(phase: String, tree: String) extends PrintedTree
234234
private object NoPrintedTree extends PrintedTree
235235

236-
private def printTree(last: PrintedTree)(implicit ctx: Context): PrintedTree = {
236+
private def printTree(last: PrintedTree)(using Context): PrintedTree = {
237237
val unit = ctx.compilationUnit
238238
val prevPhase = ctx.phase.prev // can be a mini-phase
239239
val squashedPhase = ctx.base.squashed(prevPhase)
240-
val treeString = unit.tpdTree.show(ctx.withProperty(XprintMode, Some(())))
240+
val treeString = unit.tpdTree.show(using ctx.withProperty(XprintMode, Some(())))
241241

242242
ctx.echo(s"result of $unit after $squashedPhase:")
243243

compiler/src/dotty/tools/dotc/classpath/ClassPathFactory.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ class ClassPathFactory {
1616
/**
1717
* Create a new classpath based on the abstract file.
1818
*/
19-
def newClassPath(file: AbstractFile)(implicit ctx: Context): ClassPath = ClassPathFactory.newClassPath(file)
19+
def newClassPath(file: AbstractFile)(using Context): ClassPath = ClassPathFactory.newClassPath(file)
2020

2121
/**
2222
* Creators for sub classpaths which preserve this context.
2323
*/
24-
def sourcesInPath(path: String)(implicit ctx: Context): List[ClassPath] =
24+
def sourcesInPath(path: String)(using Context): List[ClassPath] =
2525
for {
2626
file <- expandPath(path, expandStar = false)
2727
dir <- Option(AbstractFile getDirectory file)
@@ -33,25 +33,25 @@ class ClassPathFactory {
3333

3434
def expandDir(extdir: String): List[String] = dotty.tools.io.ClassPath.expandDir(extdir)
3535

36-
def contentsOfDirsInPath(path: String)(implicit ctx: Context): List[ClassPath] =
36+
def contentsOfDirsInPath(path: String)(using Context): List[ClassPath] =
3737
for {
3838
dir <- expandPath(path, expandStar = false)
3939
name <- expandDir(dir)
4040
entry <- Option(AbstractFile.getDirectory(name))
4141
}
4242
yield newClassPath(entry)
4343

44-
def classesInExpandedPath(path: String)(implicit ctx: Context): IndexedSeq[ClassPath] =
44+
def classesInExpandedPath(path: String)(using Context): IndexedSeq[ClassPath] =
4545
classesInPathImpl(path, expand = true).toIndexedSeq
4646

47-
def classesInPath(path: String)(implicit ctx: Context): List[ClassPath] = classesInPathImpl(path, expand = false)
47+
def classesInPath(path: String)(using Context): List[ClassPath] = classesInPathImpl(path, expand = false)
4848

49-
def classesInManifest(useManifestClassPath: Boolean)(implicit ctx: Context): List[ClassPath] =
49+
def classesInManifest(useManifestClassPath: Boolean)(using Context): List[ClassPath] =
5050
if (useManifestClassPath) dotty.tools.io.ClassPath.manifests.map(url => newClassPath(AbstractFile getResources url))
5151
else Nil
5252

5353
// Internal
54-
protected def classesInPathImpl(path: String, expand: Boolean)(implicit ctx: Context): List[ClassPath] =
54+
protected def classesInPathImpl(path: String, expand: Boolean)(using Context): List[ClassPath] =
5555
for {
5656
file <- expandPath(path, expand)
5757
dir <- {
@@ -61,7 +61,7 @@ class ClassPathFactory {
6161
}
6262
yield newClassPath(dir)
6363

64-
private def createSourcePath(file: AbstractFile)(implicit ctx: Context): ClassPath =
64+
private def createSourcePath(file: AbstractFile)(using Context): ClassPath =
6565
if (file.isJarOrZip)
6666
ZipAndJarSourcePathFactory.create(file)
6767
else if (file.isDirectory)
@@ -71,7 +71,7 @@ class ClassPathFactory {
7171
}
7272

7373
object ClassPathFactory {
74-
def newClassPath(file: AbstractFile)(implicit ctx: Context): ClassPath = file match {
74+
def newClassPath(file: AbstractFile)(using Context): ClassPath = file match {
7575
case vd: VirtualDirectory => VirtualDirectoryClassPath(vd)
7676
case _ =>
7777
if (file.isJarOrZip)

compiler/src/dotty/tools/dotc/classpath/ZipAndJarFileLookupFactory.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import FileUtils._
2121
sealed trait ZipAndJarFileLookupFactory {
2222
private val cache = new FileBasedCache[ClassPath]
2323

24-
def create(zipFile: AbstractFile)(implicit ctx: Context): ClassPath =
24+
def create(zipFile: AbstractFile)(using Context): ClassPath =
2525
if (ctx.settings.YdisableFlatCpCaching.value || zipFile.file == null) createForZipFile(zipFile)
2626
else createUsingCache(zipFile)
2727

compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DecompilationPrinter extends Phase {
1919

2020
override def phaseName: String = "decompilationPrinter"
2121

22-
override def run(implicit ctx: Context): Unit =
22+
override def run(using Context): Unit =
2323
if (ctx.settings.outputDir.isDefault) printToOutput(System.out)
2424
else {
2525
val outputDir = ctx.settings.outputDir.value
@@ -36,7 +36,7 @@ class DecompilationPrinter extends Phase {
3636
}
3737
}
3838

39-
private def printToOutput(out: PrintStream)(implicit ctx: Context): Unit = {
39+
private def printToOutput(out: PrintStream)(using Context): Unit = {
4040
val unit = ctx.compilationUnit
4141
if (ctx.settings.printTasty.value)
4242
println(new TastyPrinter(unit.pickled.head._2).printContents())

0 commit comments

Comments
 (0)