summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-02-14 07:11:38 +0000
committerPaul Phillips <paulp@improving.org>2011-02-14 07:11:38 +0000
commit6201a2c638e05d53f949d86314d4b77e3db606b8 (patch)
treedd934e1a34ee42f2263d9d51f0a9a3411b8a0d7c
parent00384916e0874f450bc00f9a1409850586f5b89a (diff)
downloadscala-6201a2c638e05d53f949d86314d4b77e3db606b8.tar.gz
scala-6201a2c638e05d53f949d86314d4b77e3db606b8.tar.bz2
scala-6201a2c638e05d53f949d86314d4b77e3db606b8.zip
Fix to :javap so repl-defined objects as well a...
Fix to :javap so repl-defined objects as well as classes will be found. Even case classes: scala> case class Bippy(x: Int, y: Int) defined class Bippy scala> :javap Bippy Compiled from "<console>" public class Bippy extends java.lang.Object implements scala.ScalaObject,scala.Product,scala.Serializable{ ... scala> :javap Bippy$ Compiled from "<console>" public final class Bippy$ extends scala.runtime.AbstractFunction2 implements scala.ScalaObject,scala.Serializable{ ... No review.
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ILoop.scala12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
index 38084af016..6a512f3a92 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
@@ -302,7 +302,17 @@ class ILoop(in0: Option[BufferedReader], protected val out: PrintWriter)
}
private object javap extends Javap(intp.classLoader, new IMain.ReplStrippingWriter(intp)) {
- override def tryClass(path: String): Array[Byte] = super.tryClass(intp pathToFlatName path)
+ 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 pathToFlatName path
+ def moduleName = (intp pathToFlatName path.stripSuffix("$")) + "$"
+
+ val bytes = super.tryClass(className)
+ if (bytes.nonEmpty) bytes
+ else super.tryClass(moduleName)
+ }
}
private def javapCommand(line: String): Result = {