@@ -40,15 +40,19 @@ object Inliner {
40
40
private def makeInlineable (tree : Tree )(implicit ctx : Context ) = {
41
41
42
42
/** A tree map which inserts accessors for all non-public term members accessed
43
- * from inlined code. Accesors are collected in the `accessors` buffer.
43
+ * from inlined code. Accessors are collected in the `accessors` buffer.
44
44
*/
45
45
object addAccessors extends TreeMap {
46
46
val inlineMethod = ctx.owner
47
47
val accessors = new mutable.ListBuffer [MemberDef ]
48
48
49
- /** A definition needs an accessor if it is private, protected, or qualified private */
49
+ /** A definition needs an accessor if it is private, protected, or qualified private
50
+ * and it is not part of the tree that gets inlined. The latter test is implemented
51
+ * by excluding all symbols properly contained in the inlined method.
52
+ */
50
53
def needsAccessor (sym : Symbol )(implicit ctx : Context ) =
51
- sym.is(AccessFlags ) || sym.privateWithin.exists
54
+ (sym.is(AccessFlags ) || sym.privateWithin.exists) &&
55
+ ! sym.owner.isContainedIn(inlineMethod)
52
56
53
57
/** The name of the next accessor to be generated */
54
58
def accessorName (implicit ctx : Context ) = InlineAccessorName .fresh(inlineMethod.name.asTermName)
@@ -359,13 +363,15 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
359
363
360
364
private def canElideThis (tpe : ThisType ): Boolean =
361
365
prefix.tpe == tpe && ctx.owner.isContainedIn(tpe.cls) ||
366
+ tpe.cls.isContainedIn(meth) ||
362
367
tpe.cls.is(Package )
363
368
364
369
/** Populate `thisProxy` and `paramProxy` as follows:
365
370
*
366
371
* 1a. If given type refers to a static this, thisProxy binds it to corresponding global reference,
367
- * 1b. If given type refers to an instance this, create a proxy symbol and bind the thistype to
368
- * refer to the proxy. The proxy is not yet entered in `bindingsBuf` that will come later.
372
+ * 1b. If given type refers to an instance this to a class that is not contained in the
373
+ * inlined method, create a proxy symbol and bind the thistype to refer to the proxy.
374
+ * The proxy is not yet entered in `bindingsBuf`; that will come later.
369
375
* 2. If given type refers to a parameter, make `paramProxy` refer to the entry stored
370
376
* in `paramNames` under the parameter's name. This roundabout way to bind parameter
371
377
* references to proxies is done because we not known a priori what the parameter
0 commit comments