@@ -920,10 +920,16 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
920
920
untpd.Select (tree, OuterSelectName (EmptyTermName , levels)).withType(SkolemType (tp))
921
921
922
922
/** Replace Inlined nodes and InlineProxy references to underlying arguments */
923
- def underlyingArgument (implicit ctx : Context ): Tree = mapToUnderlyingArgument.transform(tree)
923
+ def underlyingArgument (implicit ctx : Context ): Tree = {
924
+ val mapToUnderlying = new MapToUnderlying {
925
+ override def skipLocal (sym : Symbol ): Boolean =
926
+ sym.is(InlineProxy ) || sym.is(Synthetic )
927
+ }
928
+ mapToUnderlying.transform(tree)
929
+ }
924
930
925
931
/** Replace Ident nodes references to the underlying tree that defined them */
926
- def underlying (implicit ctx : Context ): Tree = mapToUnderlying .transform(tree)
932
+ def underlying (implicit ctx : Context ): Tree = new MapToUnderlying () .transform(tree)
927
933
928
934
// --- Higher order traversal methods -------------------------------
929
935
@@ -951,26 +957,12 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
951
957
}
952
958
}
953
959
954
- /** Map Inlined nodes, InlineProxy references and Synthetic val references to underlying arguments */
955
- object mapToUnderlyingArgument extends TreeMap {
956
- override def transform (tree : Tree )(implicit ctx : Context ): Tree = tree match {
957
- case tree : Ident if tree.symbol.is(InlineProxy ) || (tree.symbol.is(Synthetic ) && ! tree.symbol.owner.isClass) =>
958
- tree.symbol.defTree match {
959
- case defTree : ValOrDefDef => transform(defTree.rhs)
960
- case _ => tree
961
- }
962
- case Inlined (_, _, arg) => transform(arg)
963
- case NamedArg (_, arg) => transform(arg)
964
- case tree => super .transform(tree)
965
- }
966
- }
967
-
968
- /** Map Ident nodes references to underlying tree that defined them.
969
- * Also drops Inline and Block with no statements
960
+ /** Map Inlined nodes, NamedArgs, Blocks with no statements and local references to underlying arguments.
961
+ * Also drops Inline and Block with no statements.
970
962
*/
971
- object mapToUnderlying extends TreeMap {
963
+ class MapToUnderlying extends TreeMap {
972
964
override def transform (tree : Tree )(implicit ctx : Context ): Tree = tree match {
973
- case tree : Ident if ! tree.symbol.owner.isClass =>
965
+ case tree : Ident if ! tree.symbol.owner.isClass && skipLocal(tree.symbol) =>
974
966
tree.symbol.defTree match {
975
967
case defTree : ValOrDefDef => transform(defTree.rhs)
976
968
case _ => tree
@@ -980,6 +972,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
980
972
case NamedArg (_, arg) => transform(arg)
981
973
case tree => super .transform(tree)
982
974
}
975
+ def skipLocal (sym : Symbol ): Boolean = true
983
976
}
984
977
985
978
implicit class ListOfTreeDecorator (val xs : List [tpd.Tree ]) extends AnyVal {
0 commit comments