summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/api/Constants.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-09-19 15:04:50 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-09-19 22:47:10 +0200
commit3fa900ca0ea244ac54df75dc2fd6d711739eface (patch)
treebd37a549da114d7030a7cbce14ecc527058dd1ad /src/reflect/scala/reflect/api/Constants.scala
parenteadf1d2080e0ce763e4c1920a26b80c8b8609ca0 (diff)
downloadscala-3fa900ca0ea244ac54df75dc2fd6d711739eface.tar.gz
scala-3fa900ca0ea244ac54df75dc2fd6d711739eface.tar.bz2
scala-3fa900ca0ea244ac54df75dc2fd6d711739eface.zip
SI-6363 removes scala.reflect.base
As the experience has shown, there's no need for a separate layer of reflection in scala-library.jar. Therefore I'm putting an end to it.
Diffstat (limited to 'src/reflect/scala/reflect/api/Constants.scala')
-rw-r--r--src/reflect/scala/reflect/api/Constants.scala27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/api/Constants.scala b/src/reflect/scala/reflect/api/Constants.scala
index 6657245003..f2d8ef2eb9 100644
--- a/src/reflect/scala/reflect/api/Constants.scala
+++ b/src/reflect/scala/reflect/api/Constants.scala
@@ -6,10 +6,33 @@
package scala.reflect
package api
-trait Constants extends base.Constants {
+/**
+ * Defines the type hierachy for compile-time constants.
+ *
+ * @see [[scala.reflect]] for a description on how the class hierarchy is encoded here.
+ */
+trait Constants {
self: Universe =>
- override type Constant >: Null <: AnyRef with ConstantApi
+ /** The type of compile-time constants.
+ */
+ type Constant >: Null <: AnyRef with ConstantApi
+
+ /** A tag that preserves the identity of the `Constant` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ConstantTag: ClassTag[Constant]
+
+ /** The constructor/deconstructor for `Constant` instances. */
+ val Constant: ConstantExtractor
+
+ /** An extractor class to create and pattern match with syntax `Constant(value)`
+ * where `value` is the Scala value of the constant.
+ */
+ abstract class ConstantExtractor {
+ def apply(value: Any): Constant
+ def unapply(arg: Constant): Option[Any]
+ }
abstract class ConstantApi {
val value: Any