diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-06-05 19:41:31 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-06-08 15:23:08 +0200 |
commit | 2aaccfe2e311b22a7a93a2a77b2229222f2fb982 (patch) | |
tree | e46dea3ad587a5980cb3d1df3b706a19b104af16 /src | |
parent | ab40558bb53d6058b175e7f25f51470fa286d92e (diff) | |
download | scala-2aaccfe2e311b22a7a93a2a77b2229222f2fb982.tar.gz scala-2aaccfe2e311b22a7a93a2a77b2229222f2fb982.tar.bz2 scala-2aaccfe2e311b22a7a93a2a77b2229222f2fb982.zip |
REPL bells and whistles: -Dscala.repl.vids=<Boolean>
Displays identity hashcodes next to `res` values printed by REPL.
This proved quite useful in detecting reflection artifacts that look the same,
but are, in fact, different.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/ReplProps.scala | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala index a29eb3ac6d..236f3f23c5 100644 --- a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala +++ b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala @@ -115,7 +115,11 @@ trait MemberHandlers { if (mods.isLazy) codegenln(false, "<lazy>") else any2stringOf(req fullPath name, maxStringElements) - """ + "%s: %s = " + %s""".format(prettyName, string2code(req typeOf name), resultString) + val vidString = + if (replProps.vids) """" + " @ " + "%%8x".format(System.identityHashCode(%s)) + " """.trim.format(req fullPath name) + else "" + + """ + "%s%s: %s = " + %s""".format(prettyName, vidString, string2code(req typeOf name), resultString) } } } diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala b/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala index 75d7c8accf..aa58a8b2ba 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala @@ -23,4 +23,6 @@ class ReplProps { val replAutorunCode = Prop[JFile]("scala.repl.autoruncode") val powerInitCode = Prop[JFile]("scala.repl.power.initcode") val powerBanner = Prop[JFile]("scala.repl.power.banner") + + val vids = bool("scala.repl.vids") } |