Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix desugaring empty argument blocks in normArgs #14719

Merged
merged 2 commits into from
Mar 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala
Original file line number Diff line number Diff line change
@@ -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) =>
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
@@ -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,
7 changes: 7 additions & 0 deletions tests/pos/i14699.scala
Original file line number Diff line number Diff line change
@@ -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) {}