Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d8cd2bb
Convert to using clauses
odersky Jul 9, 2020
717bce7
Convert Symbols to using clauses
odersky Jul 8, 2020
7330e7f
Convert Denotations to using clauses
odersky Jul 8, 2020
86ae3ca
Remove implicit definitions of `ctx` that are not parameters
odersky Jul 9, 2020
1d8cb7c
Change Printers to givens
odersky Jul 9, 2020
9d52399
Change Printers to givens
odersky Jul 9, 2020
d1f2a11
Remove implicit definitions of `ctx` that are not parameters (2)
odersky Jul 9, 2020
017a578
Convert to givens in TypeComparer
odersky Jul 9, 2020
f16fec0
Convert core classes (1)
odersky Jul 9, 2020
0c0d896
Convert core classes (2)
odersky Jul 9, 2020
114e0d2
Convert core classes (3)
odersky Jul 9, 2020
23b19e8
Convert core classes (4)
odersky Jul 9, 2020
50144f4
Convert core classes (5)
odersky Jul 9, 2020
adc75a0
Convert core classes (6)
odersky Jul 9, 2020
a66f8f3
Convert tasty and unpickler classes
odersky Jul 9, 2020
f76b9b6
Convert ast classes
odersky Jul 9, 2020
b935477
Convert config classes
odersky Jul 9, 2020
2ab9a58
Convert parser classes
odersky Jul 9, 2020
e71a167
Convert interactive classes
odersky Jul 9, 2020
f5c30a9
Convert reporting classes
odersky Jul 9, 2020
1ae90ec
Convert transform classes (1)
odersky Jul 9, 2020
7366f5c
Convert transform classes (2)
odersky Jul 9, 2020
1798e29
Convert transform classes (3)
odersky Jul 9, 2020
ce9aa2d
Convert transform classes (4)
odersky Jul 9, 2020
edb4869
Convert other dotc classes (1)
odersky Jul 9, 2020
68e1fea
Convert other dotc classes (2)
odersky Jul 9, 2020
4dc0b9b
Fixes
odersky Jul 10, 2020
d84abfe
Convert tools classes
odersky Jul 9, 2020
682ef6a
Convert repl classes
odersky Jul 10, 2020
6e54aed
Convert test classes (1)
odersky Jul 10, 2020
f71a4b3
Convert test classes (2)
odersky Jul 10, 2020
b76d2e4
Make Contexts.ctx an inline function
odersky Jul 10, 2020
a9c405f
Omit redundant (using ctx)
odersky Jul 10, 2020
f3e03fc
Move atPhase and friends to Contexts
odersky Jul 10, 2020
0ece69a
Use atPhase instead of inContext where possible
odersky Jul 10, 2020
da6829b
Rename Context#phases -> Phases.curPhases
odersky Jul 10, 2020
cd9f05d
Move individual phases to Phases
odersky Jul 10, 2020
165b7d8
Use atPhase instead of passing ctx.withPhase
odersky Jul 10, 2020
5442a4f
Use atPhase for ContextFunctionResults
odersky Jul 10, 2020
1236d8c
Convert remaining instance to atPhase
odersky Jul 10, 2020
159486a
Move plugins to ContextBase
odersky Jul 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Convert other dotc classes (1)
  • Loading branch information
