Skip to content

Commit 7775aab

Browse files
authored
Merge pull request #1781 from dotty-staging/fix-#1776
Fix #1776: Avoid interaction between parameter forwarding and elimByName
2 parents 740ccf8 + 0d266ab commit 7775aab

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-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)

tests/pos/i1776.scala

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class X(val y: String)
2+
class Y(y: => String) extends X(y)
3+
class Z(z: => String) extends X(z)

0 commit comments

Comments
 (0)