diff options
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/reflect/ReflectionUtils.scala | 16 | ||||
-rw-r--r-- | src/library/scala/reflect/makro/internal/Utils.scala | 14 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/library/scala/reflect/ReflectionUtils.scala b/src/library/scala/reflect/ReflectionUtils.scala index 6ea69cb80d..aa1285d5a0 100644 --- a/src/library/scala/reflect/ReflectionUtils.scala +++ b/src/library/scala/reflect/ReflectionUtils.scala @@ -33,20 +33,26 @@ object ReflectionUtils { System.getProperties.asScala.iterator } - private def searchForBootClasspath = ( + private def inferBootClasspath: String = ( systemProperties find (_._1 endsWith ".boot.class.path") map (_._2) getOrElse "" ) def show(cl: ClassLoader) = { - def inferClasspath(cl: ClassLoader) = cl match { - case cl: java.net.URLClassLoader => "[" + (cl.getURLs mkString ",") + "]" - case _ => "<unknown>" + def inferClasspath(cl: ClassLoader): String = cl match { + case cl: java.net.URLClassLoader => + "[" + (cl.getURLs mkString ",") + "]" + case cl if cl != null && cl.getClass.getName == "scala.tools.nsc.interpreter.AbstractFileClassLoader" => + "[" + cl.asInstanceOf[{val root: api.RequiredFile}].root + "] and " + inferClasspath(cl.getParent) + case null => + inferBootClasspath + case _ => + "<unknown>" } cl match { case cl if cl != null => "%s of type %s with classpath %s".format(cl, cl.getClass, inferClasspath(cl)) case null => - "primordial classloader with boot classpath [%s]".format(searchForBootClasspath) + "primordial classloader with boot classpath [%s]".format(inferClasspath(cl)) } } diff --git a/src/library/scala/reflect/makro/internal/Utils.scala b/src/library/scala/reflect/makro/internal/Utils.scala index 3af58e1c88..3032d8e05d 100644 --- a/src/library/scala/reflect/makro/internal/Utils.scala +++ b/src/library/scala/reflect/makro/internal/Utils.scala @@ -102,7 +102,7 @@ package internal { else gen.mkMethodCall(staticModule("scala.reflect.package"), newTermName("manifestToConcreteTypeTag"), List(tpe), List(manifestInScope)) } try c.typeCheck(result) - catch { case terr @ c.TypeError(pos, msg) => failTag(terr) } + catch { case terr @ c.TypeError(pos, msg) => failTag(result, terr) } } private def nonSyntheticManifestInScope(tpe: Type) = { @@ -116,7 +116,7 @@ package internal { def materializeExpr(prefix: Tree, expr: Tree): Tree = { val result = translatingReificationErrors(c.reifyTree(prefix, expr)) try c.typeCheck(result) - catch { case terr @ c.TypeError(pos, msg) => failExpr(terr) } + catch { case terr @ c.TypeError(pos, msg) => failExpr(result, terr) } } private def translatingReificationErrors(materializer: => Tree): Tree = { @@ -130,17 +130,19 @@ package internal { } } - private def failTag(reason: Any): Nothing = { + private def failTag(result: Tree, reason: Any): Nothing = { val Apply(TypeApply(fun, List(tpeTree)), _) = c.macroApplication val tpe = tpeTree.tpe val PolyType(_, MethodType(_, tagTpe)) = fun.tpe val tagModule = tagTpe.typeSymbol.companionSymbol if (c.compilerSettings.contains("-Xlog-implicits")) - c.echo(c.enclosingPosition, "cannot materialize " + tagModule.name + "[" + tpe + "] because:\n" + reason) + c.echo(c.enclosingPosition, s"cannot materialize ${tagModule.name}[$tpe] as $result because:\n$reason") c.abort(c.enclosingPosition, "No %s available for %s".format(tagModule.name, tpe)) } - private def failExpr(reason: Any): Nothing = - c.abort(c.enclosingPosition, "Cannot materialize Expr because:\n" + reason) + private def failExpr(result: Tree, reason: Any): Nothing = { + val Apply(_, expr :: Nil) = c.macroApplication + c.abort(c.enclosingPosition, s"Cannot materialize $expr as $result because:\n$reason") + } } } |