summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/internal/Types.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-12-05 23:10:16 -0800
committerPaul Phillips <paulp@improving.org>2011-12-07 11:45:49 -0800
commit21773d31c1e15d2eec3cf2c8623d582be0a8e4ca (patch)
tree1e6c8f2239df1af2fb62b6ae0890dcffd6d24873 /src/compiler/scala/reflect/internal/Types.scala
parent33f3c60ce1931b450053ba4635f7227727aed668 (diff)
downloadscala-21773d31c1e15d2eec3cf2c8623d582be0a8e4ca.tar.gz
scala-21773d31c1e15d2eec3cf2c8623d582be0a8e4ca.tar.bz2
scala-21773d31c1e15d2eec3cf2c8623d582be0a8e4ca.zip
More warnings eliminations.
Deprecation warnings, unchecked warnings, "that's not the value you think it is" warnings. Also eliminated a warning by fixing a warning bug.
Diffstat (limited to 'src/compiler/scala/reflect/internal/Types.scala')
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index 265261f594..d17747e22a 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -649,7 +649,11 @@ trait Types extends api.Types { self: SymbolTable =>
}
/** Returns all parts of this type which satisfy predicate `p` */
- def filter(p: Type => Boolean): List[Type] = new FilterTypeCollector(p).collect(this).toList
+ def filter(p: Type => Boolean): List[Type] = new FilterTypeCollector(p) collect this
+ def withFilter(p: Type => Boolean) = new FilterTypeCollector(p) {
+ def foreach[U](f: Type => U): Unit = collect(Type.this) foreach f
+ def map[T](f: Type => T): List[T] = collect(Type.this) map f
+ }
/** Returns optionally first type (in a preorder traversal) which satisfies predicate `p`,
* or None if none exists.
@@ -4094,9 +4098,13 @@ A type's typeSymbol should never be inspected directly.
}
/** A map to implement the `filter` method. */
- class FilterTypeCollector(p: Type => Boolean) extends TypeCollector(new ListBuffer[Type]) {
+ class FilterTypeCollector(p: Type => Boolean) extends TypeCollector[List[Type]](Nil) {
+ def withFilter(q: Type => Boolean) = new FilterTypeCollector(tp => p(tp) && q(tp))
+
+ override def collect(tp: Type) = super.collect(tp).reverse
+
def traverse(tp: Type) {
- if (p(tp)) result += tp
+ if (p(tp)) result ::= tp
mapOver(tp)
}
}