Skip to content

Commit 9ebde7c

Browse files
committed
Drop more ctx bindings
1 parent 2f7f6ce commit 9ebde7c

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,14 +1445,17 @@ object Trees {
14451445
case UnApply(fun, implicits, patterns) =>
14461446
this(this(this(x, fun), implicits), patterns)
14471447
case tree @ ValDef(_, tpt, _) =>
1448-
implicit val ctx = localCtx
1449-
this(this(x, tpt), tree.rhs)
1448+
withContext(localCtx) {
1449+
this(this(x, tpt), tree.rhs)
1450+
}
14501451
case tree @ DefDef(_, tparams, vparamss, tpt, _) =>
1451-
implicit val ctx = localCtx
1452-
this(this(vparamss.foldLeft(this(x, tparams))(apply), tpt), tree.rhs)
1452+
withContext(localCtx) {
1453+
this(this(vparamss.foldLeft(this(x, tparams))(apply), tpt), tree.rhs)
1454+
}
14531455
case TypeDef(_, rhs) =>
1454-
implicit val ctx = localCtx
1455-
this(x, rhs)
1456+
withContext(localCtx) {
1457+
this(x, rhs)
1458+
}
14561459
case tree @ Template(constr, parents, self, _) if tree.derived.isEmpty =>
14571460
this(this(this(this(x, constr), parents), self), tree.body)
14581461
case Import(expr, _) =>

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object PathResolver {
2424
*/
2525
def makeAbsolute(cp: String): String = ClassPath.map(cp, x => Path(x).toAbsolute.path)
2626

27-
/** pretty print class path
27+
/** pretty print class path
2828
*/
2929
def ppcp(s: String): String = split(s) match {
3030
case Nil => ""
@@ -51,7 +51,7 @@ object PathResolver {
5151
def scalaHome: String = propOrEmpty("scala.home")
5252
def scalaExtDirs: String = propOrEmpty("scala.ext.dirs")
5353

54-
/** The java classpath and whether to use it.
54+
/** The java classpath and whether to use it.
5555
*/
5656
def javaUserClassPath: String = propOrElse("java.class.path", "")
5757
def useJavaClassPath: Boolean = propOrFalse("scala.usejavacp")
@@ -134,16 +134,15 @@ object PathResolver {
134134
}
135135

136136
/** Show values in Environment and Defaults when no argument is provided.
137-
* Otherwise, show values in Calculated as if those options had been given
137+
* Otherwise, show values in Calculated as if those options had been given
138138
* to a scala runner.
139139
*/
140140
def main(args: Array[String]): Unit =
141141
if (args.isEmpty) {
142142
println(Environment)
143143
println(Defaults)
144144
}
145-
else {
146-
implicit val ctx = (new ContextBase).initialCtx
145+
else withContext(ContextBase().initialCtx) {
147146
val ArgsSummary(sstate, rest, errors, warnings) =
148147
ctx.settings.processArguments(args.toList, true)
149148
errors.foreach(println)
@@ -165,7 +164,7 @@ class PathResolver(implicit ctx: Context) {
165164

166165
private val classPathFactory = new ClassPathFactory
167166

168-
private def cmdLineOrElse(name: String, alt: String) =
167+
private def cmdLineOrElse(name: String, alt: String) =
169168
commandLineFor(name) match {
170169
case Some("") | None => alt
171170
case Some(x) => x

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ object Comments {
1515
val ContextDoc: Key[ContextDocstrings] = new Key[ContextDocstrings]
1616

1717
/** Decorator for getting docbase out of context */
18-
implicit class CommentsContext(val ctx: Context) extends AnyVal {
19-
def docCtx: Option[ContextDocstrings] = ctx.property(ContextDoc)
20-
}
18+
extension CommentsContext on (c: Context):
19+
def docCtx: Option[ContextDocstrings] = c.property(ContextDoc)
2120

2221
/** Context for Docstrings, contains basic functionality for getting
2322
* docstrings via `Symbol` and expanding templates

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dotc
33
package typer
44

55
import core._
6-
import Contexts._, Symbols._, Decorators._, Comments._
6+
import Contexts._, Symbols._, Decorators._, Comments.{_, given _}
77
import ast.tpd
88

99
object Docstrings {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ package typer
44

55
import core._
66
import ast._
7-
import Trees._, StdNames._, Scopes._, Denotations._, Comments._
7+
import Trees._, StdNames._, Scopes._, Denotations._
88
import Contexts._, Symbols._, Types._, SymDenotations._, Names._, NameOps._, Flags._
9-
import Decorators.{given _}
9+
import Decorators.{given _}, Comments.{_, given _}
1010
import NameKinds.DefaultGetterName
1111
import TypeApplications.TypeParamInfo
1212
import ast.desugar, ast.desugar._

doc-tool/src/dotty/tools/dottydoc/util/syntax.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dottydoc
33
package util
44

55
import dotc.core.Contexts.Context
6-
import dotc.core.Comments._
6+
import dotc.core.Comments.{_, given _}
77
import model.Package
88
import core.ContextDottydoc
99
import dotc.core.Symbols._

0 commit comments

Comments
 (0)