@@ -914,10 +914,16 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
914
914
untpd.Select (tree, OuterSelectName (EmptyTermName , levels)).withType(SkolemType (tp))
915
915
916
916
/** 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
+ }
918
924
919
925
/** 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)
921
927
922
928
// --- Higher order traversal methods -------------------------------
923
929
@@ -945,26 +951,12 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
945
951
}
946
952
}
947
953
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.
964
956
*/
965
- object mapToUnderlying extends TreeMap {
957
+ class MapToUnderlying extends TreeMap {
966
958
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) =>
968
960
tree.symbol.defTree match {
969
961
case defTree : ValOrDefDef => transform(defTree.rhs)
970
962
case _ => tree
@@ -974,6 +966,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
974
966
case NamedArg (_, arg) => transform(arg)
975
967
case tree => super .transform(tree)
976
968
}
969
+ def skipLocal (sym : Symbol ): Boolean = true
977
970
}
978
971
979
972
implicit class ListOfTreeDecorator (val xs : List [tpd.Tree ]) extends AnyVal {
0 commit comments