Skip to content

Commit 3d26c53

Browse files
authored
Merge pull request #8639 from dotty-staging/change-ctx
Don't write `(using ctx: Context)`
2 parents 2c3212b + 7641518 commit 3d26c53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1630
-1622
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package backend.jvm
44
import dotc.ast.Trees.Select
55
import dotc.ast.tpd._
66
import dotc.core._
7-
import Contexts.Context
7+
import Contexts.{Context, ctx}
88
import Names.TermName, StdNames._
99
import Types.{JavaArrayType, UnspecifiedErrorType, Type}
1010
import Symbols.{Symbol, NoSymbol}
@@ -49,7 +49,7 @@ class DottyPrimitives(ictx: Context) {
4949
* @param tpe The type of the receiver object. It is used only for array
5050
* operations
5151
*/
52-
def getPrimitive(app: Apply, tpe: Type)(implicit ctx: Context): Int = {
52+
def getPrimitive(app: Apply, tpe: Type)(using Context): Int = {
5353
val fun = app.fun.symbol
5454
val defn = ctx.definitions
5555
val code = app.fun match {
@@ -130,7 +130,7 @@ class DottyPrimitives(ictx: Context) {
130130
primitives(s) = code
131131
}
132132

133-
def addPrimitives(cls: Symbol, method: TermName, code: Int)(implicit ctx: Context): Unit = {
133+
def addPrimitives(cls: Symbol, method: TermName, code: Int)(using Context): Unit = {
134134
val alts = cls.info.member(method).alternatives.map(_.symbol)
135135
if (alts.isEmpty)
136136
ctx.error(s"Unknown primitive method $cls.$method")

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package dotty.tools
22
package dotc
33

4-
import util.{FreshNameCreator, SourceFile}
4+
import core._
5+
import Contexts.{Context, ctx}
6+
import SymDenotations.ClassDenotation
7+
import Symbols._
8+
import util.{FreshNameCreator, SourceFile, NoSource}
9+
import util.Spans.Span
510
import ast.{tpd, untpd}
611
import tpd.{Tree, TreeTraverser}
712
import typer.PrepareInlineable.InlineAccessors
813
import typer.Nullables
9-
import dotty.tools.dotc.core.Contexts.Context
10-
import dotty.tools.dotc.core.SymDenotations.ClassDenotation
11-
import dotty.tools.dotc.core.Symbols._
12-
import dotty.tools.dotc.transform.SymUtils._
13-
import util.{NoSource, SourceFile}
14-
import util.Spans.Span
15-
import core.Decorators._
14+
import transform.SymUtils._
15+
import core.Decorators.{given _}
1616

1717
class CompilationUnit protected (val source: SourceFile) {
1818

@@ -43,7 +43,7 @@ class CompilationUnit protected (val source: SourceFile) {
4343

4444
var suspended: Boolean = false
4545

46-
def suspend()(using ctx: Context): Nothing =
46+
def suspend()(using Context): Nothing =
4747
if !suspended then
4848
if (ctx.settings.XprintSuspension.value)
4949
ctx.echo(i"suspended: $this")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
6060
.setTyperState(new TyperState(ctx.typerState))
6161
ctx.initialize()(start) // re-initialize the base context with start
6262
def addImport(ctx: Context, rootRef: ImportInfo.RootRef) =
63-
ctx.fresh.setImportInfo(ImportInfo.rootImport(rootRef)(ctx))
63+
ctx.fresh.setImportInfo(ImportInfo.rootImport(rootRef))
6464
defn.RootImportFns.foldLeft(start.setRun(this))(addImport)
6565
}
6666

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ object desugar {
919919
* <extension> def g[Ts](x: T)(using C)(z: T) = f(z)
920920
*/
921921
def collectiveExtensionBody(stats: List[Tree],
922-
tparams: List[TypeDef], vparamss: List[List[ValDef]])(using ctx: Context): List[Tree] =
922+
tparams: List[TypeDef], vparamss: List[List[ValDef]])(using Context): List[Tree] =
923923
for stat <- stats yield
924924
stat match
925925
case mdef: DefDef =>
@@ -968,7 +968,7 @@ object desugar {
968968
}
969969

970970
/** Invent a name for an anonympus given or extension of type or template `impl`. */
971-
def inventGivenOrExtensionName(impl: Tree)(using ctx: Context): SimpleName =
971+
def inventGivenOrExtensionName(impl: Tree)(using Context): SimpleName =
972972
val str = impl match
973973
case impl: Template =>
974974
if impl.parents.isEmpty then

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ object MainProxies {
4040
}
4141

4242
import untpd._
43-
def mainProxy(mainFun: Symbol)(using ctx: Context): List[TypeDef] = {
43+
def mainProxy(mainFun: Symbol)(using Context): List[TypeDef] = {
4444
val mainAnnotSpan = mainFun.getAnnotation(defn.MainAnnot).get.tree.span
4545
def pos = mainFun.sourcePos
4646
val argsRef = Ident(nme.args)

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class TreeMapWithImplicits extends tpd.TreeMap {
4848
case stat: Import => ctx.importContext(stat, stat.symbol)
4949
case _ => ctx
5050
}
51-
val stat1 = transform(stat)(statCtx)
51+
val stat1 = transform(stat)(using statCtx)
5252
if (stat1 ne stat) recur(stats, stat1, rest)(restCtx)
5353
else traverse(rest)(restCtx)
5454
case nil =>
@@ -81,37 +81,37 @@ class TreeMapWithImplicits extends tpd.TreeMap {
8181
nestedCtx
8282
}
8383

84-
override def transform(tree: Tree)(implicit ctx: Context): Tree = {
84+
override def transform(tree: Tree)(using Context): Tree = {
8585
def localCtx =
8686
if (tree.hasType && tree.symbol.exists) ctx.withOwner(tree.symbol) else ctx
8787
try tree match {
8888
case tree: Block =>
89-
super.transform(tree)(nestedScopeCtx(tree.stats))
89+
super.transform(tree)(using nestedScopeCtx(tree.stats))
9090
case tree: DefDef =>
91-
implicit val ctx = localCtx
91+
given Context = localCtx
9292
cpy.DefDef(tree)(
9393
tree.name,
9494
transformSub(tree.tparams),
9595
tree.vparamss mapConserve (transformSub(_)),
9696
transform(tree.tpt),
97-
transform(tree.rhs)(nestedScopeCtx(tree.vparamss.flatten)))
97+
transform(tree.rhs)(using nestedScopeCtx(tree.vparamss.flatten)))
9898
case EmptyValDef =>
9999
tree
100100
case _: PackageDef | _: MemberDef =>
101-
super.transform(tree)(localCtx)
101+
super.transform(tree)(using localCtx)
102102
case impl @ Template(constr, parents, self, _) =>
103103
cpy.Template(tree)(
104104
transformSub(constr),
105-
transform(parents)(ctx.superCallContext),
105+
transform(parents)(using ctx.superCallContext),
106106
Nil,
107107
transformSelf(self),
108108
transformStats(impl.body, tree.symbol))
109109
case tree: CaseDef =>
110-
val patCtx = patternScopeCtx(tree.pat)(ctx)
110+
val patCtx = patternScopeCtx(tree.pat)(using ctx)
111111
cpy.CaseDef(tree)(
112112
transform(tree.pat),
113-
transform(tree.guard)(patCtx),
114-
transform(tree.body)(patCtx)
113+
transform(tree.guard)(using patCtx),
114+
transform(tree.body)(using patCtx)
115115
)
116116
case _ =>
117117
super.transform(tree)

0 commit comments

Comments
 (0)