diff options
author | Martin Odersky <odersky@gmail.com> | 2014-10-24 18:32:48 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-10-26 16:24:02 +0100 |
commit | 3a250720a0833d42ed6b23b5837de64b6ce34aed (patch) | |
tree | 008c0b58a9f598da559286deb3fd9f8ab94a2d55 /src/dotty/tools/dotc/ast/tpd.scala | |
parent | 4d370b6073bec9706d427f82c4a6a40fa22fe6d0 (diff) | |
download | dotty-3a250720a0833d42ed6b23b5837de64b6ce34aed.tar.gz dotty-3a250720a0833d42ed6b23b5837de64b6ce34aed.tar.bz2 dotty-3a250720a0833d42ed6b23b5837de64b6ce34aed.zip |
Add missing and double symbol checking to TreeChecker
TreeChecker now tests that a symbol does not have two definitions that define it,
and that every reference to a symbol owner by a term is in the scope of a definition
of that symbol.
Both tests fail on several files for pattern matcher.
Diffstat (limited to 'src/dotty/tools/dotc/ast/tpd.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/tpd.scala | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index 9b7c9cbae..4c21fcf49 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -9,6 +9,7 @@ import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._, Symbols. import Denotations._, Decorators._ import config.Printers._ import typer.Mode +import collection.mutable import typer.ErrorReporting._ import scala.annotation.tailrec @@ -620,6 +621,12 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { } acc(false, tree) } + + def filterSubTrees(f: Tree => Boolean): List[Tree] = { + val buf = new mutable.ListBuffer[Tree] + foreachSubTree { tree => if (f(tree)) buf += tree } + buf.toList + } } implicit class ListOfTreeDecorator(val xs: List[tpd.Tree]) extends AnyVal { |