From 2aaccfe2e311b22a7a93a2a77b2229222f2fb982 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Tue, 5 Jun 2012 19:41:31 +0200 Subject: REPL bells and whistles: -Dscala.repl.vids= 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. --- src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala | 6 +++++- src/compiler/scala/tools/nsc/interpreter/ReplProps.scala | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') 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, "") 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") } -- cgit v1.2.3