File tree 3 files changed +6
-5
lines changed
compiler/src/dotty/tools/dotc
3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -251,16 +251,15 @@ object Decorators {
251
251
op : WrappedResult [U ] ?=> String ,
252
252
printer : config.Printers .Printer = config.Printers .default)(using c : Conversion [T , U ] = null ): T = {
253
253
// 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)
255
255
// or no such conversion was found so we'll consume the result as it is instead
256
256
val obj = if c == null then x.asInstanceOf [U ] else c(x)
257
257
printer.println(op(using WrappedResult (obj)))
258
258
x
259
259
}
260
260
261
261
/** 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
264
263
case x : Showable =>
265
264
try x.show
266
265
catch
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ object Formatting {
16
16
object ShownDef :
17
17
/** Represents a value that has been "shown" and can be consumed by StringFormatter.
18
18
* Not just a string because it may be a Seq that StringFormatter will intersperse with the trailing separator.
19
- * Also, it's not a `String | Seq[String]` because then we'd need to a Context to call `Showable#show`. We could
19
+ * Also, it's not a `String | Seq[String]` because then we'd need a Context to call `Showable#show`. We could
20
20
* make Context a requirement for a Show instance but then we'd have lots of instances instead of just one ShowAny
21
21
* instance. We could also try to make `Show#show` require the Context, but then that breaks the Conversion. */
22
22
opaque type Shown = Any
Original file line number Diff line number Diff line change @@ -1751,7 +1751,9 @@ import transform.SymUtils._
1751
1751
1752
1752
class ClassAndCompanionNameClash (cls : Symbol , other : Symbol )(using Context )
1753
1753
extends NamingMsg (ClassAndCompanionNameClashID ) {
1754
- def msg = em " Name clash: both ${cls.owner} and its companion object defines ${cls.name.stripModuleClassSuffix.show}"
1754
+ def msg =
1755
+ val name = cls.name.stripModuleClassSuffix
1756
+ em " Name clash: both ${cls.owner} and its companion object defines $name"
1755
1757
def explain =
1756
1758
em """ |A ${cls.kindString} and its companion object cannot both define a ${hl(" class" )}, ${hl(" trait" )} or ${hl(" object" )} with the same name:
1757
1759
| - ${cls.owner} defines ${cls}
You can’t perform that action at this time.
0 commit comments