diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 11e90896287d..6d90b168a29f 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -556,9 +556,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { case TypeBoundsTree(lo, hi, alias) => if (lo eq hi) && alias.isEmpty then optText(lo)(" = " ~ _) else optText(lo)(" >: " ~ _) ~ optText(hi)(" <: " ~ _) ~ optText(alias)(" = " ~ _) - case Bind(name, body) => + case bind @ Bind(name, body) => keywordText("given ").provided(tree.symbol.isOneOf(GivenOrImplicit) && !homogenizedView) ~ // Used for scala.quoted.Type in quote patterns (not pickled) - changePrec(InfixPrec) { toText(name) ~ " @ " ~ toText(body) } + changePrec(InfixPrec) { nameIdText(bind) ~ " @ " ~ toText(body) } case Alternative(trees) => changePrec(OrPrec) { toText(trees, " | ") } case UnApply(fun, implicits, patterns) => diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 43154022e3a0..1da4ed581b4d 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -1876,7 +1876,7 @@ trait Applications extends Compatibility { * formal parameter that is a unary function. */ def normArg(alts: List[TermRef], arg: untpd.Tree, idx: Int): untpd.Tree = arg match - case Block(Nil, expr) => normArg(alts, expr, idx) + case Block(Nil, expr) if !expr.isEmpty => normArg(alts, expr, idx) case untpd.Function(args: List[untpd.ValDef] @unchecked, body) => // If ref refers to a method whose parameter at index `idx` is a function type, diff --git a/tests/pos/i14699.scala b/tests/pos/i14699.scala new file mode 100644 index 000000000000..c0cc89fbf4f8 --- /dev/null +++ b/tests/pos/i14699.scala @@ -0,0 +1,7 @@ +def always(block: => Unit): Unit = {} +def always(args: Int*)(block: => Unit): Unit ={} + +def test = + val x = always{} + val xc: Unit = x + always(1,2,3) {}