summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/internal/Types.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-11-23 23:09:30 +0000
committerPaul Phillips <paulp@improving.org>2011-11-23 23:09:30 +0000
commit4cfca8a7f6763fbbaab37a3473d74118b3ec52bc (patch)
tree0fcd94312cbb08a4c58add11a8cc51bd0c0c9b6a /src/compiler/scala/reflect/internal/Types.scala
parent8e965f00e472398b466bc08da1a2d25f4566a670 (diff)
downloadscala-4cfca8a7f6763fbbaab37a3473d74118b3ec52bc.tar.gz
scala-4cfca8a7f6763fbbaab37a3473d74118b3ec52bc.tar.bz2
scala-4cfca8a7f6763fbbaab37a3473d74118b3ec52bc.zip
AnnotationInfo inertia takes me into continuati...
AnnotationInfo inertia takes me into continuations. And kept carrying me until I was carried away. The changes are mostly of the janitorial variety, just doing my part to make the interesting logic visible without being buried in low level compiler plumbing. Added at least one seriously convenient convenience method: tree modifyType fn // equivalent to if (tree.tpe == null) tree else tree setType fn(tree.tpe) This is the analogue to the recently added: symbol modifyInfo fn // same idea It's like having our carpets steam cleaned when we can keep pushing until machinery stays in the machine and the relevant logic stands gloriously on top. You'll eventually exclaim, "I didn't even know these carpets were that color!"
Diffstat (limited to 'src/compiler/scala/reflect/internal/Types.scala')
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index 88019f51f7..0f8d28ff03 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -1022,11 +1022,10 @@ trait Types extends api.Types { self: SymbolTable =>
// overrides these.
def annotations: List[AnnotationInfo] = Nil
def withoutAnnotations: Type = this
+ def filterAnnotations(p: AnnotationInfo => Boolean): Type = this
def setAnnotations(annots: List[AnnotationInfo]): Type = annotatedType(annots, this)
def withAnnotations(annots: List[AnnotationInfo]): Type = annotatedType(annots, this)
- final def withAnnotation(annot: AnnotationInfo): Type = withAnnotations(List(annot))
-
/** Remove any annotations from this type and from any
* types embedded in this type. */
def stripAnnotations = StripAnnotationsMap(this)
@@ -2715,8 +2714,14 @@ A type's typeSymbol should never be inspected directly.
override def safeToString = annotations.mkString(underlying + " @", " @", "")
+ override def filterAnnotations(p: AnnotationInfo => Boolean): Type = {
+ val (yes, no) = annotations partition p
+ if (yes.isEmpty) underlying
+ else if (no.isEmpty) this
+ else copy(annotations = yes)
+ }
override def setAnnotations(annots: List[AnnotationInfo]): Type =
- if (annots.isEmpty) withoutAnnotations
+ if (annots.isEmpty) underlying
else copy(annotations = annots)
/** Add a number of annotations to this type */
@@ -2724,7 +2729,11 @@ A type's typeSymbol should never be inspected directly.
if (annots.isEmpty) this
else copy(annots ::: this.annotations)
- /** Remove any annotations from this type */
+ /** Remove any annotations from this type.
+ * TODO - is it allowed to nest AnnotatedTypes? If not then let's enforce
+ * that at creation. At the moment if they do ever turn up nested this
+ * recursively calls withoutAnnotations.
+ */
override def withoutAnnotations = underlying.withoutAnnotations
/** Set the self symbol */