Skip to content

Commit 35e8fcb

Browse files
committed
Add comment regarding prettification
1 parent 3a11ff7 commit 35e8fcb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,10 +689,27 @@ class CompilingInterpreter(
689689

690690
private def resultExtractor(req: Request, varName: Name): String = {
691691
val prettyName = varName.decode
692+
// FIXME: `varType` is prettified to abbreviate common types where
693+
// appropriate, and to also prettify literal types
694+
//
695+
// This should be rewritten to use the actual types once we have a
696+
// semantic representation available to the REPL
692697
val varType = string2code(req.typeOf(varName)) match {
698+
// Extract List's paremeter from full path
693699
case ListReg(param) => s"List[$param]"
700+
// Extract Map's paremeters from full path
694701
case MapReg(k, v) => s"Map[$k, $v]"
702+
// Extract literal type from literal type representation. Example:
703+
//
704+
// ```
705+
// scala> val x: 42 = 42
706+
// val x: Int(42) = 42
707+
// scala> val y: "hello" = "hello"
708+
// val y: String("hello") = "hello"
709+
// ```
695710
case LitReg(lit) => lit
711+
// When the type is a singleton value like None, don't show `None$`
712+
// instead show `None.type`.
696713
case x if x.lastOption == Some('$') => x.init + ".type"
697714
case x => x
698715
}

0 commit comments

Comments
 (0)