diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-05-26 16:42:01 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-05-26 21:27:52 +1000 |
commit | db114aa44efe63763a883dcf07d667fe7d744ff6 (patch) | |
tree | 2e4a20b330d249c826a513025c8161649dc7ad47 /src/repl/scala/tools | |
parent | a3bb887e0200cf47a1fa2382a18948b3c553cf26 (diff) | |
download | scala-db114aa44efe63763a883dcf07d667fe7d744ff6.tar.gz scala-db114aa44efe63763a883dcf07d667fe7d744ff6.tar.bz2 scala-db114aa44efe63763a883dcf07d667fe7d744ff6.zip |
SI-7747 Limit previous change to imports of REPL vals
We only need to introduce the temporary val in the imports
wrapper when we are importing a val or module defined in the REPL.
The test case from the previous commit still passes, but
we are generating slightly simpler code.
Compared to 2.11.6, these two commits result in the following
diff:
https://gist.github.com/retronym/aa4bd3aeef1ab1b85fe9
Diffstat (limited to 'src/repl/scala/tools')
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/Imports.scala | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/Imports.scala b/src/repl/scala/tools/nsc/interpreter/Imports.scala index 97798cd017..c52869e208 100644 --- a/src/repl/scala/tools/nsc/interpreter/Imports.scala +++ b/src/repl/scala/tools/nsc/interpreter/Imports.scala @@ -165,12 +165,17 @@ trait Imports { case x if isClassBased => for (imv <- x.definedNames) { if (!currentImps.contains(imv)) { - val valName = req.lineRep.packageName + req.lineRep.readName - if (!tempValLines.contains(req.lineRep.lineId)) { - code.append(s"val $valName = $objName\n") - tempValLines += req.lineRep.lineId + x match { + case _: ValHandler | _: ModuleHandler => + val valName = req.lineRep.packageName + req.lineRep.readName + if (!tempValLines.contains(req.lineRep.lineId)) { + code.append(s"val $valName = $objName\n") + tempValLines += req.lineRep.lineId + } + code.append(s"import $valName ${req.accessPath}.`$imv`;\n") + case _ => + code.append("import " + objName + req.accessPath + ".`" + imv + "`\n") } - code.append(s"import $valName ${req.accessPath}.`$imv`;\n") currentImps += imv } } |