Skip to content

Fix #1776: Avoid interaction between parameter forwarding and elimByName #1781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ class ParamForwarding(thisTransformer: DenotTransformer) {
stat match {
case stat: ValDef =>
val sym = stat.symbol.asTerm
if (sym is (ParamAccessor, butNot = Mutable)) {
if (sym.is(ParamAccessor, butNot = Mutable) && !sym.info.isInstanceOf[ExprType]) {
// ElimByName gets confused with methods returning an ExprType,
// so avoid param forwarding if parameter is by name. See i1766.scala
val idx = superArgs.indexWhere(_.symbol == sym)
if (idx >= 0 && superParamNames(idx) == stat.name) { // supercall to like-named parameter
val alias = inheritedAccessor(sym)
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/i1776.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class X(val y: String)
class Y(y: => String) extends X(y)
class Z(z: => String) extends X(z)