summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-04-23 07:30:37 -0700
committerPaul Phillips <paulp@improving.org>2013-04-23 19:42:57 -0700
commitfe8280c020eab60a7f94cb1faa50ba412635caea (patch)
treecf489aa3437a798994dde8d8407ff2aefa806d3c /src
parent5ec9dbd6a983778b3765d2da36b208081896ad8e (diff)
downloadscala-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.
Diffstat (limited to 'src')
-rw-r--r--src/reflect/scala/reflect/api/Types.scala6
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala2
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.
*/