Skip to content

Commit f332dcc

Browse files
committed
Fix #1776: Avoid interaction between parameter forwarding and elimByName
Parameter forwarding is not geared to handle parameters of by-name types correctly and consequently elimByName generates wrong code. Since it's a corner case it's easiest by not applying the parameter forwarding optimization to by-name parameters.
1 parent 4daf543 commit f332dcc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ class ParamForwarding(thisTransformer: DenotTransformer) {
5555
stat match {
5656
case stat: ValDef =>
5757
val sym = stat.symbol.asTerm
58-
if (sym is (ParamAccessor, butNot = Mutable)) {
58+
if (sym.is(ParamAccessor, butNot = Mutable) && !sym.info.isInstanceOf[ExprType]) {
59+
// ElimByName gets confused with methods returning an ExprType,
60+
// so avoid param forwarding if parameter is by name. See i1766.scala
5961
val idx = superArgs.indexWhere(_.symbol == sym)
6062
if (idx >= 0 && superParamNames(idx) == stat.name) { // supercall to like-named parameter
6163
val alias = inheritedAccessor(sym)

0 commit comments

Comments
 (0)