summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-05-06 04:32:03 +0000
committerPaul Phillips <paulp@improving.org>2011-05-06 04:32:03 +0000
commit57a00a46c823663238a7af1cd27b1cf80cc81168 (patch)
tree26c403de6e7c04ea33cda11e49262f8f5be70fe8 /src
parent4eb00a0a7227b70c42d46befc7c4418cfa22532e (diff)
downloadscala-57a00a46c823663238a7af1cd27b1cf80cc81168.tar.gz
scala-57a00a46c823663238a7af1cd27b1cf80cc81168.tar.bz2
scala-57a00a46c823663238a7af1cd27b1cf80cc81168.zip
Help :javap find nested repl-defined objects.
no review.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ILoop.scala33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
index 7b57c11714..7884a7ac47 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
@@ -389,15 +389,30 @@ class ILoop(in0: Option[BufferedReader], protected val out: PrintWriter)
protected def newJavap() = new Javap(intp.classLoader, new IMain.ReplStrippingWriter(intp)) {
override def tryClass(path: String): Array[Byte] = {
- // Look for Foo first, then Foo$, but if Foo$ is given explicitly,
- // we have to drop the $ to find object Foo, then tack it back onto
- // the end of the flattened name.
- def className = intp flatName path
- def moduleName = (intp flatName path.stripSuffix("$")) + "$"
-
- val bytes = super.tryClass(className)
- if (bytes.nonEmpty) bytes
- else super.tryClass(moduleName)
+ val hd :: rest = path split '.' toList;
+ // If there are dots in the name, the first segment is the
+ // key to finding it.
+ if (rest.nonEmpty) {
+ intp optFlatName hd match {
+ case Some(flat) =>
+ val clazz = flat :: rest mkString "$"
+ val bytes = super.tryClass(clazz)
+ if (bytes.nonEmpty) bytes
+ else super.tryClass(clazz + "$")
+ case _ => super.tryClass(path)
+ }
+ }
+ else {
+ // Look for Foo first, then Foo$, but if Foo$ is given explicitly,
+ // we have to drop the $ to find object Foo, then tack it back onto
+ // the end of the flattened name.
+ def className = intp flatName path
+ def moduleName = (intp flatName path.stripSuffix("$")) + "$"
+
+ val bytes = super.tryClass(className)
+ if (bytes.nonEmpty) bytes
+ else super.tryClass(moduleName)
+ }
}
}
private lazy val javap =