Skip to content

Commit 328ded4

Browse files
committed
Fix #1732: Special treatment for bottom type by-name args
If a by-name arg has a bottom type, we need to create a closure with the result type of the formal parameter, or else specialization with FunctionalInterfaces will fail.
1 parent 39c27b6 commit 328ded4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-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) =>

0 commit comments

Comments
 (0)