diff options
author | Som Snytt <som.snytt@gmail.com> | 2012-12-27 03:33:11 -0800 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2013-01-09 02:12:35 -0800 |
commit | 942f078720cb05c9238913bae8e62900558c2c45 (patch) | |
tree | 8c8d58fece2706cf2f8e57b168ea5378f2502c18 /src/compiler/scala/tools/nsc/interpreter/IMain.scala | |
parent | 666572261c41cc92b06c03bf4aa260c198240cd8 (diff) | |
download | scala-942f078720cb05c9238913bae8e62900558c2c45.tar.gz scala-942f078720cb05c9238913bae8e62900558c2c45.tar.bz2 scala-942f078720cb05c9238913bae8e62900558c2c45.zip |
Repl javap decodes various synthetic names for us (fixing SI-6894)
For instance, javap -app Test is equivalent to javap Test$delayedInit$App
with the correct line and iw prepended. This works by taking Test as a
name in scope, translating that, and then supplying the suffix.
Then javap -fun Test shows Test$$anonfun*, and for member m,
javap -fun Test#m shows Test$$anonfun$$m*.
This also works for classes and values defined in the repl.
javap -fun -raw m shows $line3.$read$$iw$$iw$$anonfun$m$1.
E.g., javap -fun scala.Enumeration obviates knowing or guessing
scala/Enumeration$$anonfun$scala$Enumeration$$populateNameMap$1.class.
Also, scala> :javap -fun scala.Array#concat
but still to do is using imported syms.
Both files and replout are supported for searching for artifacts.
The trigger is detecting the synthetic name (has an interior dollar).
Still to do, filter the output on Test#m to show only m.
Need a way to explore the list of artifacts; ideally, related symbols
would be available reflectively.
Prefer companion class to object, otherwise it's not showable;
for object, require dollar when both exist.
A JavapTest is supplied that is a ReplTest that asserts something about
its output instead of printing it.
Diffstat (limited to 'src/compiler/scala/tools/nsc/interpreter/IMain.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/IMain.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 36f012229e..4f23d9902e 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -953,7 +953,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends */ def tryTwice(op: => Symbol): Symbol = exitingTyper(op) orElse exitingFlatten(op) - def symbolOfIdent(id: String): Symbol = symbolOfTerm(id) orElse symbolOfType(id) + def symbolOfIdent(id: String): Symbol = symbolOfType(id) orElse symbolOfTerm(id) def symbolOfType(id: String): Symbol = tryTwice(replScope lookup (id: TypeName)) def symbolOfTerm(id: String): Symbol = tryTwice(replScope lookup (id: TermName)) def symbolOfName(id: Name): Symbol = replScope lookup id |