odersky committed Jul 9, 2020
commit edb4869df72b26ef9d3cc80bec06f27034c384bc
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/backend/sjs/JUnitBootstrappers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ class JUnitBootstrappers extends MiniPhase {
if timeoutName.toString == "timeout" => Some(timeoutLiteral)
case other => {
val shownName = other match {
case NamedArg(name, _) => name.show(ctx)
case other => other.show(ctx)
case NamedArg(name, _) => name.show(using ctx)
case other => other.show(using ctx)
}
ctx.error(s"$shownName is an unsupported argument for the JUnit @Test annotation in this position", other.sourcePos)
None
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Bench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object Bench extends Driver {
private def ntimes(n: Int)(op: => Reporter): Reporter =
(0 until n).foldLeft(emptyReporter)((_, _) => op)

override def doCompile(compiler: Compiler, fileNames: List[String])(implicit ctx: Context): Reporter =
override def doCompile(compiler: Compiler, fileNames: List[String])(using Context): Reporter =
ntimes(numRuns) {
val start = System.nanoTime()
val r = super.doCompile(compiler, fileNames)
Expand Down
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/CompilationUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ object CompilationUnit {
class SuspendException extends Exception

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

/** Make a compilation unit, given picked bytes and unpickled tree */
def apply(source: SourceFile, unpickled: Tree, forceTrees: Boolean)(implicit ctx: Context): CompilationUnit = {
def apply(source: SourceFile, unpickled: Tree, forceTrees: Boolean)(using Context): CompilationUnit = {
assert(!unpickled.isEmpty, unpickled)
val unit1 = new CompilationUnit(source)
unit1.tpdTree = unpickled
Expand All @@ -98,7 +98,7 @@ object CompilationUnit {
/** Create a compilation unit corresponding to `source`.
* If `mustExist` is true, this will fail if `source` does not exist.
*/
def apply(source: SourceFile, mustExist: Boolean = true)(implicit ctx: Context): CompilationUnit = {
def apply(source: SourceFile, mustExist: Boolean = true)(using Context): CompilationUnit = {
val src =
if (!mustExist)
source
Expand All @@ -117,7 +117,7 @@ object CompilationUnit {
/** Force the tree to be loaded */
private class Force extends TreeTraverser {
var needsStaging = false
def traverse(tree: Tree)(implicit ctx: Context): Unit = {
def traverse(tree: Tree)(using Context): Unit = {
if (tree.symbol.isQuote)
needsStaging = true
traverseChildren(tree)
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ class Compiler {
runId += 1; runId
}

def reset()(implicit ctx: Context): Unit = {
def reset()(using Context): Unit = {
ctx.base.reset()
if (ctx.run != null) ctx.run.reset()
}

def newRun(implicit ctx: Context): Run = {
def newRun(using Context): Run = {
reset()
val rctx =
if ctx.settings.Ysemanticdb.value
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import fromtasty.{TASTYCompiler, TastyFileUtil}
*/
class Driver {

protected def newCompiler(implicit ctx: Context): Compiler =
protected def newCompiler(using Context): Compiler =
if (ctx.settings.fromTasty.value) new TASTYCompiler
else new Compiler

protected def emptyReporter: Reporter = new StoreReporter(null)

protected def doCompile(compiler: Compiler, fileNames: List[String])(implicit ctx: Context): Reporter =
protected def doCompile(compiler: Compiler, fileNames: List[String])(using Context): Reporter =
if (fileNames.nonEmpty)
try
val run = compiler.newRun
Expand Down Expand Up @@ -191,7 +191,7 @@ class Driver {
*/
def process(args: Array[String], rootCtx: Context): Reporter = {
val (fileNames, compileCtx) = setup(args, rootCtx)
doCompile(newCompiler(compileCtx), fileNames)(compileCtx)
doCompile(newCompiler(using compileCtx), fileNames)(using compileCtx)
}

def main(args: Array[String]): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Resident.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Resident extends Driver {
final override def process(args: Array[String], rootCtx: Context): Reporter = {
@tailrec def loop(args: Array[String], prevCtx: Context): Reporter = {
var (fileNames, ctx) = setup(args, prevCtx)
doCompile(residentCompiler, fileNames)(ctx)
doCompile(residentCompiler, fileNames)(using ctx)
var nextCtx = ctx
var line = getLine()
while (line == reset) {
Expand Down
22 changes: 11 additions & 11 deletions compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
* for type checking.
* imports For each element of RootImports, an import context
*/
protected def rootContext(implicit ctx: Context): Context = {
protected def rootContext(using Context): Context = {
ctx.initialize()
ctx.base.setPhasePlan(comp.phases)
val rootScope = new MutableScope
Expand All @@ -80,7 +80,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint

private var compiling = false

private var myCtx = rootContext(ictx)
private var myCtx = rootContext(using ictx)

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

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

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

def runPhases(implicit ctx: Context) = {
def runPhases(using Context) = {
var lastPrintedTree: PrintedTree = NoPrintedTree
val profiler = ctx.profiler

Expand All @@ -182,7 +182,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
if (ctx.settings.Xprint.value.containsPhase(phase))
for (unit <- units)
lastPrintedTree =
printTree(lastPrintedTree)(ctx.fresh.setPhase(phase.next).setCompilationUnit(unit))
printTree(lastPrintedTree)(using ctx.fresh.setPhase(phase.next).setCompilationUnit(unit))
ctx.informTime(s"$phase ", start)
Stats.record(s"total trees at end of $phase", ast.Trees.ntrees)
for (unit <- units)
Expand All @@ -195,7 +195,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
val runCtx = ctx.fresh
runCtx.setProfiler(Profiler())
ctx.phases.foreach(_.initContext(runCtx))
runPhases(runCtx)
runPhases(using runCtx)
if (!ctx.reporter.hasErrors) Rewrites.writeBack()
while (finalizeActions.nonEmpty) {
val action = finalizeActions.remove(0)
Expand All @@ -209,11 +209,11 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
* If `typeCheck = true`, also run typer on the compilation unit, and set
* `rootTreeOrProvider`.
*/
def lateCompile(file: AbstractFile, typeCheck: Boolean)(implicit ctx: Context): Unit =
def lateCompile(file: AbstractFile, typeCheck: Boolean)(using Context): Unit =
if (!files.contains(file) && !lateFiles.contains(file)) {
lateFiles += file
val unit = CompilationUnit(ctx.getSource(file.path))
def process()(implicit ctx: Context) = {
def process()(using Context) = {
unit.untpdTree =
if (unit.isJava) new JavaParser(unit.source).parse()
else new Parser(unit.source).parse()
Expand All @@ -226,18 +226,18 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
if (typeCheck)
if (compiling) finalizeActions += (() => processUnit()) else processUnit()
}
process()(runContext.fresh.setCompilationUnit(unit))
process()(using runContext.fresh.setCompilationUnit(unit))
}

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

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

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

Expand Down
18 changes: 9 additions & 9 deletions compiler/src/dotty/tools/dotc/classpath/ClassPathFactory.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class ClassPathFactory {
/**
* Create a new classpath based on the abstract file.
*/
def newClassPath(file: AbstractFile)(implicit ctx: Context): ClassPath = ClassPathFactory.newClassPath(file)
def newClassPath(file: AbstractFile)(using Context): ClassPath = ClassPathFactory.newClassPath(file)

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

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

def contentsOfDirsInPath(path: String)(implicit ctx: Context): List[ClassPath] =
def contentsOfDirsInPath(path: String)(using Context): List[ClassPath] =
for {
dir <- expandPath(path, expandStar = false)
name <- expandDir(dir)
entry <- Option(AbstractFile.getDirectory(name))
}
yield newClassPath(entry)

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

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

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

// Internal
protected def classesInPathImpl(path: String, expand: Boolean)(implicit ctx: Context): List[ClassPath] =
protected def classesInPathImpl(path: String, expand: Boolean)(using Context): List[ClassPath] =
for {
file <- expandPath(path, expand)
dir <- {
Expand All @@ -61,7 +61,7 @@ class ClassPathFactory {
}
yield newClassPath(dir)

private def createSourcePath(file: AbstractFile)(implicit ctx: Context): ClassPath =
private def createSourcePath(file: AbstractFile)(using Context): ClassPath =
if (file.isJarOrZip)
ZipAndJarSourcePathFactory.create(file)
else if (file.isDirectory)
Expand All @@ -71,7 +71,7 @@ class ClassPathFactory {
}

object ClassPathFactory {
def newClassPath(file: AbstractFile)(implicit ctx: Context): ClassPath = file match {
def newClassPath(file: AbstractFile)(using Context): ClassPath = file match {
case vd: VirtualDirectory => VirtualDirectoryClassPath(vd)
case _ =>
if (file.isJarOrZip)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import FileUtils._
sealed trait ZipAndJarFileLookupFactory {
private val cache = new FileBasedCache[ClassPath]

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DecompilationPrinter extends Phase {

override def phaseName: String = "decompilationPrinter"

override def run(implicit ctx: Context): Unit =
override def run(using Context): Unit =
if (ctx.settings.outputDir.isDefault) printToOutput(System.out)
else {
val outputDir = ctx.settings.outputDir.value
Expand All @@ -36,7 +36,7 @@ class DecompilationPrinter extends Phase {
}
}

private def printToOutput(out: PrintStream)(implicit ctx: Context): Unit = {
private def printToOutput(out: PrintStream)(using Context): Unit = {
val unit = ctx.compilationUnit
if (ctx.settings.printTasty.value)
println(new TastyPrinter(unit.pickled.head._2).printContents())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class IDEDecompilerDriver(val settings: List[String]) extends dotc.Driver {
def run(className: String): (String, String) = {
val reporter = new StoreReporter(null) with HideNonSensicalMessages

val run = decompiler.newRun(myInitCtx.fresh.setReporter(reporter))
val run = decompiler.newRun(using myInitCtx.fresh.setReporter(reporter))

inContext(run.runContext) {
run.compile(List(className))
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/decompiler/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import dotty.tools.dotc.core.Contexts._
* @author Nicolas Stucki
*/
object Main extends dotc.Driver {
override protected def newCompiler(implicit ctx: Context): dotc.Compiler = {
override protected def newCompiler(using Context): dotc.Compiler = {
assert(ctx.settings.fromTasty.value)
if (!ctx.settings.outputDir.isDefault)
Files.deleteIfExists(ctx.settings.outputDir.value.fileNamed("decompiled.scala").jpath)
Expand Down
10 changes: 5 additions & 5 deletions compiler/src/dotty/tools/dotc/fromtasty/ReadTasty.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class ReadTasty extends Phase {

def phaseName: String = "readTasty"

override def isRunnable(implicit ctx: Context): Boolean =
override def isRunnable(using Context): Boolean =
ctx.settings.fromTasty.value

override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] =
units.flatMap(readTASTY(_)(ctx.addMode(Mode.ReadPositions)))
override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] =
units.flatMap(readTASTY(_)(using ctx.addMode(Mode.ReadPositions)))

def readTASTY(unit: CompilationUnit)(implicit ctx: Context): Option[CompilationUnit] = unit match {
def readTASTY(unit: CompilationUnit)(using Context): Option[CompilationUnit] = unit match {
case unit: TASTYCompilationUnit =>
val className = unit.className.toTypeName

Expand Down Expand Up @@ -75,5 +75,5 @@ class ReadTasty extends Phase {
Some(unit)
}

def run(implicit ctx: Context): Unit = unsupported("run")
def run(using Context): Unit = unsupported("run")
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TASTYCompiler extends Compiler {
override protected def frontendPhases: List[List[Phase]] =
List(new ReadTasty) :: Nil

override def newRun(implicit ctx: Context): Run = {
override def newRun(using Context): Run = {
reset()
new TASTYRun(this, ctx.addMode(Mode.ReadPositions))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
val reporter =
new StoreReporter(null) with UniqueMessagePositions with HideNonSensicalMessages

val run = compiler.newRun(myInitCtx.fresh.setReporter(reporter))
val run = compiler.newRun(using myInitCtx.fresh.setReporter(reporter))
myCtx = run.runContext

given Context = myCtx
Expand Down Expand Up @@ -312,7 +312,7 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
* late-compilation is needed).
*/
private def initialize(): Unit = {
val run = compiler.newRun(myInitCtx.fresh)
val run = compiler.newRun(using myInitCtx.fresh)
myCtx = run.runContext
run.compileUnits(Nil, myCtx)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/plugins/Plugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ trait ResearchPlugin extends Plugin {
* @param plan: the given phase plan
* @return the new phase plan
*/
def init(options: List[String], plan: List[List[Phase]])(implicit ctx: Context): List[List[Phase]]
def init(options: List[String], plan: List[List[Phase]])(using Context): List[List[Phase]]
}

object Plugin {
Expand Down
Loading