@@ -53,23 +53,13 @@ object Inliner {
53
53
// This is quite tricky, as such types can appear anywhere, including as parts
54
54
// of types of other things. For the moment we do nothing and complain
55
55
// at the implicit expansion site if there's a reference to an inaccessible type.
56
- override def transform (tree : Tree )(implicit ctx : Context ): Tree = tree match {
57
- case tree : Assign =>
58
- transform(tree.lhs) match {
59
- case lhs1 : RefTree =>
60
- lhs1.name match {
61
- case InlineAccessorName (name) =>
62
- cpy.Apply (tree)(useSetter(lhs1), transform(tree.rhs) :: Nil )
63
- case _ =>
64
- super .transform(tree)
65
- }
66
- case _ =>
67
- super .transform(tree)
68
- }
69
- case _ =>
70
- super .transform(accessorIfNeeded(tree))
71
- }
72
-
56
+ override def transform (tree : Tree )(implicit ctx : Context ): Tree =
57
+ super .transform(accessorIfNeeded(tree)) match {
58
+ case tree1 @ Assign (lhs : RefTree , rhs) if lhs.symbol.name.is(InlineAccessorName ) =>
59
+ cpy.Apply (tree1)(useSetter(lhs), rhs :: Nil )
60
+ case tree1 =>
61
+ tree1
62
+ }
73
63
}
74
64
75
65
/** Adds accessors for all non-public term members accessed
@@ -104,14 +94,14 @@ object Inliner {
104
94
* to have the inlined method as owner.
105
95
*/
106
96
def registerInlineInfo (
107
- sym : SymDenotation , treeExpr : Context => Tree )(implicit ctx : Context ): Unit = {
108
- sym .unforcedAnnotation(defn.BodyAnnot ) match {
97
+ inlined : Symbol , treeExpr : Context => Tree )(implicit ctx : Context ): Unit = {
98
+ inlined .unforcedAnnotation(defn.BodyAnnot ) match {
109
99
case Some (ann : ConcreteBodyAnnotation ) =>
110
100
case Some (ann : LazyBodyAnnotation ) if ann.isEvaluated =>
111
101
case _ =>
112
102
if (! ctx.isAfterTyper) {
113
103
val inlineCtx = ctx
114
- sym .updateAnnotation(LazyBodyAnnotation { _ =>
104
+ inlined .updateAnnotation(LazyBodyAnnotation { _ =>
115
105
implicit val ctx = inlineCtx
116
106
val body = treeExpr(ctx)
117
107
if (ctx.reporter.hasErrors) body else ctx.compilationUnit.inlineAccessors.makeInlineable(body)
@@ -173,10 +163,10 @@ object Inliner {
173
163
174
164
/** Produces an inlined version of `call` via its `inlined` method.
175
165
*
176
- * @param call The original call to a `@inline` method
177
- * @param rhs The body of the inline method that replaces the call.
166
+ * @param call the original call to a `@inline` method
167
+ * @param rhsToInline the body of the inline method that replaces the call.
178
168
*/
179
- class Inliner (call : tpd.Tree , rhs : tpd.Tree )(implicit ctx : Context ) {
169
+ class Inliner (call : tpd.Tree , rhsToInline : tpd.Tree )(implicit ctx : Context ) {
180
170
import tpd ._
181
171
import Inliner ._
182
172
@@ -200,7 +190,7 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
200
190
*/
201
191
private val paramProxy = new mutable.HashMap [Type , Type ]
202
192
203
- /** A map from the classes of (direct and outer) this references in `rhs `
193
+ /** A map from the classes of (direct and outer) this references in `rhsToInline `
204
194
* to references of their proxies.
205
195
* Note that we can't index by the ThisType itself since there are several
206
196
* possible forms to express what is logicaly the same ThisType. E.g.
@@ -315,7 +305,7 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
315
305
if (! isIdempotentExpr(prefix)) registerType(meth.owner.thisType)
316
306
317
307
// Register types of all leaves of inlined body so that the `paramProxy` and `thisProxy` maps are defined.
318
- rhs .foreachSubTree(registerLeaf)
308
+ rhsToInline .foreachSubTree(registerLeaf)
319
309
320
310
// The class that the this-proxy `selfSym` represents
321
311
def classOf (selfSym : Symbol ) = selfSym.info.widen.classSymbol
@@ -387,7 +377,7 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
387
377
// the owner from the inlined method to the current owner.
388
378
val inliner = new TreeTypeMap (typeMap, treeMap, meth :: Nil , ctx.owner :: Nil )(inlineCtx)
389
379
390
- val expansion = inliner(rhs .withPos(call.pos))
380
+ val expansion = inliner(rhsToInline .withPos(call.pos))
391
381
trace(i " inlining $call\n , BINDINGS = \n ${bindingsBuf.toList}% \n % \n EXPANSION = \n $expansion" , inlining, show = true ) {
392
382
393
383
// The final expansion runs a typing pass over the inlined tree. See InlineTyper for details.
@@ -426,7 +416,7 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
426
416
/** A typer for inlined code. Its purpose is:
427
417
* 1. Implement constant folding over inlined code
428
418
* 2. Selectively expand ifs with constant conditions
429
- * 3. Inline arguments that are inlineable closures
419
+ * 3. Inline arguments that are by-name closures
430
420
* 4. Make sure inlined code is type-correct.
431
421
* 5. Make sure that the tree's typing is idempotent (so that future -Ycheck passes succeed)
432
422
*/
0 commit comments