Skip to content

Commit

Permalink
REPL print, add unevaluated comment to lazy val
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Aug 9, 2019
1 parent c0c9df4 commit d31a308
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala
Expand Up @@ -26,7 +26,7 @@ trait MemberHandlers {
import global._
import naming._

import ReplStrings.{string2codeQuoted, string2code, any2stringOf, emptyStringQuoted, quotedString}
import ReplStrings.{string2codeQuoted, string2code, any2stringOf, quotedString}

private def codegenln(leadingPlus: Boolean, xs: String*): String = codegen(leadingPlus, (xs ++ Array("\n")): _*)
private def codegenln(xs: String*): String = codegenln(true, xs: _*)
Expand Down Expand Up @@ -133,7 +133,7 @@ trait MemberHandlers {
else {
// if this is a lazy val we avoid evaluating it here
val resultString =
if (mods.isLazy) emptyStringQuoted
if (mods.isLazy) quotedString(" // unevaluated")
else quotedString(" = ") + " + " + any2stringOf(path, maxStringElements)

val varOrValOrLzy =
Expand Down
4 changes: 1 addition & 3 deletions src/repl/scala/tools/nsc/interpreter/ReplStrings.scala
Expand Up @@ -37,7 +37,7 @@ object ReplStrings {
res.toString
}

def quotedString(str: String) =
@inline final def quotedString(str: String) =
"\"" + str + "\""

def string2codeQuoted(str: String) =
Expand All @@ -46,8 +46,6 @@ object ReplStrings {
def any2stringOf(x: Any, maxlen: Int) =
s"_root_.scala.runtime.ScalaRunTime.replStringOf($x, $maxlen)"

val emptyStringQuoted: String = quotedString("")

// no escaped or nested quotes
private[this] val inquotes = """(['"])(.*?)\1""".r
def unquoted(s: String) = s match { case inquotes(_, w) => w ; case _ => s }
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/repl-serialization.check
Expand Up @@ -4,7 +4,7 @@ val extract: AnyRef => Unit = <function1>
val x: Int = 0
def getX(): Int
class U
lazy val y: Int
lazy val y: Int // unevaluated
evaluating z
evaluating zz
class D
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/t6937.check
Expand Up @@ -12,7 +12,7 @@ scala> class A
class A

scala> lazy val apiru = ru: ApiUniverse
lazy val apiru: scala.reflect.api.Universe
lazy val apiru: scala.reflect.api.Universe // unevaluated

scala> apiru.typeTag[A].in(cm)
val res0: reflect.runtime.universe.TypeTag[A] = TypeTag[A]
Expand Down

0 comments on commit d31a308

Please sign in to comment.