diff options
-rw-r--r-- | src/dotty/tools/dotc/transform/AugmentScala2Traits.scala | 11 | ||||
-rw-r--r-- | tests/pos/scala2traits/scala-trait.scala | 6 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/transform/AugmentScala2Traits.scala b/src/dotty/tools/dotc/transform/AugmentScala2Traits.scala index c3e205f83..6c2d63d10 100644 --- a/src/dotty/tools/dotc/transform/AugmentScala2Traits.scala +++ b/src/dotty/tools/dotc/transform/AugmentScala2Traits.scala @@ -69,16 +69,13 @@ class AugmentScala2Traits extends MiniPhaseTransform with IdentityDenotTransform info = fullyParameterizedType(mold.info, mixin)) } - def traitSetter(getter: TermSymbol) = { - val separator = if (getter.is(Private)) nme.EXPAND_SEPARATOR else nme.TRAIT_SETTER_SEPARATOR - val expandedGetterName = - if (getter.is(ExpandedName)) getter.name - else getter.name.expandedName(getter.owner, separator) + def traitSetter(getter: TermSymbol) = getter.copy( - name = expandedGetterName.setterName, + name = getter.ensureNotPrivate.name + .expandedName(getter.owner, nme.TRAIT_SETTER_SEPARATOR) + .asTermName.setterName, flags = Method | Accessor | ExpandedName, info = MethodType(getter.info.resultType :: Nil, defn.UnitType)) - } for (sym <- mixin.info.decls) { if (needsForwarder(sym) || sym.isConstructor || sym.isGetter && sym.is(Lazy)) diff --git a/tests/pos/scala2traits/scala-trait.scala b/tests/pos/scala2traits/scala-trait.scala index db05bc941..4d91b12b2 100644 --- a/tests/pos/scala2traits/scala-trait.scala +++ b/tests/pos/scala2traits/scala-trait.scala @@ -9,7 +9,7 @@ trait T { trait S2T { var x: Int = 0 lazy val y: Int = 1 -// val z: Int = 2 + val z: Int = 2 val a: Int var b: Int @@ -19,13 +19,13 @@ trait S2T { trait S2Tprivate { private var x: Int = 0 private lazy val y: Int = 1 -// private val z: Int = 2 // @darkdimius uncomment once lazy vals can be inherited. + private val z: Int = 2 private def f(x: Int): Int = x + y def xx = x def xx_=(x: Int) = this.x = x def yy = y -// def zz = z + def zz = z def ff(x: Int) = f(x) } |