Skip to content

Commit ad8919f

Browse files
committed
Adapt name tags for protected
Protected accessor names are no longer pickled, but inline accessors are. Adapt name tags accordingly. Bump major Tasty version.
1 parent 645e561 commit ad8919f

File tree

5 files changed

+25
-22
lines changed

5 files changed

+25
-22
lines changed

compiler/src/dotty/tools/dotc/core/NameKinds.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ object NameKinds {
353353

354354
val SuperAccessorName = new PrefixNameKind(SUPERACCESSOR, "super$")
355355
val InitializerName = new PrefixNameKind(INITIALIZER, "initial$")
356-
val ProtectedAccessorName = new PrefixNameKind(PROTECTEDACCESSOR, "protected$")
357-
val ProtectedSetterName = new PrefixNameKind(PROTECTEDSETTER, "protected$set") // dubious encoding, kept for Scala2 compatibility
356+
val ProtectedGetterName = new PrefixNameKind(PROTECTEDGETTER, "protected_get$")
357+
val ProtectedSetterName = new PrefixNameKind(PROTECTEDSETTER, "protected_set$")
358358
val InlineGetterName = new PrefixNameKind(INLINEGETTER, "inline_get$")
359359
val InlineSetterName = new PrefixNameKind(INLINESETTER, "inline_set$")
360360

@@ -388,9 +388,12 @@ object NameKinds {
388388
def infoString: String = "Signed"
389389
}
390390

391-
/** Possible name kinds of a method that comes from Scala2 pickling info. */
391+
/** Possible name kinds of a method that comes from Scala2 pickling info.
392+
* and that need to be unmangled. Note: Scala2 protected accessors and setters
393+
* can be left mangled, so they are not included in thus list.
394+
*/
392395
val Scala2MethodNameKinds: List[NameKind] =
393-
List(DefaultGetterName, ExtMethName, UniqueExtMethName, ProtectedAccessorName, ProtectedSetterName)
396+
List(DefaultGetterName, ExtMethName, UniqueExtMethName)
394397

395398
def simpleNameKindOfTag : collection.Map[Int, ClassifiedNameKind] = simpleNameKinds
396399
def qualifiedNameKindOfTag : collection.Map[Int, QualifiedNameKind] = qualifiedNameKinds

compiler/src/dotty/tools/dotc/core/NameTags.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ object NameTags extends TastyFormat.NameTags {
1515
// outer accessor that will be filled in by ExplicitOuter.
1616
// <num> indicates the number of hops needed to select the outer field.
1717

18+
final val PROTECTEDGETTER = 24 // The name of a protected getter `protected_get$<name>` created by ProtectedAccessors.
19+
20+
final val PROTECTEDSETTER = 25 // The name of a protected setter `protected_set$<name>` created by ProtectedAccessors.
21+
1822
final val INITIALIZER = 26 // A mixin initializer method
1923

2024
final val AVOIDCLASH = 27 // Adds a suffix to avoid a name clash;
@@ -47,7 +51,9 @@ object NameTags extends TastyFormat.NameTags {
4751
case OUTERSELECT => "OUTERSELECT"
4852

4953
case SUPERACCESSOR => "SUPERACCESSOR"
50-
case PROTECTEDACCESSOR => "PROTECTEDACCESSOR"
54+
case INLINEGETTER => "INLINEGETTER"
55+
case INLINESETTER => "INLINESETTER"
56+
case PROTECTEDGETTER => "PROTECTEDGETTER"
5157
case PROTECTEDSETTER => "PROTECTEDSETTER"
5258
case INITIALIZER => "INITIALIZER"
5359
case AVOIDCLASH => "AVOIDCLASH"

compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Macro-format:
3939
VARIANT Length underlying_NameRef variance_Nat // 0: Contravariant, 1: Covariant
4040
4141
SUPERACCESSOR Length underlying_NameRef
42-
PROTECTEDACCESSOR Length underlying_NameRef
43-
PROTECTEDSETTER Length underlying_NameRef
42+
INLINEGETTER Length underlying_NameRef
43+
INLINESETTER Length underlying_NameRef
4444
OBJECTCLASS Length underlying_NameRef
4545
4646
SIGNED Length original_NameRef resultSig_NameRef paramSig_NameRef*
@@ -226,8 +226,8 @@ Standard Section: "Positions" Assoc*
226226
object TastyFormat {
227227

228228
final val header = Array(0x5C, 0xA1, 0xAB, 0x1F)
229-
val MajorVersion = 7
230-
val MinorVersion = 1
229+
val MajorVersion = 8
230+
val MinorVersion = 0
231231

232232
/** Tags used to serialize names */
233233
class NameTags {
@@ -252,18 +252,12 @@ object TastyFormat {
252252

253253
final val SUPERACCESSOR = 20 // The name of a super accessor `super$name` created by SuperAccesors.
254254

255-
final val PROTECTEDACCESSOR = 21 // The name of a protected accessor `protected$<name>` created by SuperAccesors.
255+
final val INLINEGETTER = 21 // The name of an inline getter `inline_get$name`
256256

257-
final val PROTECTEDSETTER = 22 // The name of a protected setter `protected$set<name>` created by SuperAccesors.
258-
// This is a dubious encoding for its risk for ambiguity.
259-
// It is kept for Scala-2 compatibility.
257+
final val INLINESETTER = 22 // The name of an inline setter `inline_set$name`
260258

261259
final val OBJECTCLASS = 23 // The name of an object class (or: module class) `<name>$`.
262260

263-
final val INLINEGETTER = 24 // The name of an inline getter `inline_get$name`
264-
265-
final val INLINESETTER = 25 // The name of an inline setter `inline_set$name`
266-
267261
final val SIGNED = 63 // A pair of a name and a signature, used to idenitfy
268262
// possibly overloaded methods.
269263
}

compiler/src/dotty/tools/dotc/transform/ProtectedAccessors.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ProtectedAccessors extends MiniPhase {
2020
override def phaseName = ProtectedAccessors.name
2121

2222
object Accessors extends AccessProxies {
23-
def getterName = ProtectedAccessorName
23+
def getterName = ProtectedGetterName
2424
def setterName = ProtectedSetterName
2525

2626
val insert = new Insert {

compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Types._, Contexts._, Constants._, Names._, NameOps._, Flags._, DenotTrans
1111
import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._, Scopes._, Denotations._
1212
import util.Positions._
1313
import Decorators._
14-
import NameKinds.{ProtectedAccessorName, ProtectedSetterName, OuterSelectName, SuperAccessorName}
14+
import NameKinds.{ProtectedGetterName, ProtectedSetterName, OuterSelectName, SuperAccessorName}
1515
import Symbols._, TypeUtils._, SymUtils._
1616

1717
/** This class performs the following functions:
@@ -166,7 +166,7 @@ class SuperAccessors(thisPhase: DenotTransformer) {
166166
assert(clazz.exists, sym)
167167
ctx.debuglog("Decided for host class: " + clazz)
168168

169-
val accName = ProtectedAccessorName(sym.name)
169+
val accName = ProtectedGetterName(sym.name)
170170

171171
// if the result type depends on the this type of an enclosing class, the accessor
172172
// has to take an object of exactly this type, otherwise it's more general
@@ -206,7 +206,7 @@ class SuperAccessors(thisPhase: DenotTransformer) {
206206

207207
def isProtectedAccessor(tree: Tree)(implicit ctx: Context): Boolean = tree match {
208208
case Apply(TypeApply(Select(_, name), _), qual :: Nil) =>
209-
name.is(ProtectedAccessorName) || name.is(ProtectedSetterName)
209+
name.is(ProtectedGetterName) || name.is(ProtectedSetterName)
210210
case _ => false
211211
}
212212

@@ -221,7 +221,7 @@ class SuperAccessors(thisPhase: DenotTransformer) {
221221
assert(clazz.exists, sym)
222222
ctx.debuglog("Decided for host class: " + clazz)
223223

224-
val accName = ProtectedAccessorName(sym.name)
224+
val accName = ProtectedGetterName(sym.name)
225225

226226
// if the result type depends on the this type of an enclosing class, the accessor
227227
// has to take an object of exactly this type, otherwise it's more general

0 commit comments

Comments
 (0)