summaryrefslogtreecommitdiff
path: root/src/reflect
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2014-02-14 22:55:29 +0100
committerEugene Burmako <xeno.by@gmail.com>2014-02-15 09:32:27 +0100
commit99b32bf47e356603ac7c0171b55eaef055c6b672 (patch)
tree88d02ea6d81538581c5c63f0e59e825fd7bc05e8 /src/reflect
parent88fd9b91c9b468d983bff795869753e6b9c53365 (diff)
downloadscala-99b32bf47e356603ac7c0171b55eaef055c6b672.tar.gz
scala-99b32bf47e356603ac7c0171b55eaef055c6b672.tar.bz2
scala-99b32bf47e356603ac7c0171b55eaef055c6b672.zip
staticXXX now throw ScalaReflectionException
Previously this was scala.reflect.internal.MissingRequirementError, but that's not good enough for the public API.
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/scala/reflect/api/Mirror.scala6
-rw-r--r--src/reflect/scala/reflect/api/Mirrors.scala4
-rw-r--r--src/reflect/scala/reflect/internal/Mirrors.scala9
-rw-r--r--src/reflect/scala/reflect/internal/ReificationSupport.scala7
-rw-r--r--src/reflect/scala/reflect/runtime/JavaMirrors.scala5
5 files changed, 15 insertions, 16 deletions
diff --git a/src/reflect/scala/reflect/api/Mirror.scala b/src/reflect/scala/reflect/api/Mirror.scala
index 48fc8dede4..da3afd89ff 100644
--- a/src/reflect/scala/reflect/api/Mirror.scala
+++ b/src/reflect/scala/reflect/api/Mirror.scala
@@ -79,8 +79,7 @@ abstract class Mirror[U <: Universe with Singleton] {
* }
*
* staticClass("foo.B") will resolve to the symbol corresponding to the class B declared in the package foo, and
- * staticClass("foo.A") will throw a MissingRequirementException (which is exactly what scalac would do if this
- * fully qualified class name is written inside any package in a Scala program).
+ * staticClass("foo.A") will throw a ScalaReflectionException.
*
* In the example above, to load a symbol that corresponds to the class B declared in the object foo,
* use staticModule("foo") to load the module symbol and then navigate info.members of its moduleClass.
@@ -106,8 +105,7 @@ abstract class Mirror[U <: Universe with Singleton] {
* }
*
* staticModule("foo.B") will resolve to the symbol corresponding to the object B declared in the package foo, and
- * staticModule("foo.A") will throw a MissingRequirementException (which is exactly what scalac would do if this
- * fully qualified class name is written inside any package in a Scala program).
+ * staticModule("foo.A") will throw a ScalaReflectionException
*
* In the example above, to load a symbol that corresponds to the object B declared in the object foo,
* use staticModule("foo") to load the module symbol and then navigate info.members of its moduleClass.
diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala
index 03a3c8c0fb..ec420d184c 100644
--- a/src/reflect/scala/reflect/api/Mirrors.scala
+++ b/src/reflect/scala/reflect/api/Mirrors.scala
@@ -504,7 +504,7 @@ trait Mirrors { self: Universe =>
/** A class symbol for the specified runtime class.
* @return The class symbol for the runtime class in the current class loader.
* @throws java.lang.ClassNotFoundException if no class with that name exists
- * @throws scala.reflect.internal.MissingRequirementError if no corresponding symbol exists
+ * @throws scala.reflect.ScalaReflectionException if no corresponding symbol exists
* to do: throws anything else?
*/
def classSymbol(rtcls: RuntimeClass): ClassSymbol
@@ -512,7 +512,7 @@ trait Mirrors { self: Universe =>
/** A module symbol for the specified runtime class.
* @return The module symbol for the runtime class in the current class loader.
* @throws java.lang.ClassNotFoundException if no class with that name exists
- * @throws scala.reflect.internal.MissingRequirementError if no corresponding symbol exists
+ * @throws scala.reflect.ScalaReflectionException if no corresponding symbol exists
* to do: throws anything else?
*/
def moduleSymbol(rtcls: RuntimeClass): ModuleSymbol
diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala
index aef99b0ed4..7065a8cd6d 100644
--- a/src/reflect/scala/reflect/internal/Mirrors.scala
+++ b/src/reflect/scala/reflect/internal/Mirrors.scala
@@ -117,7 +117,8 @@ trait Mirrors extends api.Mirrors {
* Compiler might ignore them, but they should be loadable with macros.
*/
override def staticClass(fullname: String): ClassSymbol =
- ensureClassSymbol(fullname, staticModuleOrClass(newTypeNameCached(fullname)))
+ try ensureClassSymbol(fullname, staticModuleOrClass(newTypeNameCached(fullname)))
+ catch { case mre: MissingRequirementError => throw new ScalaReflectionException(mre.msg) }
/************************ loaders of module symbols ************************/
@@ -155,7 +156,8 @@ trait Mirrors extends api.Mirrors {
* Compiler might ignore them, but they should be loadable with macros.
*/
override def staticModule(fullname: String): ModuleSymbol =
- ensureModuleSymbol(fullname, staticModuleOrClass(newTermNameCached(fullname)), allowPackages = false)
+ try ensureModuleSymbol(fullname, staticModuleOrClass(newTermNameCached(fullname)), allowPackages = false)
+ catch { case mre: MissingRequirementError => throw new ScalaReflectionException(mre.msg) }
/************************ loaders of package symbols ************************/
@@ -197,7 +199,8 @@ trait Mirrors extends api.Mirrors {
}
override def staticPackage(fullname: String): ModuleSymbol =
- ensurePackageSymbol(fullname.toString, getModuleOrClass(newTermNameCached(fullname)), allowModules = false)
+ try ensurePackageSymbol(fullname.toString, getModuleOrClass(newTermNameCached(fullname)), allowModules = false)
+ catch { case mre: MissingRequirementError => throw new ScalaReflectionException(mre.msg) }
/************************ helpers ************************/
diff --git a/src/reflect/scala/reflect/internal/ReificationSupport.scala b/src/reflect/scala/reflect/internal/ReificationSupport.scala
index 653beb4c2f..6a91109faf 100644
--- a/src/reflect/scala/reflect/internal/ReificationSupport.scala
+++ b/src/reflect/scala/reflect/internal/ReificationSupport.scala
@@ -23,14 +23,15 @@ trait ReificationSupport { self: SymbolTable =>
val result = owner.info decl name
if (result ne NoSymbol) result
else
- mirrorThatLoaded(owner).missingHook(owner, name) orElse
- MissingRequirementError.notFound("%s %s in %s".format(if (name.isTermName) "term" else "type", name, owner.fullName))
+ mirrorThatLoaded(owner).missingHook(owner, name) orElse {
+ throw new ScalaReflectionException("%s %s in %s not found".format(if (name.isTermName) "term" else "type", name, owner.fullName))
+ }
}
def selectOverloadedMethod(owner: Symbol, name: String, index: Int): MethodSymbol = {
val result = owner.info.decl(newTermName(name)).alternatives(index)
if (result ne NoSymbol) result.asMethod
- else MissingRequirementError.notFound("overloaded method %s #%d in %s".format(name, index, owner.fullName))
+ else throw new ScalaReflectionException("overloaded method %s #%d in %s not found".format(name, index, owner.fullName))
}
def newFreeTerm(name: String, value: => Any, flags: Long = 0L, origin: String = null): FreeTermSymbol =
diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala
index de0ad7161b..f5bddb1784 100644
--- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala
+++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala
@@ -80,10 +80,7 @@ private[scala] trait JavaMirrors extends internal.SymbolTable with api.JavaUnive
// the same thing is done by the `missingHook` below
override def staticPackage(fullname: String): ModuleSymbol =
try super.staticPackage(fullname)
- catch {
- case _: MissingRequirementError =>
- makeScalaPackage(fullname)
- }
+ catch { case _: ScalaReflectionException => makeScalaPackage(fullname) }
// ----------- Caching ------------------------------------------------------------------