From 35e8fcb805e7780555cf48160f90c9da71bb1811 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Thu, 1 Dec 2016 15:34:37 +0100 Subject: Add comment regarding prettification --- .../dotty/tools/dotc/repl/CompilingInterpreter.scala | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'compiler/src/dotty/tools/dotc/repl') 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 } -- cgit v1.2.3