Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SI-8132 Fix false "overrides nothing" for case class protected param

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...
commit 8642a50da8c0d0eb1e3001fb56426e8c1ef122f3 1 parent e089caf
Jason Zaugg retronym authored
2  src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
View
@@ -380,7 +380,7 @@ trait SyntheticMethods extends ast.TreeDSL {
val original = ddef.symbol
val newAcc = deriveMethod(ddef.symbol, name => context.unit.freshTermName(name + "$")) { newAcc =>
newAcc.makePublic
- newAcc resetFlag (ACCESSOR | PARAMACCESSOR)
+ newAcc resetFlag (ACCESSOR | PARAMACCESSOR | OVERRIDE)
ddef.rhs.duplicate
}
// TODO: shouldn't the next line be: `original resetFlag CASEACCESSOR`?
5 test/files/pos/t8132.scala
View
@@ -0,0 +1,5 @@
+trait T {
+ protected def s: String
+}
+
+case class G(override protected val s: String) extends T
Please sign in to comment.
Something went wrong with that request. Please try again.