File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
compiler/src/dotty/tools/dotc/repl Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -689,10 +689,27 @@ class CompilingInterpreter(
689
689
690
690
private def resultExtractor (req : Request , varName : Name ): String = {
691
691
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
692
697
val varType = string2code(req.typeOf(varName)) match {
698
+ // Extract List's paremeter from full path
693
699
case ListReg (param) => s " List[ $param] "
700
+ // Extract Map's paremeters from full path
694
701
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
+ // ```
695
710
case LitReg (lit) => lit
711
+ // When the type is a singleton value like None, don't show `None$`
712
+ // instead show `None.type`.
696
713
case x if x.lastOption == Some ('$' ) => x.init + " .type"
697
714
case x => x
698
715
}
You can’t perform that action at this time.
0 commit comments