diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 20f3b8c59486..14077bb69e49 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -750,7 +750,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { for (m <- normMembers) { if (!needsSpecialization(fullEnv, m)) { - if (m.isValue && !m.isMutable && !m.isMethod && !m.isDeferred && !m.isLazy) { + if (m.isValue && !m.isMutable && !m.isMethod && !m.isDeferred && !m.isLazy && !m.isParamAccessor) { // non-specialized `val` fields are made mutable (in Constructors) and assigned from the // constructors of specialized subclasses. See PR scala/scala#9704. clazz.primaryConstructor.updateAttachment(ConstructorNeedsFence) diff --git a/test/junit/scala/tools/nsc/backend/jvm/BytecodeTest.scala b/test/junit/scala/tools/nsc/backend/jvm/BytecodeTest.scala index f7a0de1c5372..44983abe6524 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/BytecodeTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/BytecodeTest.scala @@ -393,7 +393,7 @@ class BytecodeTest extends BytecodeTesting { @Test def nonSpecializedValFence(): Unit = { def code(u1: String) = - s"""abstract class Speck[@specialized(Int) T](t: T) { + s"""abstract class Speck[@specialized(Int) T](t: T, sm: String, val sn: String) { | val a = t | $u1 | lazy val u2 = "?"