diff --git a/compiler/src/dotty/tools/dotc/transform/BetaReduce.scala b/compiler/src/dotty/tools/dotc/transform/BetaReduce.scala index 97dc4697db6d..c586bb06cc29 100644 --- a/compiler/src/dotty/tools/dotc/transform/BetaReduce.scala +++ b/compiler/src/dotty/tools/dotc/transform/BetaReduce.scala @@ -128,7 +128,10 @@ object BetaReduce: ref.symbol case _ => val flags = Synthetic | (param.symbol.flags & Erased) - val tpe = if arg.tpe.dealias.isInstanceOf[ConstantType] then arg.tpe.dealias else arg.tpe.widen + val tpe = + if arg.tpe.isBottomType then param.tpe.widenTermRefExpr + else if arg.tpe.dealias.isInstanceOf[ConstantType] then arg.tpe.dealias + else arg.tpe.widen val binding = ValDef(newSymbol(ctx.owner, param.name, flags, tpe, coord = arg.span), arg).withSpan(arg.span) if !(tpe.isInstanceOf[ConstantType] && isPureExpr(arg)) then bindings += binding diff --git a/tests/pos/i15165.scala b/tests/pos/i15165.scala new file mode 100644 index 000000000000..15e89c90e900 --- /dev/null +++ b/tests/pos/i15165.scala @@ -0,0 +1,6 @@ +def test1 = { (y: Int) => y + 1 }.apply(???) + +class C: + def x: Int = 8 + +def test2 = { (c: C) => c.x }.apply(null)