Skip to content

Commit

Permalink
Merge pull request #10658 from som-snytt/issue/12929-specialization-c…
Browse files Browse the repository at this point in the history
…tor-field

Paramaccessors are private local in specialize
  • Loading branch information
lrytz committed Jan 15, 2024
2 parents fe7fd99 + 4d7f71f commit f1c9a40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Expand Up @@ -1997,7 +1997,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
// param accessors for private members (the others are inherited from the generic class)
if (m.isPrimaryConstructor) {
for (param <- vparams ; if sClass.info.nonPrivateMember(param.name) == NoSymbol) {
val acc = param.cloneSymbol(sClass, param.flags | PARAMACCESSOR | PRIVATE)
val acc = param.cloneSymbol(sClass, param.flags | PARAMACCESSOR | PrivateLocal)
sClass.info.decls.enter(acc)
mbrs += ValDef(acc, EmptyTree).setType(NoType).setPos(m.pos)
}
Expand Down
7 changes: 7 additions & 0 deletions test/files/specialized/t12929.scala
@@ -0,0 +1,7 @@

class C[@specialized(Int) A](i: Int)

object Test extends App {
val c = new C[Int](42)
assert(c.getClass.getDeclaredFields.isEmpty)
}

0 comments on commit f1c9a40

Please sign in to comment.