summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2011-11-10 16:37:36 +0000
committerMartin Odersky <odersky@gmail.com>2011-11-10 16:37:36 +0000
commit7121c6a8db65b20667bcb75e77b72c997afe2fde (patch)
tree53efba92694bf8e0c4ff59ad9766f2a65dd11585 /src/library
parent7876a574d5d9141230113b6bbeb13f00d072c4f1 (diff)
downloadscala-7121c6a8db65b20667bcb75e77b72c997afe2fde.tar.gz
scala-7121c6a8db65b20667bcb75e77b72c997afe2fde.tar.bz2
scala-7121c6a8db65b20667bcb75e77b72c997afe2fde.zip
(1) Made ReflectionUtils an object, to take its...
(1) Made ReflectionUtils an object, to take its members out of the reflect package. (2) Removed old Type/Symbol/Tree from reflect package. (3) Got scratchpad to work better. Review by extempore.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/reflect/ReflectionUtils.scala4
-rw-r--r--src/library/scala/reflect/package.scala8
2 files changed, 6 insertions, 6 deletions
diff --git a/src/library/scala/reflect/ReflectionUtils.scala b/src/library/scala/reflect/ReflectionUtils.scala
index c2f89102cb..b63a8645de 100644
--- a/src/library/scala/reflect/ReflectionUtils.scala
+++ b/src/library/scala/reflect/ReflectionUtils.scala
@@ -9,7 +9,7 @@ import java.lang.reflect.{ InvocationTargetException, UndeclaredThrowableExcepti
/** A few java-reflection oriented utility functions useful during reflection bootstrapping.
*/
-trait ReflectionUtils {
+object ReflectionUtils {
// Unwraps some chained exceptions which arise during reflective calls.
def unwrapThrowable(x: Throwable): Throwable = x match {
case _: InvocationTargetException | // thrown by reflectively invoked method or constructor
@@ -23,7 +23,7 @@ trait ReflectionUtils {
}
// Transforms an exception handler into one which will only receive the unwrapped
// exceptions (for the values of wrap covered in unwrapThrowable.)
- def unwrapForHandler[T](pf: PartialFunction[Throwable, T]): PartialFunction[Throwable, T] = {
+ def unwrapHandler[T](pf: PartialFunction[Throwable, T]): PartialFunction[Throwable, T] = {
case ex if pf isDefinedAt unwrapThrowable(ex) => pf(unwrapThrowable(ex))
}
diff --git a/src/library/scala/reflect/package.scala b/src/library/scala/reflect/package.scala
index d18924c409..62592baa27 100644
--- a/src/library/scala/reflect/package.scala
+++ b/src/library/scala/reflect/package.scala
@@ -1,22 +1,22 @@
package scala
-package object reflect extends ReflectionUtils {
+package object reflect {
+
// !!! 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.
lazy val mirror: api.Mirror = {
// we use (Java) reflection here so that we can keep reflect.runtime and reflect.internals in a seperate jar
- singletonInstance("scala.reflect.runtime.Mirror") collect { case x: api.Mirror => x } getOrElse {
+ ReflectionUtils.singletonInstance("scala.reflect.runtime.Mirror") collect { case x: api.Mirror => x } getOrElse {
throw new UnsupportedOperationException("Scala reflection not available on this platform")
}
}
- /** Uncomment once we got rid of the old Symbols, Types, Trees
type Symbol = mirror.Symbol
type Type = mirror.Type
type Tree = mirror.Tree
- */
+
@deprecated("Use `@scala.beans.BeanDescription` instead", "2.10.0")
type BeanDescription = scala.beans.BeanDescription
@deprecated("Use `@scala.beans.BeanDisplayName` instead", "2.10.0")