From f349862095dc0c20bce262da4030aa1a2a1056c6 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 14 Sep 2020 21:23:15 +0200 Subject: [PATCH] Improve Inlined printing --- compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala | 2 +- tests/neg/cannot-reduce-inline-match.check | 4 +--- tests/neg/inline-error-pos.check | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 2f76a9cf3f48..620a5528e7f5 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -463,7 +463,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { case tree @ Inlined(call, bindings, body) => (("/* inlined from " ~ (if (call.isEmpty) "outside" else toText(call)) ~ " */ ") `provided` !homogenizedView && ctx.settings.XprintInline.value) ~ - blockText(bindings :+ body) + (if bindings.isEmpty then toText(body) else blockText(bindings :+ body)) case tpt: untpd.DerivedTypeTree => "" case TypeTree() => diff --git a/tests/neg/cannot-reduce-inline-match.check b/tests/neg/cannot-reduce-inline-match.check index bd5992761893..ceca40a74cbd 100644 --- a/tests/neg/cannot-reduce-inline-match.check +++ b/tests/neg/cannot-reduce-inline-match.check @@ -2,8 +2,6 @@ 9 | foo("f") // error | ^^^^^^^^ | cannot reduce inline match with - | scrutinee: { - | "f" - | } : ("f" : String) + | scrutinee: "f" : ("f" : String) | patterns : case _:Int | This location contains code that was inlined from cannot-reduce-inline-match.scala:3 diff --git a/tests/neg/inline-error-pos.check b/tests/neg/inline-error-pos.check index b529a888f33b..121684fe14d6 100644 --- a/tests/neg/inline-error-pos.check +++ b/tests/neg/inline-error-pos.check @@ -2,8 +2,6 @@ 8 | val b = foo(2) // error | ^^^^^^ | cannot reduce inline match with - | scrutinee: { - | 2 - | } : (2 : Int) + | scrutinee: 2 : (2 : Int) | patterns : case 1 | This location contains code that was inlined from inline-error-pos.scala:3