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 config classes
  • Loading branch information
odersky committed Jul 9, 2020
commit b935477733777ed0bcc88a6933ab81f390ff4f69
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 @@ -67,7 +67,7 @@ class Driver {

def setup(args: Array[String], rootCtx: Context): (List[String], Context) = {
val ictx = rootCtx.fresh
val summary = CompilerCommand.distill(args)(ictx)
val summary = CompilerCommand.distill(args)(using ictx)
ictx.setSettings(summary.sstate)
MacroClassLoader.init(ictx)
Positioned.updateDebugPos(using ictx)
Expand All @@ -84,7 +84,7 @@ class Driver {

/** Setup extra classpath and figure out class names for tasty file inputs */
protected def fromTastySetup(fileNames0: List[String], ctx0: Context): (List[String], Context) =
if (ctx0.settings.fromTasty.value(ctx0)) {
if (ctx0.settings.fromTasty.value(using ctx0)) {
// Resolve classpath and class names of tasty files
val (classPaths, classNames) = fileNames0.flatMap { name =>
val path = Paths.get(name)
Expand All @@ -109,7 +109,7 @@ class Driver {
}.unzip
val ctx1 = ctx0.fresh
val classPaths1 = classPaths.distinct.filter(_ != "")
val fullClassPath = (classPaths1 :+ ctx1.settings.classpath.value(ctx1)).mkString(java.io.File.pathSeparator)
val fullClassPath = (classPaths1 :+ ctx1.settings.classpath.value(using ctx1)).mkString(java.io.File.pathSeparator)
ctx1.setSetting(ctx1.settings.classpath, fullClassPath)
(classNames, ctx1)
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/config/CompilerCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object CompilerCommand {
def versionMsg: String = s"Dotty compiler $versionString -- $copyrightString"

/** Distill arguments into summary detailing settings, errors and files to compiler */
def distill(args: Array[String])(implicit ctx: Context): ArgsSummary = {
def distill(args: Array[String])(using Context): ArgsSummary = {
/**
* Expands all arguments starting with @ to the contents of the
* file named like each argument.
Expand Down Expand Up @@ -64,7 +64,7 @@ object CompilerCommand {
* are already applied in context.
* @return The list of files to compile.
*/
def checkUsage(summary: ArgsSummary, sourcesRequired: Boolean)(implicit ctx: Context): List[String] = {
def checkUsage(summary: ArgsSummary, sourcesRequired: Boolean)(using Context): List[String] = {
val settings = ctx.settings

/** Creates a help message for a subset of options based on cond */
Expand Down
12 changes: 6 additions & 6 deletions compiler/src/dotty/tools/dotc/config/JavaPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ class JavaPlatform extends Platform {

private var currentClassPath: Option[ClassPath] = None

def classPath(implicit ctx: Context): ClassPath = {
def classPath(using Context): ClassPath = {
if (currentClassPath.isEmpty)
currentClassPath = Some(new PathResolver().result)
val cp = currentClassPath.get
cp
}

// The given symbol is a method with the right name and signature to be a runnable java program.
def isMainMethod(sym: SymDenotation)(implicit ctx: Context): Boolean =
def isMainMethod(sym: SymDenotation)(using Context): Boolean =
(sym.name == nme.main) && (sym.info match {
case MethodTpe(_, defn.ArrayOf(el) :: Nil, restpe) => el =:= defn.StringType && (restpe isRef defn.UnitClass)
case _ => false
Expand All @@ -35,10 +35,10 @@ class JavaPlatform extends Platform {
currentClassPath = Some(subst.getOrElse(cp, cp))
}

def rootLoader(root: TermSymbol)(implicit ctx: Context): SymbolLoader = new SymbolLoaders.PackageLoader(root, classPath)
def rootLoader(root: TermSymbol)(using Context): SymbolLoader = new SymbolLoaders.PackageLoader(root, classPath)

/** Is the SAMType `cls` also a SAM under the rules of the JVM? */
def isSam(cls: ClassSymbol)(implicit ctx: Context): Boolean =
def isSam(cls: ClassSymbol)(using Context): Boolean =
cls.isAllOf(NoInitsTrait) &&
cls.superClass == defn.ObjectClass &&
cls.directlyInheritedTraits.forall(_.is(NoInits)) &&
Expand All @@ -50,7 +50,7 @@ class JavaPlatform extends Platform {
* to anything but other booleans, but it should be present in
* case this is put to other uses.
*/
def isMaybeBoxed(sym: ClassSymbol)(implicit ctx: Context): Boolean = {
def isMaybeBoxed(sym: ClassSymbol)(using Context): Boolean = {
val d = defn
import d._
(sym == ObjectClass) ||
Expand All @@ -61,6 +61,6 @@ class JavaPlatform extends Platform {
(sym derivesFrom BoxedBooleanClass)
}

def newClassLoader(bin: AbstractFile)(implicit ctx: Context): SymbolLoader =
def newClassLoader(bin: AbstractFile)(using Context): SymbolLoader =
new ClassfileLoader(bin)
}
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/config/PathResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ object PathResolver {
)
}

def fromPathString(path: String)(implicit ctx: Context): ClassPath = {
def fromPathString(path: String)(using Context): ClassPath = {
val settings = ctx.settings.classpath.update(path)
new PathResolver()(using ctx.fresh.setSettings(settings)).result
}
Expand Down Expand Up @@ -159,8 +159,8 @@ object PathResolver {

import PathResolver.{Defaults, ppcp}

class PathResolver(implicit ctx: Context) {
import ctx.base.settings
class PathResolver(using c: Context) {
import c.base.settings

private val classPathFactory = new ClassPathFactory

Expand Down
14 changes: 7 additions & 7 deletions compiler/src/dotty/tools/dotc/config/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import core.Flags.Module
abstract class Platform {

/** The root symbol loader. */
def rootLoader(root: TermSymbol)(implicit ctx: Context): SymbolLoader
def rootLoader(root: TermSymbol)(using Context): SymbolLoader

/** The compiler classpath. */
def classPath(implicit ctx: Context): ClassPath
def classPath(using Context): ClassPath

/** Update classpath with a substitution that maps entries to entries */
def updateClassPath(subst: Map[ClassPath, ClassPath]): Unit
Expand All @@ -26,19 +26,19 @@ abstract class Platform {
//def platformPhases: List[SubComponent]

/** Is the SAMType `cls` also a SAM under the rules of the platform? */
def isSam(cls: ClassSymbol)(implicit ctx: Context): Boolean
def isSam(cls: ClassSymbol)(using Context): Boolean

/** The various ways a boxed primitive might materialize at runtime. */
def isMaybeBoxed(sym: ClassSymbol)(implicit ctx: Context): Boolean
def isMaybeBoxed(sym: ClassSymbol)(using Context): Boolean

/** Create a new class loader to load class file `bin` */
def newClassLoader(bin: AbstractFile)(implicit ctx: Context): SymbolLoader
def newClassLoader(bin: AbstractFile)(using Context): SymbolLoader

/** The given symbol is a method with the right name and signature to be a runnable program. */
def isMainMethod(sym: SymDenotation)(implicit ctx: Context): Boolean
def isMainMethod(sym: SymDenotation)(using Context): Boolean

/** The given class has a main method. */
final def hasMainMethod(sym: Symbol)(implicit ctx: Context): Boolean =
final def hasMainMethod(sym: Symbol)(using Context): Boolean =
sym.info.member(nme.main).hasAltWith {
case x: SymDenotation => isMainMethod(x) && (sym.is(Module) || x.isStatic)
case _ => false
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/config/SJSPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import Symbols._

import dotty.tools.backend.sjs.JSDefinitions

class SJSPlatform()(implicit ctx: Context) extends JavaPlatform {
class SJSPlatform()(using Context) extends JavaPlatform {

/** Scala.js-specific definitions. */
val jsDefinitions: JSDefinitions = new JSDefinitions()

/** Is the SAMType `cls` also a SAM under the rules of the Scala.js back-end? */
override def isSam(cls: ClassSymbol)(implicit ctx: Context): Boolean =
override def isSam(cls: ClassSymbol)(using Context): Boolean =
defn.isFunctionClass(cls) || jsDefinitions.isJSFunctionClass(cls)
}

4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class ScalaSettings extends Settings.SettingGroup {
default = "true")

object mixinForwarderChoices {
def isTruthy(implicit ctx: Context) = XmixinForceForwarders.value == "true"
def isAtLeastJunit(implicit ctx: Context) = isTruthy || XmixinForceForwarders.value == "junit"
def isTruthy(using Context) = XmixinForceForwarders.value == "true"
def isAtLeastJunit(using Context) = isTruthy || XmixinForceForwarders.value == "junit"
}

/** -Y "Private" settings */
Expand Down
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/config/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ object Settings {

object Setting {
implicit class SettingDecorator[T](val setting: Setting[T]) extends AnyVal {
def value(implicit ctx: Context): T = setting.valueIn(ctx.settingsState)
def update(x: T)(implicit ctx: Context): SettingsState = setting.updateIn(ctx.settingsState, x)
def isDefault(implicit ctx: Context): Boolean = setting.isDefaultIn(ctx.settingsState)
def value(using Context): T = setting.valueIn(ctx.settingsState)
def update(x: T)(using Context): SettingsState = setting.updateIn(ctx.settingsState, x)
def isDefault(using Context): Boolean = setting.isDefaultIn(ctx.settingsState)
}
}

Expand Down Expand Up @@ -252,7 +252,7 @@ object Settings {
}
}

def processArguments(arguments: List[String], processAll: Boolean)(implicit ctx: Context): ArgsSummary =
def processArguments(arguments: List[String], processAll: Boolean)(using Context): ArgsSummary =
processArguments(ArgsSummary(ctx.settingsState, arguments, Nil, Nil), processAll, Nil)

def publish[T](settingf: Int => Setting[T]): Setting[T] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
// We also need something like sbt server-mode to be informed of changes on
// the classpath.

private val (zipClassPaths, dirClassPaths) = currentCtx.platform.classPath(currentCtx) match {
private val (zipClassPaths, dirClassPaths) = currentCtx.platform.classPath(using currentCtx) match {
case AggregateClassPath(cps) =>
// FIXME: We shouldn't assume that ClassPath doesn't have other
// subclasses. For now, the only other subclass is JrtClassPath on Java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend

type Settings = config.ScalaSettings

def Settings_color(self: Settings): Boolean = self.color.value(rootContext) == "always"
def Settings_color(self: Settings): Boolean = self.color.value(using rootContext) == "always"


///////////
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/repl/Rendering.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
if (myClassLoader != null) myClassLoader
else {
val parent = parentClassLoader.getOrElse {
val compilerClasspath = ctx.platform.classPath(ctx).asURLs
val compilerClasspath = ctx.platform.classPath(using ctx).asURLs
new java.net.URLClassLoader(compilerClasspath.toArray, null)
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/repl/ReplDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ReplDriver(settings: Array[String],
*/
protected def resetToInitial(): Unit = {
rootCtx = initialCtx
if (rootCtx.settings.outputDir.isDefault(rootCtx))
if (rootCtx.settings.outputDir.isDefault(using rootCtx))
rootCtx = rootCtx.fresh
.setSetting(rootCtx.settings.outputDir, new VirtualDirectory("<REPL compilation output>"))
compiler = new ReplCompiler
Expand Down
4 changes: 2 additions & 2 deletions doc-tool/src/dotty/tools/dottydoc/DocDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class DocDriver extends Driver {

override def setup(args: Array[String], rootCtx: Context): (List[String], Context) = {
val ctx = rootCtx.fresh
val summary = CompilerCommand.distill(args)(ctx)
val summary = CompilerCommand.distill(args)(using ctx)

ctx.setSettings(summary.sstate)
ctx.setSetting(ctx.settings.YcookComments, true)
ctx.setSetting(ctx.settings.YnoInline, true)
ctx.setProperty(ContextDoc, new ContextDottydoc)

val fileNames = CompilerCommand.checkUsage(summary, sourcesRequired)(ctx)
val fileNames = CompilerCommand.checkUsage(summary, sourcesRequired)(using ctx)
fromTastySetup(fileNames, ctx)
}

Expand Down