@@ -28,21 +28,18 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
2828
2929 var myClassLoader : AbstractFileClassLoader = uninitialized
3030
31- private def pprintRender (value : Any , width : Int , height : Int , initialOffset : Int )(using Context ): fansi.Str = {
32- def fallback () = {
33-
34- val fansiStr = pprint.PPrinter .Color
31+ private def pprintRender (value : Any , width : Int , height : Int , initialOffset : Int )(using Context ): String = {
32+ def fallback () =
33+ dotty.shaded.pprint.PPrinter .Color
3534 .apply(value, width = width, height = height, initialOffset = initialOffset)
36- dotty.shaded.pprint.log(fansiStr.toString.toCharArray)
37- fansiStr
38- }
39-
35+ .render
36+ .toString
4037 try
4138 val cl = classLoader()
42- val pprintCls = Class .forName(" pprint.PPrinter$Color$" , false , cl)
43- val fansiStrCls = Class .forName(" fansi.Str" , false , cl)
44- val Color = pprintCls .getField(" MODULE$" ).get(null )
45- val Color_apply = pprintCls .getMethod(" apply" ,
39+ val pprintColorCls = Class .forName(" dotty.shaded. pprint.PPrinter$Color$" , false , cl)
40+ val fansiStrCls = Class .forName(" dotty.shaded. fansi.Str" , false , cl)
41+ val Color = pprintColorCls .getField(" MODULE$" ).get(null )
42+ val Color_apply = pprintColorCls .getMethod(" apply" ,
4643 classOf [Any ], // value
4744 classOf [Int ], // width
4845 classOf [Int ], // height
@@ -51,11 +48,11 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
5148 classOf [Boolean ], // escape Unicode
5249 classOf [Boolean ], // show field names
5350 )
51+ val FansiStr_render = fansiStrCls.getMethod(" render" )
5452 val fansiStr = Color_apply .invoke(
5553 Color , value, width, height, 2 , initialOffset, false , true
5654 )
57- dotty.shaded.pprint.log(fansiStr.toString.toCharArray)
58- fansi.Str (fansiStr.toString)
55+ FansiStr_render .invoke(fansiStr).asInstanceOf [String ]
5956 catch
6057 case _ : ClassNotFoundException => fallback()
6158 case _ : NoSuchMethodException => fallback()
0 commit comments