File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -251,16 +251,15 @@ object Decorators {
251251 op : WrappedResult [U ] ?=> String ,
252252 printer : config.Printers .Printer = config.Printers .default)(using c : Conversion [T , U ] = null ): T = {
253253 // either the use of `$result` was driven by the expected type of `Shown`
254- // which lead to the summoning of `Conversion[T, Shown]` (which we'll invoke)
254+ // which led to the summoning of `Conversion[T, Shown]` (which we'll invoke)
255255 // or no such conversion was found so we'll consume the result as it is instead
256256 val obj = if c == null then x.asInstanceOf [U ] else c(x)
257257 printer.println(op(using WrappedResult (obj)))
258258 x
259259 }
260260
261261 /** Instead of `toString` call `show` on `Showable` values, falling back to `toString` if an exception is raised. */
262- def show (using Context )(using z : Show [T ] = null ): String = x match
263- case _ if z != null => z.show(x).toString
262+ def show (using Context ): String = x match
264263 case x : Showable =>
265264 try x.show
266265 catch
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ object Formatting {
1818 object ShownDef :
1919 /** Represents a value that has been "shown" and can be consumed by StringFormatter.
2020 * Not just a string because it may be a Seq that StringFormatter will intersperse with the trailing separator.
21- * Also, it's not a `String | Seq[String]` because then we'd need to a Context to call `Showable#show`. We could
21+ * Also, it's not a `String | Seq[String]` because then we'd need a Context to call `Showable#show`. We could
2222 * make Context a requirement for a Show instance but then we'd have lots of instances instead of just one ShowAny
2323 * instance. We could also try to make `Show#show` require the Context, but then that breaks the Conversion. */
2424 opaque type Shown = Any
Original file line number Diff line number Diff line change @@ -1759,7 +1759,9 @@ import transform.SymUtils._
17591759
17601760 class ClassAndCompanionNameClash (cls : Symbol , other : Symbol )(using Context )
17611761 extends NamingMsg (ClassAndCompanionNameClashID ) {
1762- def msg = em " Name clash: both ${cls.owner} and its companion object defines ${cls.name.stripModuleClassSuffix.show}"
1762+ def msg =
1763+ val name = cls.name.stripModuleClassSuffix
1764+ em " Name clash: both ${cls.owner} and its companion object defines $name"
17631765 def explain =
17641766 em """ |A ${cls.kindString} and its companion object cannot both define a ${hl(" class" )}, ${hl(" trait" )} or ${hl(" object" )} with the same name:
17651767 | - ${cls.owner} defines ${cls}
You can’t perform that action at this time.
0 commit comments