Skip to content

Commit 27fdc29

Browse files
committed
Define a low-priority instance of Show for Product
This removes the need for some of the default instances. More importantly, this reduces the burden and boilerplate that would be needed when introducing a new case class, without defining a Show instance for it or extending Showable.
1 parent e40c5df commit 27fdc29

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

compiler/src/dotty/tools/dotc/printing/Formatting.scala

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ object Formatting {
3333
object ShowAny extends Show[Any]:
3434
def show(x: Any): Shown = x
3535

36-
class ShowImplicits1:
36+
class ShowImplicits2:
37+
given Show[Product] = ShowAny
38+
39+
class ShowImplicits1 extends ShowImplicits2:
3740
given Show[ImplicitRef] = ShowAny
3841
given Show[Names.Designator] = ShowAny
3942
given Show[util.SrcPos] = ShowAny
@@ -62,25 +65,15 @@ object Formatting {
6265
given Show[Class[?]] = ShowAny
6366
given Show[Exception] = ShowAny
6467
given Show[StringBuffer] = ShowAny
65-
given Show[Atoms] = ShowAny
66-
given Show[Highlight] = ShowAny
67-
given Show[HighlightBuffer] = ShowAny
6868
given Show[CompilationUnit] = ShowAny
69-
given Show[Mode] = ShowAny
7069
given Show[Phases.Phase] = ShowAny
71-
given Show[Signature] = ShowAny
7270
given Show[TyperState] = ShowAny
7371
given Show[config.ScalaVersion] = ShowAny
7472
given Show[io.AbstractFile] = ShowAny
75-
given Show[parsing.Scanners.IndentWidth] = ShowAny
7673
given Show[parsing.Scanners.Scanner] = ShowAny
7774
given Show[util.SourceFile] = ShowAny
7875
given Show[util.Spans.Span] = ShowAny
79-
given Show[dotty.tools.tasty.TastyBuffer.Addr] = ShowAny
8076
given Show[tasty.TreeUnpickler#OwnerTree] = ShowAny
81-
given Show[interactive.Completion] = ShowAny
82-
given Show[transform.sjs.JSSymUtils.JSName] = ShowAny
83-
given Show[org.scalajs.ir.Position] = ShowAny
8477
end Show
8578
end ShownDef
8679
export ShownDef.{ Show, Shown }

0 commit comments

Comments
 (0)