Skip to content

Commit

Permalink
SI-8132 Fix false "overrides nothing" for case class protected param
Browse files Browse the repository at this point in the history
Case class parameters that are less-than-public have an accessor
method created. In the enclosed test, we saw:

    case class G extends AnyRef with T with Product with Serializable {
      override <synthetic> <stable> <caseaccessor> def s$1: String = G.this.s;
      <caseaccessor> <paramaccessor> private[this] val s: String = _;
      override <stable> <accessor> <paramaccessor> protected def s: String = G.this.s;
      ...
    }

This commit removes the OVERRIDE flag from the accessor method,
which avoids the spurious "overrides nothing" error.
  • Loading branch information
retronym committed Jan 15, 2014
1 parent e089caf commit 8642a50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Expand Up @@ -380,7 +380,7 @@ trait SyntheticMethods extends ast.TreeDSL {
val original = ddef.symbol val original = ddef.symbol
val newAcc = deriveMethod(ddef.symbol, name => context.unit.freshTermName(name + "$")) { newAcc => val newAcc = deriveMethod(ddef.symbol, name => context.unit.freshTermName(name + "$")) { newAcc =>
newAcc.makePublic newAcc.makePublic
newAcc resetFlag (ACCESSOR | PARAMACCESSOR) newAcc resetFlag (ACCESSOR | PARAMACCESSOR | OVERRIDE)
ddef.rhs.duplicate ddef.rhs.duplicate
} }
// TODO: shouldn't the next line be: `original resetFlag CASEACCESSOR`? // TODO: shouldn't the next line be: `original resetFlag CASEACCESSOR`?
Expand Down
5 changes: 5 additions & 0 deletions test/files/pos/t8132.scala
@@ -0,0 +1,5 @@
trait T {
protected def s: String
}

case class G(override protected val s: String) extends T

0 comments on commit 8642a50

Please sign in to comment.