Skip to content

Commit ac14eb2

Browse files
committed
Switch to (using Context) in more files in typer
1 parent cddf112 commit ac14eb2

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

compiler/src/dotty/tools/dotc/transform/CookComments.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class CookComments extends MegaPhase.MiniPhase {
1515
val owner = template.self.symbol.orElse(cls)
1616

1717
template.body.foreach { stat =>
18-
Docstrings.cookComment(stat.symbol, owner)(cookingCtx)
18+
Docstrings.cookComment(stat.symbol, owner)(using cookingCtx)
1919
}
2020

21-
Docstrings.cookComment(cls, cls)(cookingCtx)
21+
Docstrings.cookComment(cls, cls)(using cookingCtx)
2222
}
2323

2424
tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ object Docstrings {
2020
* @param sym The symbol for which the comment is being cooked.
2121
* @param owner The class for which comments are being cooked.
2222
*/
23-
def cookComment(sym: Symbol, owner: Symbol)(implicit ctx: Context): Option[Comment] =
23+
def cookComment(sym: Symbol, owner: Symbol)(using Context): Option[Comment] =
2424
ctx.docCtx.flatMap { docCtx =>
25-
expand(sym, owner)(ctx, docCtx)
25+
expand(sym, owner)(using ctx)(using docCtx)
2626
}
2727

28-
private def expand(sym: Symbol, owner: Symbol)(implicit ctx: Context, docCtx: ContextDocstrings): Option[Comment] =
28+
private def expand(sym: Symbol, owner: Symbol)(using Context)(using docCtx: ContextDocstrings): Option[Comment] =
2929
docCtx.docstring(sym).flatMap {
3030
case cmt if cmt.isExpanded =>
3131
Some(cmt)
@@ -48,7 +48,7 @@ object Docstrings {
4848
}
4949
}
5050

51-
private def expandComment(sym: Symbol, owner: Symbol, comment: Comment)(implicit ctx: Context, docCtx: ContextDocstrings): Comment = {
51+
private def expandComment(sym: Symbol, owner: Symbol, comment: Comment)(using Context)(using docCtx: ContextDocstrings): Comment = {
5252
val tplExp = docCtx.templateExpander
5353
tplExp.defineVariables(sym)
5454
val newComment = comment.expand(tplExp.expandedDocComment(sym, owner, _))

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ trait Dynamic {
5050
* foo.bar(x = bazX, y = bazY, baz, ...) ~~> foo.applyDynamicNamed("bar")(("x", bazX), ("y", bazY), ("", baz), ...)
5151
* foo.bar[T0, ...](x = bazX, y = bazY, baz, ...) ~~> foo.applyDynamicNamed[T0, ...]("bar")(("x", bazX), ("y", bazY), ("", baz), ...)
5252
*/
53-
def typedDynamicApply(tree: untpd.Apply, pt: Type)(implicit ctx: Context): Tree = {
53+
def typedDynamicApply(tree: untpd.Apply, pt: Type)(using Context): Tree = {
5454
def typedDynamicApply(qual: untpd.Tree, name: Name, selSpan: Span, targs: List[untpd.Tree]): Tree = {
5555
def isNamedArg(arg: untpd.Tree): Boolean = arg match { case NamedArg(_, _) => true; case _ => false }
5656
val args = tree.args
@@ -87,13 +87,13 @@ trait Dynamic {
8787
* Note: inner part of translation foo.bar(baz) = quux ~~> foo.selectDynamic(bar).update(baz, quux) is achieved
8888
* through an existing transformation of in typedAssign [foo.bar(baz) = quux ~~> foo.bar.update(baz, quux)].
8989
*/
90-
def typedDynamicSelect(tree: untpd.Select, targs: List[Tree], pt: Type)(implicit ctx: Context): Tree =
90+
def typedDynamicSelect(tree: untpd.Select, targs: List[Tree], pt: Type)(using Context): Tree =
9191
typedApply(coreDynamic(tree.qualifier, nme.selectDynamic, tree.name, tree.span, targs), pt)
9292

9393
/** Translate selection that does not typecheck according to the normal rules into a updateDynamic.
9494
* foo.bar = baz ~~> foo.updateDynamic(bar)(baz)
9595
*/
96-
def typedDynamicAssign(tree: untpd.Assign, pt: Type)(implicit ctx: Context): Tree = {
96+
def typedDynamicAssign(tree: untpd.Assign, pt: Type)(using Context): Tree = {
9797
def typedDynamicAssign(qual: untpd.Tree, name: Name, selSpan: Span, targs: List[untpd.Tree]): Tree =
9898
typedApply(untpd.Apply(coreDynamic(qual, nme.updateDynamic, name, selSpan, targs), tree.rhs), pt)
9999
tree.lhs match {
@@ -106,7 +106,7 @@ trait Dynamic {
106106
}
107107
}
108108

109-
private def coreDynamic(qual: untpd.Tree, dynName: Name, name: Name, selSpan: Span, targs: List[untpd.Tree])(implicit ctx: Context): untpd.Apply = {
109+
private def coreDynamic(qual: untpd.Tree, dynName: Name, name: Name, selSpan: Span, targs: List[untpd.Tree])(using Context): untpd.Apply = {
110110
val select = untpd.Select(qual, dynName).withSpan(selSpan)
111111
val selectWithTypes =
112112
if (targs.isEmpty) select
@@ -137,7 +137,7 @@ trait Dynamic {
137137
* It's an error if U is neither a value nor a method type, or a dependent method
138138
* type.
139139
*/
140-
def handleStructural(tree: Tree)(implicit ctx: Context): Tree = {
140+
def handleStructural(tree: Tree)(using Context): Tree = {
141141
val (fun @ Select(qual, name), targs, vargss) = decomposeCall(tree)
142142

143143
def structuralCall(selectorName: TermName, ctags: List[Tree]) = {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,29 @@ object ErrorReporting {
1616

1717
import tpd._
1818

19-
def errorTree(tree: untpd.Tree, msg: Message, pos: SourcePosition)(implicit ctx: Context): tpd.Tree =
19+
def errorTree(tree: untpd.Tree, msg: Message, pos: SourcePosition)(using Context): tpd.Tree =
2020
tree.withType(errorType(msg, pos))
2121

22-
def errorTree(tree: untpd.Tree, msg: Message)(implicit ctx: Context): tpd.Tree =
22+
def errorTree(tree: untpd.Tree, msg: Message)(using Context): tpd.Tree =
2323
errorTree(tree, msg, tree.sourcePos)
2424

25-
def errorTree(tree: untpd.Tree, msg: TypeError, pos: SourcePosition)(implicit ctx: Context): tpd.Tree =
25+
def errorTree(tree: untpd.Tree, msg: TypeError, pos: SourcePosition)(using Context): tpd.Tree =
2626
tree.withType(errorType(msg, pos))
2727

28-
def errorType(msg: Message, pos: SourcePosition)(implicit ctx: Context): ErrorType = {
28+
def errorType(msg: Message, pos: SourcePosition)(using Context): ErrorType = {
2929
ctx.error(msg, pos)
3030
ErrorType(msg)
3131
}
3232

33-
def errorType(ex: TypeError, pos: SourcePosition)(implicit ctx: Context): ErrorType = {
33+
def errorType(ex: TypeError, pos: SourcePosition)(using Context): ErrorType = {
3434
ctx.error(ex, pos)
3535
ErrorType(ex.toMessage)
3636
}
3737

38-
def wrongNumberOfTypeArgs(fntpe: Type, expectedArgs: List[ParamInfo], actual: List[untpd.Tree], pos: SourcePosition)(implicit ctx: Context): ErrorType =
38+
def wrongNumberOfTypeArgs(fntpe: Type, expectedArgs: List[ParamInfo], actual: List[untpd.Tree], pos: SourcePosition)(using Context): ErrorType =
3939
errorType(WrongNumberOfTypeArgs(fntpe, expectedArgs, actual)(ctx), pos)
4040

41-
class Errors(implicit ctx: Context) {
41+
class Errors(using Context) {
4242

4343
/** An explanatory note to be added to error messages
4444
* when there's a problem with abstract var defs */
@@ -141,5 +141,5 @@ object ErrorReporting {
141141
else ""
142142
}
143143

144-
def err(implicit ctx: Context): Errors = new Errors
144+
def err(using Context): Errors = new Errors
145145
}

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ abstract class Lifter {
2929
import tpd._
3030

3131
/** Test indicating `expr` does not need lifting */
32-
def noLift(expr: Tree)(implicit ctx: Context): Boolean
32+
def noLift(expr: Tree)(using Context): Boolean
3333

3434
/** The corresponding lifter for pass-by-name arguments */
3535
protected def exprLifter: Lifter = NoLift
@@ -38,12 +38,12 @@ abstract class Lifter {
3838
protected def liftedFlags: FlagSet = EmptyFlags
3939

4040
/** The tree of a lifted definition */
41-
protected def liftedDef(sym: TermSymbol, rhs: Tree)(implicit ctx: Context): MemberDef = ValDef(sym, rhs)
41+
protected def liftedDef(sym: TermSymbol, rhs: Tree)(using Context): MemberDef = ValDef(sym, rhs)
4242

4343
/** Is lifting performed on erased terms? */
4444
protected def isErased = false
4545

46-
private def lift(defs: mutable.ListBuffer[Tree], expr: Tree, prefix: TermName = EmptyTermName)(implicit ctx: Context): Tree =
46+
private def lift(defs: mutable.ListBuffer[Tree], expr: Tree, prefix: TermName = EmptyTermName)(using Context): Tree =
4747
if (noLift(expr)) expr
4848
else {
4949
val name = UniqueName.fresh(prefix)
@@ -62,7 +62,7 @@ abstract class Lifter {
6262
*
6363
* lhs += expr
6464
*/
65-
def liftAssigned(defs: mutable.ListBuffer[Tree], tree: Tree)(implicit ctx: Context): Tree = tree match {
65+
def liftAssigned(defs: mutable.ListBuffer[Tree], tree: Tree)(using Context): Tree = tree match {
6666
case Apply(MaybePoly(fn @ Select(pre, name), targs), args) =>
6767
cpy.Apply(tree)(
6868
cpy.Select(fn)(
@@ -75,7 +75,7 @@ abstract class Lifter {
7575
}
7676

7777
/** Lift a function argument, stripping any NamedArg wrapper */
78-
private def liftArg(defs: mutable.ListBuffer[Tree], arg: Tree, prefix: TermName = EmptyTermName)(implicit ctx: Context): Tree =
78+
private def liftArg(defs: mutable.ListBuffer[Tree], arg: Tree, prefix: TermName = EmptyTermName)(using Context): Tree =
7979
arg match {
8080
case arg @ NamedArg(name, arg1) => cpy.NamedArg(arg)(name, lift(defs, arg1, prefix))
8181
case arg => lift(defs, arg, prefix)
@@ -84,7 +84,7 @@ abstract class Lifter {
8484
/** Lift arguments that are not-idempotent into ValDefs in buffer `defs`
8585
* and replace by the idents of so created ValDefs.
8686
*/
87-
def liftArgs(defs: mutable.ListBuffer[Tree], methRef: Type, args: List[Tree])(implicit ctx: Context): List[Tree] =
87+
def liftArgs(defs: mutable.ListBuffer[Tree], methRef: Type, args: List[Tree])(using Context): List[Tree] =
8888
methRef.widen match {
8989
case mt: MethodType =>
9090
args.lazyZip(mt.paramNames).lazyZip(mt.paramInfos).map { (arg, name, tp) =>
@@ -108,7 +108,7 @@ abstract class Lifter {
108108
* But leave pure expressions alone.
109109
*
110110
*/
111-
def liftApp(defs: mutable.ListBuffer[Tree], tree: Tree)(implicit ctx: Context): Tree = tree match {
111+
def liftApp(defs: mutable.ListBuffer[Tree], tree: Tree)(using Context): Tree = tree match {
112112
case Apply(fn, args) =>
113113
val fn1 = liftApp(defs, fn)
114114
val args1 = liftArgs(defs, fn.tpe, args)
@@ -133,24 +133,24 @@ abstract class Lifter {
133133
*
134134
* unless `pre` is idempotent.
135135
*/
136-
def liftPrefix(defs: mutable.ListBuffer[Tree], tree: Tree)(implicit ctx: Context): Tree =
136+
def liftPrefix(defs: mutable.ListBuffer[Tree], tree: Tree)(using Context): Tree =
137137
if (isIdempotentExpr(tree)) tree else lift(defs, tree)
138138
}
139139

140140
/** No lifting at all */
141141
object NoLift extends Lifter {
142-
def noLift(expr: tpd.Tree)(implicit ctx: Context): Boolean = true
142+
def noLift(expr: tpd.Tree)(using Context): Boolean = true
143143
}
144144

145145
/** Lift all impure arguments */
146146
class LiftImpure extends Lifter {
147-
def noLift(expr: tpd.Tree)(implicit ctx: Context): Boolean = tpd.isPureExpr(expr)
147+
def noLift(expr: tpd.Tree)(using Context): Boolean = tpd.isPureExpr(expr)
148148
}
149149
object LiftImpure extends LiftImpure
150150

151151
/** Lift all impure or complex arguments */
152152
class LiftComplex extends Lifter {
153-
def noLift(expr: tpd.Tree)(implicit ctx: Context): Boolean = tpd.isPurePath(expr)
153+
def noLift(expr: tpd.Tree)(using Context): Boolean = tpd.isPurePath(expr)
154154
override def exprLifter: Lifter = LiftToDefs
155155
}
156156
object LiftComplex extends LiftComplex
@@ -161,7 +161,7 @@ object LiftErased extends LiftComplex:
161161
/** Lift all impure or complex arguments to `def`s */
162162
object LiftToDefs extends LiftComplex {
163163
override def liftedFlags: FlagSet = Method
164-
override def liftedDef(sym: TermSymbol, rhs: tpd.Tree)(implicit ctx: Context): tpd.DefDef = tpd.DefDef(sym, rhs)
164+
override def liftedDef(sym: TermSymbol, rhs: tpd.Tree)(using Context): tpd.DefDef = tpd.DefDef(sym, rhs)
165165
}
166166

167167
/** Lifter for eta expansion */
@@ -221,7 +221,7 @@ object EtaExpansion extends LiftImpure {
221221
* be OK. After elimByName they are all converted to regular function types anyway.
222222
* But see comment on the `ExprType` case in function `prune` in class `ConstraintHandling`.
223223
*/
224-
def etaExpand(tree: Tree, mt: MethodType, xarity: Int)(implicit ctx: Context): untpd.Tree = {
224+
def etaExpand(tree: Tree, mt: MethodType, xarity: Int)(using Context): untpd.Tree = {
225225
import untpd._
226226
assert(!ctx.isAfterTyper)
227227
val defs = new mutable.ListBuffer[tpd.Tree]

0 commit comments

Comments
 (0)