From ce9ab408c5e7e5fbe2231a9e29be2902e055160f Mon Sep 17 00:00:00 2001 From: peng Date: Fri, 22 Sep 2023 19:55:58 -0400 Subject: [PATCH] simplify formatDiffImpl --- .../splain/SplainFormattingExtension.scala | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/core/src/main/scala-2.13.7+/latest/splain/SplainFormattingExtension.scala b/core/src/main/scala-2.13.7+/latest/splain/SplainFormattingExtension.scala index a2bdcd6..7c41266 100644 --- a/core/src/main/scala-2.13.7+/latest/splain/SplainFormattingExtension.scala +++ b/core/src/main/scala-2.13.7+/latest/splain/SplainFormattingExtension.scala @@ -549,7 +549,26 @@ trait SplainFormattingExtension extends typechecker.splain.SplainFormatting with if (noArgs.distinct.size == 1) { formatDiffInfix(left, right, top) } else { - formatDiffSpecial(left, right, top).getOrElse(formatDiffSimple(left, right)) + formatDiffSpecial(left, right, top).getOrElse { + + val result = formatDiffSimple(left, right) + + result match { + case diff: Diff => + val noApparentDiff = diff.left == diff.right + + if (noApparentDiff) { + + ExplainDiff( + diff, + TypeDiffView(left, right).builtInDiffMsg + ).index() + } + case _ => + } + + result + } } } @@ -578,26 +597,6 @@ trait SplainFormattingExtension extends typechecker.splain.SplainFormatting with } } - override def formatDiffSimple(left: Type, right: Type): Formatted = { - - val result = super.formatDiffSimple(left, right) - - result match { - case diff: Diff => - val noApparentDiff = diff.left == diff.right - - if (noApparentDiff) { - - ExplainDiff( - diff, - TypeDiffView(left, right).builtInDiffMsg - ).index() - } - } - - result - } - override def showFormattedLImpl(ft: Formatted, break: Boolean): TypeRepr = { /**