diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-03-16 16:58:00 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-03-16 16:58:00 +0100 |
commit | fd1214cfff0bf8a257a85e1ef44047ed6de000a2 (patch) | |
tree | 4452681787122e8357844e972e40de3b6f150f04 /src | |
parent | 027abb4de0710b17ba92499f231d0b0d6467831a (diff) | |
download | dotty-fd1214cfff0bf8a257a85e1ef44047ed6de000a2.tar.gz dotty-fd1214cfff0bf8a257a85e1ef44047ed6de000a2.tar.bz2 dotty-fd1214cfff0bf8a257a85e1ef44047ed6de000a2.zip |
Test case for TreeInfo#defPath
I'm about to refactor that method in terms of a TreeAccumulator.
Note that I've packaged the test case in `dotty.tools.dotc.ast`
I believe this is the best approach for organizing unit tests:
the import tax is minimized, and use of relative imports is
made less fragile by avoiding creating new packages to test code.
I'll reorganize the other unit tests like this if others agree.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/ast/tpd.scala | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index 0dce4c324..4de98d8f8 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -330,6 +330,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { def deepFold[T](z: T)(op: (T, tpd.Tree) => T) = new DeepFolder(op).apply(z, tree) + def find[T](pred: (tpd.Tree) => Boolean): Option[tpd.Tree] = + shallowFold[Option[tpd.Tree]](None)((accum, tree) => if (pred(tree)) Some(tree) else accum) + def subst(from: List[Symbol], to: List[Symbol])(implicit ctx: Context): ThisTree = new TreeMapper(typeMap = new ctx.SubstSymMap(from, to)).apply(tree) |