@@ -12,7 +12,7 @@ import Types._
12
12
import Decorators ._
13
13
import NameKinds ._
14
14
import StdNames .nme
15
- import Contexts .Context
15
+ import Contexts .{ Context , ctx }
16
16
import Names .Name
17
17
import NameKinds .{InlineAccessorName , UniqueInlineName }
18
18
import NameOps ._
@@ -32,7 +32,7 @@ object PrepareInlineable {
32
32
* that the inline accessor takes its receiver as first parameter. Such accessors
33
33
* are created by MakeInlineablePassing.
34
34
*/
35
- override def passReceiverAsArg (name : Name )(implicit ctx : Context ): Boolean = name match {
35
+ override def passReceiverAsArg (name : Name )(using Context ): Boolean = name match {
36
36
case InlineAccessorName (UniqueInlineName (_, _)) => true
37
37
case _ => false
38
38
}
@@ -49,23 +49,23 @@ object PrepareInlineable {
49
49
* Constant vals don't need accessors since they are inlined in FirstTransform.
50
50
* Inline methods don't need accessors since they are inlined in Typer.
51
51
*/
52
- def needsAccessor (sym : Symbol )(implicit ctx : Context ): Boolean =
52
+ def needsAccessor (sym : Symbol )(using Context ): Boolean =
53
53
sym.isTerm &&
54
54
(sym.isOneOf(AccessFlags ) || sym.privateWithin.exists) &&
55
55
! sym.isContainedIn(inlineSym) &&
56
56
! (sym.isStableMember && sym.info.widenTermRefExpr.isInstanceOf [ConstantType ]) &&
57
57
! sym.isInlineMethod
58
58
59
- def preTransform (tree : Tree )(implicit ctx : Context ): Tree
59
+ def preTransform (tree : Tree )(using Context ): Tree
60
60
61
- def postTransform (tree : Tree )(implicit ctx : Context ): Tree = tree match {
61
+ def postTransform (tree : Tree )(using Context ): Tree = tree match {
62
62
case Assign (lhs, rhs) if lhs.symbol.name.is(InlineAccessorName ) =>
63
63
cpy.Apply (tree)(useSetter(lhs), rhs :: Nil )
64
64
case _ =>
65
65
tree
66
66
}
67
67
68
- override def transform (tree : Tree )(implicit ctx : Context ): Tree =
68
+ override def transform (tree : Tree )(using Context ): Tree =
69
69
postTransform(super .transform(preTransform(tree)))
70
70
}
71
71
@@ -75,7 +75,7 @@ object PrepareInlineable {
75
75
* by the test that we can find a host for the accessor.
76
76
*/
77
77
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 {
79
79
case tree : RefTree if needsAccessor(tree.symbol) =>
80
80
if (tree.symbol.isConstructor) {
81
81
ctx.error(" Implementation restriction: cannot use private constructors in inlineinline methods" , tree.sourcePos)
@@ -85,7 +85,7 @@ object PrepareInlineable {
85
85
case _ =>
86
86
tree
87
87
}
88
- override def ifNoHost (reference : RefTree )(implicit ctx : Context ): Tree = reference
88
+ override def ifNoHost (reference : RefTree )(using Context ): Tree = reference
89
89
}
90
90
91
91
/** Fallback approach if the direct approach does not work: Place the accessor method
@@ -119,7 +119,7 @@ object PrepareInlineable {
119
119
*/
120
120
class MakeInlineablePassing (inlineSym : Symbol ) extends MakeInlineableMap (inlineSym) {
121
121
122
- def preTransform (tree : Tree )(implicit ctx : Context ): Tree = tree match {
122
+ def preTransform (tree : Tree )(using Context ): Tree = tree match {
123
123
case _ : Apply | _ : TypeApply | _ : RefTree
124
124
if needsAccessor(tree.symbol) && tree.isTerm && ! tree.symbol.isConstructor =>
125
125
val (refPart, targs, argss) = decomposeCall(tree)
@@ -186,7 +186,7 @@ object PrepareInlineable {
186
186
* @return If there are accessors generated, a thicket consisting of the rewritten `tree`
187
187
* and all accessors, otherwise the original tree.
188
188
*/
189
- def makeInlineable (tree : Tree )(implicit ctx : Context ): Tree = {
189
+ def makeInlineable (tree : Tree )(using Context ): Tree = {
190
190
val inlineSym = ctx.owner
191
191
if (inlineSym.owner.isTerm)
192
192
// Inlineable methods in local scopes can only be called in the scope they are defined,
@@ -198,10 +198,10 @@ object PrepareInlineable {
198
198
}
199
199
}
200
200
201
- def isLocalOrParam (sym : Symbol , inlineMethod : Symbol )(implicit ctx : Context ): Boolean =
201
+ def isLocalOrParam (sym : Symbol , inlineMethod : Symbol )(using Context ): Boolean =
202
202
sym.isContainedIn(inlineMethod) && sym != inlineMethod
203
203
204
- def isLocal (sym : Symbol , inlineMethod : Symbol )(implicit ctx : Context ): Boolean =
204
+ def isLocal (sym : Symbol , inlineMethod : Symbol )(using Context ): Boolean =
205
205
isLocalOrParam(sym, inlineMethod) && ! (sym.is(Param ) && sym.owner == inlineMethod)
206
206
207
207
/** The type ascription `rhs: tpt`, unless `original` is `transparent`. */
@@ -218,7 +218,7 @@ object PrepareInlineable {
218
218
* to have the inline method as owner.
219
219
*/
220
220
def registerInlineInfo (
221
- inlined : Symbol , treeExpr : Context ?=> Tree )(implicit ctx : Context ): Unit =
221
+ inlined : Symbol , treeExpr : Context ?=> Tree )(using Context ): Unit =
222
222
inlined.unforcedAnnotation(defn.BodyAnnot ) match {
223
223
case Some (ann : ConcreteBodyAnnotation ) =>
224
224
case Some (ann : LazyBodyAnnotation ) if ann.isEvaluated || ann.isEvaluating =>
@@ -241,7 +241,7 @@ object PrepareInlineable {
241
241
}
242
242
}
243
243
244
- def checkInlineMethod (inlined : Symbol , body : Tree )(implicit ctx : Context ): Unit = {
244
+ def checkInlineMethod (inlined : Symbol , body : Tree )(using Context ): Unit = {
245
245
if (inlined.owner.isClass && inlined.owner.seesOpaques)
246
246
ctx.error(em " Implementation restriction: No inline methods allowed where opaque type aliases are in scope " , inlined.sourcePos)
247
247
if (ctx.outer.inInlineMethod)
0 commit comments