From c9ed923fee410612ad9c504cf48fa1f1fad38f90 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Thu, 19 Sep 2024 08:42:43 -0700 Subject: [PATCH] Test RedundantBraces around nested if before else --- .../resources/rewrite/RedundantBraces-if.stat | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/scalafmt-tests/shared/src/test/resources/rewrite/RedundantBraces-if.stat b/scalafmt-tests/shared/src/test/resources/rewrite/RedundantBraces-if.stat index 88e49dc5f6..cb91eeacf5 100644 --- a/scalafmt-tests/shared/src/test/resources/rewrite/RedundantBraces-if.stat +++ b/scalafmt-tests/shared/src/test/resources/rewrite/RedundantBraces-if.stat @@ -288,3 +288,43 @@ while (x < 10) { >>> while (x < 10) x += 1 +<<< #4133 outer braces around expression ending with `if`-without-`else` +object a { + if (imported.isOverloaded) { + for (sym <- imported.alternatives) + if (isQualifyingImplicit(name, sym, pre, imported = true)) + f(sym) + } + else if (isQualifyingImplicit(name, imported, pre, imported = true)) + f(imported) +} +>>> +Idempotency violated +=> Diff (- obtained, + expected) + f(sym) +- else if (isQualifyingImplicit(name, imported, pre, imported = true)) +- f(imported) ++ else if (isQualifyingImplicit(name, imported, pre, imported = true)) ++ f(imported) + } +<<< #4133 nested braces around expression ending with `if`-without-`else` +object a { + if (imported.isOverloaded) { + for (sym <- imported.alternatives) { + if (isQualifyingImplicit(name, sym, pre, imported = true)) { + f(sym) + } + } + } + else if (isQualifyingImplicit(name, imported, pre, imported = true)) + f(imported) +} +>>> +Idempotency violated +=> Diff (- obtained, + expected) + f(sym) +- else if (isQualifyingImplicit(name, imported, pre, imported = true)) +- f(imported) ++ else if (isQualifyingImplicit(name, imported, pre, imported = true)) ++ f(imported) + }