Skip to content

Commit 8322bca

Browse files
committed
Fix desugaring empty argument blocks in normArgs
Fixes #14699
1 parent ca63fc1 commit 8322bca

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ trait Applications extends Compatibility {
18761876
* formal parameter that is a unary function.
18771877
*/
18781878
def normArg(alts: List[TermRef], arg: untpd.Tree, idx: Int): untpd.Tree = arg match
1879-
case Block(Nil, expr) => normArg(alts, expr, idx)
1879+
case Block(Nil, expr) if !expr.isEmpty => normArg(alts, expr, idx)
18801880
case untpd.Function(args: List[untpd.ValDef] @unchecked, body) =>
18811881

18821882
// If ref refers to a method whose parameter at index `idx` is a function type,

tests/pos/i14699.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def always(block: => Unit): Unit = {}
2+
def always(args: Int*)(block: => Unit): Unit ={}
3+
4+
def test =
5+
val x = always{}
6+
val xc: Unit = x
7+
always(1,2,3) {}

0 commit comments

Comments
 (0)