Skip to content

Commit

Permalink
REPL bells and whistles: -Dscala.repl.vids=<Boolean>
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xeno-by committed Jun 8, 2012
1 parent ab40558 commit 2aaccfe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -115,7 +115,11 @@ trait MemberHandlers {
if (mods.isLazy) codegenln(false, "<lazy>") if (mods.isLazy) codegenln(false, "<lazy>")
else any2stringOf(req fullPath name, maxStringElements) 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)
} }
} }
} }
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/scala/tools/nsc/interpreter/ReplProps.scala
Expand Up @@ -23,4 +23,6 @@ class ReplProps {
val replAutorunCode = Prop[JFile]("scala.repl.autoruncode") val replAutorunCode = Prop[JFile]("scala.repl.autoruncode")
val powerInitCode = Prop[JFile]("scala.repl.power.initcode") val powerInitCode = Prop[JFile]("scala.repl.power.initcode")
val powerBanner = Prop[JFile]("scala.repl.power.banner") val powerBanner = Prop[JFile]("scala.repl.power.banner")

val vids = bool("scala.repl.vids")
} }

0 comments on commit 2aaccfe

Please sign in to comment.