@@ -15,7 +15,7 @@ import StdNames.nme
1515import Contexts .Context
1616import Names .{Name , TermName , EmptyTermName }
1717import NameOps ._
18- import NameKinds .{ClassifiedNameKind , InlineAccessorName }
18+ import NameKinds .{ClassifiedNameKind , InlineAccessorName , UniqueName }
1919import ProtoTypes .selectionProto
2020import SymDenotations .SymDenotation
2121import Annotations ._
@@ -63,23 +63,13 @@ object Inliner {
6363 // This is quite tricky, as such types can appear anywhere, including as parts
6464 // of types of other things. For the moment we do nothing and complain
6565 // at the implicit expansion site if there's a reference to an inaccessible type.
66- override def transform (tree : Tree )(implicit ctx : Context ): Tree = tree match {
67- case tree : Assign =>
68- transform(tree.lhs) match {
69- case lhs1 : RefTree =>
70- lhs1.name match {
71- case InlineAccessorName (name) =>
72- cpy.Apply (tree)(useSetter(lhs1), transform(tree.rhs) :: Nil )
73- case _ =>
74- super .transform(tree)
75- }
76- case _ =>
77- super .transform(tree)
78- }
79- case _ =>
80- super .transform(accessorIfNeeded(tree))
81- }
82-
66+ override def transform (tree : Tree )(implicit ctx : Context ): Tree =
67+ super .transform(accessorIfNeeded(tree)) match {
68+ case tree1 @ Assign (lhs : RefTree , rhs) if lhs.symbol.name.is(InlineAccessorName ) =>
69+ cpy.Apply (tree1)(useSetter(lhs), rhs :: Nil )
70+ case tree1 =>
71+ tree1
72+ }
8373 }
8474
8575 /** Adds accessors for all non-public term members accessed
@@ -391,7 +381,8 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
391381 case _ => tree
392382 }}
393383
394- val inlineCtx = inlineContext(call)
384+ val inlineTyper = new InlineTyper
385+ val inlineCtx = inlineContext(call).fresh.setTyper(inlineTyper).setNewScope
395386 // The complete translation maps references to `this` and parameters to
396387 // corresponding arguments or proxies on the type and term level. It also changes
397388 // the owner from the inlined method to the current owner.
@@ -401,7 +392,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
401392 trace(i " inlining $call\n , BINDINGS = \n ${bindingsBuf.toList}% \n % \n EXPANSION = \n $expansion" , inlining, show = true ) {
402393
403394 // The final expansion runs a typing pass over the inlined tree. See InlineTyper for details.
404- val expansion1 = InlineTyper .typed(expansion, pt)(inlineCtx)
395+ val expansion1 = inlineTyper .typed(expansion, pt)(inlineCtx)
405396
406397 /** All bindings in `bindingsBuf` except bindings of inlineable closures */
407398 val bindings = bindingsBuf.toList.map(_.withPos(call.pos))
@@ -421,8 +412,8 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
421412 */
422413 private object InlineableArg {
423414 lazy val paramProxies = paramProxy.values.toSet
424- def unapply (tree : Ident )(implicit ctx : Context ): Option [Tree ] =
425- if (paramProxies.contains(tree.tpe ))
415+ def unapply (tree : Trees . Ident [_] )(implicit ctx : Context ): Option [Tree ] =
416+ if (paramProxies.contains(tree.typeOpt ))
426417 bindingsBuf.find(_.name == tree.name) match {
427418 case Some (vdef : ValDef ) if vdef.symbol.is(Inline ) =>
428419 Some (vdef.rhs.changeOwner(vdef.symbol, ctx.owner))
@@ -440,7 +431,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
440431 * 4. Make sure inlined code is type-correct.
441432 * 5. Make sure that the tree's typing is idempotent (so that future -Ycheck passes succeed)
442433 */
443- private object InlineTyper extends ReTyper {
434+ private class InlineTyper extends ReTyper {
444435
445436 override def ensureAccessible (tpe : Type , superAccess : Boolean , pos : Position )(implicit ctx : Context ): Type = {
446437 tpe match {
@@ -507,6 +498,8 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
507498
508499 betaReduce(super .typedApply(tree, pt))
509500 }
501+
502+ override def newLikeThis : Typer = new InlineTyper
510503 }
511504
512505 /** Drop any side-effect-free bindings that are unused in expansion or other reachable bindings.
0 commit comments