@@ -914,10 +914,16 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
914914 untpd.Select (tree, OuterSelectName (EmptyTermName , levels)).withType(SkolemType (tp))
915915
916916 /** Replace Inlined nodes and InlineProxy references to underlying arguments */
917- def underlyingArgument (implicit ctx : Context ): Tree = mapToUnderlyingArgument.transform(tree)
917+ def underlyingArgument (implicit ctx : Context ): Tree = {
918+ val mapToUnderlying = new MapToUnderlying {
919+ override def skipLocal (sym : Symbol ): Boolean =
920+ sym.is(InlineProxy ) || sym.is(Synthetic )
921+ }
922+ mapToUnderlying.transform(tree)
923+ }
918924
919925 /** Replace Ident nodes references to the underlying tree that defined them */
920- def underlying (implicit ctx : Context ): Tree = mapToUnderlying .transform(tree)
926+ def underlying (implicit ctx : Context ): Tree = new MapToUnderlying () .transform(tree)
921927
922928 // --- Higher order traversal methods -------------------------------
923929
@@ -945,26 +951,12 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
945951 }
946952 }
947953
948- /** Map Inlined nodes, InlineProxy references and Synthetic val references to underlying arguments */
949- object mapToUnderlyingArgument extends TreeMap {
950- override def transform (tree : Tree )(implicit ctx : Context ): Tree = tree match {
951- case tree : Ident if tree.symbol.is(InlineProxy ) || (tree.symbol.is(Synthetic ) && ! tree.symbol.owner.isClass) =>
952- tree.symbol.defTree match {
953- case defTree : ValOrDefDef => transform(defTree.rhs)
954- case _ => tree
955- }
956- case Inlined (_, _, arg) => transform(arg)
957- case NamedArg (_, arg) => transform(arg)
958- case tree => super .transform(tree)
959- }
960- }
961-
962- /** Map Ident nodes references to underlying tree that defined them.
963- * Also drops Inline and Block with no statements
954+ /** Map Inlined nodes, NamedArgs, Blocks with no statements and local references to underlying arguments.
955+ * Also drops Inline and Block with no statements.
964956 */
965- object mapToUnderlying extends TreeMap {
957+ class MapToUnderlying extends TreeMap {
966958 override def transform (tree : Tree )(implicit ctx : Context ): Tree = tree match {
967- case tree : Ident if ! tree.symbol.owner.isClass =>
959+ case tree : Ident if ! tree.symbol.owner.isClass && skipLocal(tree.symbol) =>
968960 tree.symbol.defTree match {
969961 case defTree : ValOrDefDef => transform(defTree.rhs)
970962 case _ => tree
@@ -974,6 +966,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
974966 case NamedArg (_, arg) => transform(arg)
975967 case tree => super .transform(tree)
976968 }
969+ def skipLocal (sym : Symbol ): Boolean = true
977970 }
978971
979972 implicit class ListOfTreeDecorator (val xs : List [tpd.Tree ]) extends AnyVal {
0 commit comments