Skip to content

Commit dec083a

Browse files
committed
Make all name kinds strict
For many kinds this is needed because creation of a name kind involves a side effect, namely registering the name kind. If we delay this we might get a crash on unpickling because a tag is not set yet. This was observed when compiling the collection strawman test.
1 parent c6dafba commit dec083a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ object NameKinds {
6262
}
6363

6464
/** The kind of SimpleNames */
65-
object SimpleNameKind extends NameKind(UTF8) { self =>
65+
val SimpleNameKind = new NameKind(UTF8) { self =>
6666
type ThisInfo = Info
6767
val info = new Info
6868
def mkString(underlying: TermName, info: ThisInfo) = unsupported("mkString")
@@ -311,7 +311,7 @@ object NameKinds {
311311
val PatMatSelectorName = new UniqueNameKind("selector")
312312

313313
/** The kind of names of default argument getters */
314-
object DefaultGetterName extends NumberedNameKind(DEFAULTGETTER, "DefaultGetter") {
314+
val DefaultGetterName = new NumberedNameKind(DEFAULTGETTER, "DefaultGetter") {
315315
def mkString(underlying: TermName, info: ThisInfo) = {
316316
val prefix = if (underlying.isConstructorName) nme.DEFAULT_GETTER_INIT else underlying
317317
prefix.toString + str.DEFAULT_GETTER + (info.num + 1)
@@ -330,14 +330,14 @@ object NameKinds {
330330
}
331331

332332
/** The kind of names that also encode a variance: 0 for contravariance, 1 for covariance. */
333-
object VariantName extends NumberedNameKind(VARIANT, "Variant") {
333+
val VariantName = new NumberedNameKind(VARIANT, "Variant") {
334334
def mkString(underlying: TermName, info: ThisInfo) = "-+"(info.num).toString + underlying
335335
}
336336

337337
/** Names of the form N_<outer>. Emitted by inliner, replaced by outer path
338338
* in ExplicitOuter.
339339
*/
340-
object OuterSelectName extends NumberedNameKind(OUTERSELECT, "OuterSelect") {
340+
val OuterSelectName = new NumberedNameKind(OUTERSELECT, "OuterSelect") {
341341
def mkString(underlying: TermName, info: ThisInfo) = {
342342
assert(underlying.isEmpty)
343343
info.num + "_<outer>"
@@ -359,7 +359,7 @@ object NameKinds {
359359
val ModuleClassName = new SuffixNameKind(OBJECTCLASS, "$", optInfoString = "ModuleClass")
360360

361361
/** A name together with a signature. Used in Tasty trees. */
362-
object SignedName extends NameKind(63) {
362+
val SignedName = new NameKind(63) {
363363

364364
case class SignedInfo(sig: Signature) extends Info {
365365
override def toString = s"$infoString $sig"

0 commit comments

Comments
 (0)