diff options
author | Paul Phillips <paulp@improving.org> | 2013-04-23 07:30:37 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-04-23 19:42:57 -0700 |
commit | fe8280c020eab60a7f94cb1faa50ba412635caea (patch) | |
tree | cf489aa3437a798994dde8d8407ff2aefa806d3c | |
parent | 5ec9dbd6a983778b3765d2da36b208081896ad8e (diff) | |
download | scala-fe8280c020eab60a7f94cb1faa50ba412635caea.tar.gz scala-fe8280c020eab60a7f94cb1faa50ba412635caea.tar.bz2 scala-fe8280c020eab60a7f94cb1faa50ba412635caea.zip |
Added orElse to Type.
Tree and Symbol each have the analogous method, so consistency
calls along with utility for putting it on Type.
-rw-r--r-- | src/reflect/scala/reflect/api/Types.scala | 6 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala index 1152f97350..0291d5d26f 100644 --- a/src/reflect/scala/reflect/api/Types.scala +++ b/src/reflect/scala/reflect/api/Types.scala @@ -209,6 +209,12 @@ trait Types { /******************* helpers *******************/ + /** Provides an alternate if type is NoType. + * + * @group Helpers + */ + def orElse(alt: => Type): Type + /** Substitute symbols in `to` for corresponding occurrences of references to * symbols `from` in this type. */ diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index cd41f533bb..86115e7174 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -742,6 +742,8 @@ trait Types def map[T](f: Type => T): List[T] = collect(Type.this) map f } + @inline final def orElse(alt: => Type): Type = if (this ne NoType) this else alt + /** Returns optionally first type (in a preorder traversal) which satisfies predicate `p`, * or None if none exists. */ |