Skip to content

Commit 8fb6a67

Browse files
committed
Switch to (using Context) in more files in typer
1 parent a226721 commit 8fb6a67

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ class Namer { typer: Typer =>
866866
def rhsToInline(using Context): tpd.Tree =
867867
val mdef = typedAheadExpr(original).asInstanceOf[tpd.DefDef]
868868
PrepareInlineable.wrapRHS(original, mdef.tpt, mdef.rhs)
869-
PrepareInlineable.registerInlineInfo(sym, rhsToInline)(localContext(sym))
869+
PrepareInlineable.registerInlineInfo(sym, rhsToInline)(using localContext(sym))
870870
case _ =>
871871
}
872872

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Types._
1212
import Decorators._
1313
import NameKinds._
1414
import StdNames.nme
15-
import Contexts.Context
15+
import Contexts.{Context, ctx}
1616
import Names.Name
1717
import NameKinds.{InlineAccessorName, UniqueInlineName}
1818
import NameOps._
@@ -32,7 +32,7 @@ object PrepareInlineable {
3232
* that the inline accessor takes its receiver as first parameter. Such accessors
3333
* are created by MakeInlineablePassing.
3434
*/
35-
override def passReceiverAsArg(name: Name)(implicit ctx: Context): Boolean = name match {
35+
override def passReceiverAsArg(name: Name)(using Context): Boolean = name match {
3636
case InlineAccessorName(UniqueInlineName(_, _)) => true
3737
case _ => false
3838
}
@@ -49,23 +49,23 @@ object PrepareInlineable {
4949
* Constant vals don't need accessors since they are inlined in FirstTransform.
5050
* Inline methods don't need accessors since they are inlined in Typer.
5151
*/
52-
def needsAccessor(sym: Symbol)(implicit ctx: Context): Boolean =
52+
def needsAccessor(sym: Symbol)(using Context): Boolean =
5353
sym.isTerm &&
5454
(sym.isOneOf(AccessFlags) || sym.privateWithin.exists) &&
5555
!sym.isContainedIn(inlineSym) &&
5656
!(sym.isStableMember && sym.info.widenTermRefExpr.isInstanceOf[ConstantType]) &&
5757
!sym.isInlineMethod
5858

59-
def preTransform(tree: Tree)(implicit ctx: Context): Tree
59+
def preTransform(tree: Tree)(using Context): Tree
6060

61-
def postTransform(tree: Tree)(implicit ctx: Context): Tree = tree match {
61+
def postTransform(tree: Tree)(using Context): Tree = tree match {
6262
case Assign(lhs, rhs) if lhs.symbol.name.is(InlineAccessorName) =>
6363
cpy.Apply(tree)(useSetter(lhs), rhs :: Nil)
6464
case _ =>
6565
tree
6666
}
6767

68-
override def transform(tree: Tree)(implicit ctx: Context): Tree =
68+
override def transform(tree: Tree)(using Context): Tree =
6969
postTransform(super.transform(preTransform(tree)))
7070
}
7171

@@ -75,7 +75,7 @@ object PrepareInlineable {
7575
* by the test that we can find a host for the accessor.
7676
*/
7777
class MakeInlineableDirect(inlineSym: Symbol) extends MakeInlineableMap(inlineSym) {
78-
def preTransform(tree: Tree)(implicit ctx: Context): Tree = tree match {
78+
def preTransform(tree: Tree)(using Context): Tree = tree match {
7979
case tree: RefTree if needsAccessor(tree.symbol) =>
8080
if (tree.symbol.isConstructor) {
8181
ctx.error("Implementation restriction: cannot use private constructors in inlineinline methods", tree.sourcePos)
@@ -85,7 +85,7 @@ object PrepareInlineable {
8585
case _ =>
8686
tree
8787
}
88-
override def ifNoHost(reference: RefTree)(implicit ctx: Context): Tree = reference
88+
override def ifNoHost(reference: RefTree)(using Context): Tree = reference
8989
}
9090

9191
/** Fallback approach if the direct approach does not work: Place the accessor method
@@ -119,7 +119,7 @@ object PrepareInlineable {
119119
*/
120120
class MakeInlineablePassing(inlineSym: Symbol) extends MakeInlineableMap(inlineSym) {
121121

122-
def preTransform(tree: Tree)(implicit ctx: Context): Tree = tree match {
122+
def preTransform(tree: Tree)(using Context): Tree = tree match {
123123
case _: Apply | _: TypeApply | _: RefTree
124124
if needsAccessor(tree.symbol) && tree.isTerm && !tree.symbol.isConstructor =>
125125
val (refPart, targs, argss) = decomposeCall(tree)
@@ -186,7 +186,7 @@ object PrepareInlineable {
186186
* @return If there are accessors generated, a thicket consisting of the rewritten `tree`
187187
* and all accessors, otherwise the original tree.
188188
*/
189-
def makeInlineable(tree: Tree)(implicit ctx: Context): Tree = {
189+
def makeInlineable(tree: Tree)(using Context): Tree = {
190190
val inlineSym = ctx.owner
191191
if (inlineSym.owner.isTerm)
192192
// Inlineable methods in local scopes can only be called in the scope they are defined,
@@ -198,10 +198,10 @@ object PrepareInlineable {
198198
}
199199
}
200200

201-
def isLocalOrParam(sym: Symbol, inlineMethod: Symbol)(implicit ctx: Context): Boolean =
201+
def isLocalOrParam(sym: Symbol, inlineMethod: Symbol)(using Context): Boolean =
202202
sym.isContainedIn(inlineMethod) && sym != inlineMethod
203203

204-
def isLocal(sym: Symbol, inlineMethod: Symbol)(implicit ctx: Context): Boolean =
204+
def isLocal(sym: Symbol, inlineMethod: Symbol)(using Context): Boolean =
205205
isLocalOrParam(sym, inlineMethod) && !(sym.is(Param) && sym.owner == inlineMethod)
206206

207207
/** The type ascription `rhs: tpt`, unless `original` is `transparent`. */
@@ -218,7 +218,7 @@ object PrepareInlineable {
218218
* to have the inline method as owner.
219219
*/
220220
def registerInlineInfo(
221-
inlined: Symbol, treeExpr: Context ?=> Tree)(implicit ctx: Context): Unit =
221+
inlined: Symbol, treeExpr: Context ?=> Tree)(using Context): Unit =
222222
inlined.unforcedAnnotation(defn.BodyAnnot) match {
223223
case Some(ann: ConcreteBodyAnnotation) =>
224224
case Some(ann: LazyBodyAnnotation) if ann.isEvaluated || ann.isEvaluating =>
@@ -241,7 +241,7 @@ object PrepareInlineable {
241241
}
242242
}
243243

244-
def checkInlineMethod(inlined: Symbol, body: Tree)(implicit ctx: Context): Unit = {
244+
def checkInlineMethod(inlined: Symbol, body: Tree)(using Context): Unit = {
245245
if (inlined.owner.isClass && inlined.owner.seesOpaques)
246246
ctx.error(em"Implementation restriction: No inline methods allowed where opaque type aliases are in scope", inlined.sourcePos)
247247
if (ctx.outer.inInlineMethod)

0 commit comments

Comments
 (0)