aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-12-01 15:34:37 +0100
committerFelix Mulder <felix.mulder@gmail.com>2016-12-01 15:34:37 +0100
commit35e8fcb805e7780555cf48160f90c9da71bb1811 (patch)
treeaa8bf9d46c1606df68387db532ae117ceada73f6
parent3a11ff78bf36a126edd90adb5d21b0280ab03533 (diff)
downloaddotty-35e8fcb805e7780555cf48160f90c9da71bb1811.tar.gz
dotty-35e8fcb805e7780555cf48160f90c9da71bb1811.tar.bz2
dotty-35e8fcb805e7780555cf48160f90c9da71bb1811.zip
Add comment regarding prettification
-rw-r--r--compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala17
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala b/compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
index 7fe3d815d..14a3b4ad0 100644
--- a/compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
+++ b/compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
@@ -689,10 +689,27 @@ class CompilingInterpreter(
private def resultExtractor(req: Request, varName: Name): String = {
val prettyName = varName.decode
+ // FIXME: `varType` is prettified to abbreviate common types where
+ // appropriate, and to also prettify literal types
+ //
+ // This should be rewritten to use the actual types once we have a
+ // semantic representation available to the REPL
val varType = string2code(req.typeOf(varName)) match {
+ // Extract List's paremeter from full path
case ListReg(param) => s"List[$param]"
+ // Extract Map's paremeters from full path
case MapReg(k, v) => s"Map[$k, $v]"
+ // Extract literal type from literal type representation. Example:
+ //
+ // ```
+ // scala> val x: 42 = 42
+ // val x: Int(42) = 42
+ // scala> val y: "hello" = "hello"
+ // val y: String("hello") = "hello"
+ // ```
case LitReg(lit) => lit
+ // When the type is a singleton value like None, don't show `None$`
+ // instead show `None.type`.
case x if x.lastOption == Some('$') => x.init + ".type"
case x => x
}