summaryrefslogtreecommitdiff
path: root/src/library/scala/reflect/package.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scala/reflect/package.scala')
-rw-r--r--src/library/scala/reflect/package.scala58
1 files changed, 9 insertions, 49 deletions
diff --git a/src/library/scala/reflect/package.scala b/src/library/scala/reflect/package.scala
index 38a144cd49..ba93a1c91f 100644
--- a/src/library/scala/reflect/package.scala
+++ b/src/library/scala/reflect/package.scala
@@ -1,42 +1,8 @@
package scala
-package object reflect {
+package object reflect extends reflect_compat {
- import ReflectionUtils._
- import scala.compat.Platform.EOL
-
- // !!! This was a val; we can't throw exceptions that aggressively without breaking
- // non-standard environments, e.g. google app engine. I made it a lazy val, but
- // I think it would be better yet to throw the exception somewhere else - not during
- // initialization, but in response to a doomed attempt to utilize it.
-
- // todo. default mirror (a static object) might become a source for memory leaks (because it holds a strong reference to a classloader)!
- lazy val mirror: api.Mirror =
- try mkMirror(defaultReflectionClassLoader)
- catch {
- case ex: UnsupportedOperationException =>
- new DummyMirror(defaultReflectionClassLoader)
- }
-
- private[scala] def mirrorDiagnostics(cl: ClassLoader): String = """
- |
- | This error has happened because `scala.reflect.runtime.package` located in
- | scala-compiler.jar cannot be loaded. Classloader you are using is:
- | %s.
- |
- | For the instructions for some of the situations that might be relevant
- | visit our knowledge base at https://gist.github.com/2391081.
- """.stripMargin('|').format(show(cl))
-
- def mkMirror(classLoader: ClassLoader): api.Mirror = {
- val coreClassLoader = getClass.getClassLoader
- val instance = invokeFactoryOpt(coreClassLoader, "scala.reflect.runtime.package", "mkMirror", classLoader)
- instance match {
- case Some(x: api.Mirror) => x
- case Some(_) => throw new UnsupportedOperationException("Available scala reflection implementation is incompatible with this interface." + mirrorDiagnostics(coreClassLoader))
- case None => throw new UnsupportedOperationException("Scala reflection not available on this platform." + mirrorDiagnostics(coreClassLoader))
- }
- }
+ lazy val basis: base.Universe = new base.Base
@deprecated("Use `@scala.beans.BeanDescription` instead", "2.10.0")
type BeanDescription = scala.beans.BeanDescription
@@ -53,18 +19,12 @@ package object reflect {
@deprecated("Use `@scala.beans.ScalaBeanInfo` instead", "2.10.0")
type ScalaBeanInfo = scala.beans.ScalaBeanInfo
- // ArrayTag trait is defined separately from the mirror
- // ErasureTag trait is defined separately from the mirror
- // ConcreteErasureTag trait is defined separately from the mirror
- // ClassTag class is defined separately from the mirror
- type TypeTag[T] = scala.reflect.mirror.TypeTag[T]
- type ConcreteTypeTag[T] = scala.reflect.mirror.ConcreteTypeTag[T]
-
- // ClassTag object is defined separately from the mirror
- lazy val TypeTag = scala.reflect.mirror.TypeTag
- lazy val ConcreteTypeTag = scala.reflect.mirror.ConcreteTypeTag
+ // ArrayTag trait is defined outside the basis
+ // ClassTag class is defined outside the basis
+ type TypeTag[T] = scala.reflect.basis.TypeTag[T]
+ type ConcreteTypeTag[T] = scala.reflect.basis.ConcreteTypeTag[T]
- def arrayTagToClassManifest[T](tag: ArrayTag[T]): ClassManifest[T] = TagInterop.arrayTagToClassManifest[T](tag)
- def concreteTypeTagToManifest[T](tag: ConcreteTypeTag[T]): Manifest[T] = TagInterop.concreteTypeTagToManifest[T](tag)
- def manifestToConcreteTypeTag[T](tag: Manifest[T]): ConcreteTypeTag[T] = TagInterop.manifestToConcreteTypeTag[T](tag)
+ // ClassTag object is defined outside the basis
+ lazy val TypeTag = scala.reflect.basis.TypeTag
+ lazy val ConcreteTypeTag = scala.reflect.basis.ConcreteTypeTag
}