Skip to content

Commit 64b8931

Browse files
authored
Merge pull request #1864 from dotty-staging/fix-#1732
Fix #1732: Special treatment for bottom type by-name args
2 parents 7997ca5 + 1663768 commit 64b8931

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

compiler/src/dotty/tools/dotc/transform/ElimByName.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform
7171

7272
def transformArg(arg: Tree, formal: Type): Tree = formal.dealias match {
7373
case formalExpr: ExprType =>
74-
val argType = arg.tpe.widenIfUnstable
74+
var argType = arg.tpe.widenIfUnstable
75+
if (defn.isBottomType(argType)) argType = formal.widenExpr
7576
val argFun = arg match {
7677
case Apply(Select(qual, nme.apply), Nil)
7778
if qual.tpe.derivesFrom(defn.FunctionClass(0)) && isPureExpr(qual) =>

tests/run/i1732.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
object Test {
2+
import scala.util.control.Breaks
3+
4+
def brk(f: () => Unit): Unit = try {
5+
f()
6+
} catch {
7+
case ex: NotImplementedError =>
8+
}
9+
def main(args: Array[String]): Unit = {
10+
brk { () => ??? }
11+
Breaks.breakable {
12+
Breaks.break
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)