From 0698383d595fec40c70905eb0e06b430f93ba0b8 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 27 Mar 2017 10:08:59 +0200 Subject: Add NameExtractors Use a new scheme for creating and accessing semantic names which is based on semantic name extractors with nested info classes. --- .../src/dotty/tools/dotc/core/Denotations.scala | 19 ++-- compiler/src/dotty/tools/dotc/core/NameInfos.scala | 122 --------------------- compiler/src/dotty/tools/dotc/core/NameOps.scala | 43 ++++---- compiler/src/dotty/tools/dotc/core/Names.scala | 60 +++++----- compiler/src/dotty/tools/dotc/core/StdNames.scala | 2 + .../src/dotty/tools/dotc/core/SymDenotations.scala | 8 +- .../dotty/tools/dotc/core/tasty/NameBuffer.scala | 27 ++--- .../dotty/tools/dotc/core/tasty/TreePickler.scala | 6 +- .../tools/dotc/core/tasty/TreeUnpickler.scala | 5 +- 9 files changed, 90 insertions(+), 202 deletions(-) delete mode 100644 compiler/src/dotty/tools/dotc/core/NameInfos.scala (limited to 'compiler/src/dotty/tools') diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala index aa0ea39a2..60a506291 100644 --- a/compiler/src/dotty/tools/dotc/core/Denotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala @@ -6,6 +6,7 @@ import SymDenotations.{ SymDenotation, ClassDenotation, NoDenotation } import Contexts.{Context, ContextBase} import Names._ import NameOps._ +import NameExtractors._ import StdNames._ import Symbols.NoSymbol import Symbols._ @@ -1185,19 +1186,19 @@ object Denotations { } else owner } - def recur(path: Name, wrap: Name => Name = identity): Denotation = path match { + def recur(path: Name, wrap: TermName => Name = identity): Denotation = path match { case path: TypeName => - recur(path.toTermName, n => wrap(n.toTypeName)) - case DerivedTermName(prefix, NameInfo.ModuleClass) => - recur(prefix, n => wrap(n.derived(NameInfo.ModuleClass))) - case DerivedTermName(prefix, NameInfo.Select(selector)) => + recur(path.toTermName, n => n.toTypeName) + case ModuleClassName(underlying) => + recur(underlying, n => wrap(ModuleClassName(n))) + case QualifiedName(prefix, selector) => select(recur(prefix), wrap(selector)) - case DerivedTermName(prefix, qual: NameInfo.Qualified) => - recur(prefix, n => wrap(n ++ qual.separator ++ qual.name)) + case AnyQualifiedName(prefix, info) => + recur(prefix, n => wrap(info.mkString(n).toTermName)) case path: SimpleTermName => - def recurSimple(len: Int, wrap: Name => Name): Denotation = { + def recurSimple(len: Int, wrap: TermName => Name): Denotation = { val point = path.lastIndexOf('.', len - 1) - val selector = wrap(path.slice(point + 1, len)) + val selector = wrap(path.slice(point + 1, len).asTermName) val prefix = if (point > 0) recurSimple(point, identity) else if (selector.isTermName) defn.RootClass.denot diff --git a/compiler/src/dotty/tools/dotc/core/NameInfos.scala b/compiler/src/dotty/tools/dotc/core/NameInfos.scala deleted file mode 100644 index 4f2628a9e..000000000 --- a/compiler/src/dotty/tools/dotc/core/NameInfos.scala +++ /dev/null @@ -1,122 +0,0 @@ -package dotty.tools.dotc -package core - -import Names._ -import NameOps._ -import StdNames._ - -/** Additional info associated with a name. At a minimum its kind and - * a way to turn it into a string. - */ -abstract class NameInfo extends util.DotClass { - def kind: NameInfo.Kind - def mkString(underlying: TermName): String - def map(f: SimpleTermName => SimpleTermName): NameInfo = this -} - -object NameInfo { - - type Kind = Int - - val TermNameKind = 0 - val SelectKind = 1 - val FlattenKind = 2 - val ExpandKind = 3 - val TraitSetterKind = 4 - val DefaultGetterKind = 5 - val VariantKind = 6 - val SuperAccessorKind = 7 - val InitializerKind = 8 - val ModuleClassKind = 10 - - val qualifier: Map[String, SimpleTermName => Qualified] = - Map("." -> Select, - "$" -> Flatten, - str.EXPAND_SEPARATOR -> Expand, - str.TRAIT_SETTER_SEPARATOR -> TraitSetter) - - def definesNewName(kind: Kind) = kind <= TraitSetterKind - - /** TermNames have the lowest possible kind */ - val TermName = new NameInfo { - def kind = TermNameKind - def mkString(underlying: TermName) = underlying.toString // will cause an unsupported exception - } - - trait Qualified extends NameInfo { - def kind: Kind - def name: SimpleTermName - def separator: String - def newLikeThis(name: SimpleTermName): Qualified // TODO: should use copy instead after bootstrap - - override def map(f: SimpleTermName => SimpleTermName): NameInfo = newLikeThis(f(name)) - def mkString(underlying: TermName) = s"$underlying$separator$name" - override def toString = s"${getClass.getSimpleName}($name)" - } - - case class Select(val name: SimpleTermName) extends Qualified { - def kind = SelectKind - def separator = "." - def newLikeThis(name: SimpleTermName) = Select(name) - } - - case class Flatten(val name: SimpleTermName) extends Qualified { - def kind = FlattenKind - def separator = "$" - def newLikeThis(name: SimpleTermName) = Flatten(name) - } - - case class Expand(val name: SimpleTermName) extends Qualified { - def kind = ExpandKind - def separator = str.EXPAND_SEPARATOR - def newLikeThis(name: SimpleTermName) = Expand(name) - } - - case class TraitSetter(val name: SimpleTermName) extends Qualified { - def kind = TraitSetterKind - def separator = nme.TRAIT_SETTER_SEPARATOR.toString - def newLikeThis(name: SimpleTermName) = TraitSetter(name) - } - - trait Numbered extends NameInfo { - def num: Int - override def toString = s"${getClass.getSimpleName}($num)" - } - - case class DefaultGetter(val num: Int) extends Numbered { - def kind = DefaultGetterKind - def mkString(underlying: TermName) = { - val prefix = if (underlying.isConstructorName) nme.DEFAULT_GETTER_INIT else underlying - prefix.toString + nme.DEFAULT_GETTER + (num + 1) - } - } - - case class Variant(val num: Int) extends Numbered { - def kind = VariantKind - def mkString(underlying: TermName) = varianceToPrefix(num).toString + underlying - } - - val SuperAccessor = new NameInfo { - def kind = SuperAccessorKind - def mkString(underlying: TermName) = - underlying.mapLast(n => (nme.SUPER_PREFIX ++ n).asSimpleName).toString - override def toString = "SuperAccessor" - } - - val Initializer = new NameInfo { - def kind = InitializerKind - def mkString(underlying: TermName) = - underlying.mapLast(n => (nme.INITIALIZER_PREFIX ++ n).asSimpleName).toString - override def toString = "Initializer" - } - - val ModuleClass = new NameInfo { - def kind = ModuleClassKind - def mkString(underlying: TermName) = underlying + "$" - override def toString = "ModuleClass" - } - - /** Map between variances and name prefixes */ - val varianceToPrefix = Map(-1 -> '-', 0 -> '=', 1 -> '+') - val prefixToVariance = Map('-' -> -1, '=' -> 0, '+' -> 1) -} \ No newline at end of file diff --git a/compiler/src/dotty/tools/dotc/core/NameOps.scala b/compiler/src/dotty/tools/dotc/core/NameOps.scala index ed6a41ac5..b51955d9d 100644 --- a/compiler/src/dotty/tools/dotc/core/NameOps.scala +++ b/compiler/src/dotty/tools/dotc/core/NameOps.scala @@ -4,7 +4,7 @@ package core import java.security.MessageDigest import scala.annotation.switch import scala.io.Codec -import Names._, StdNames._, Contexts._, Symbols._, Flags._ +import Names._, StdNames._, Contexts._, Symbols._, Flags._, NameExtractors._ import Decorators.PreNamedString import util.{Chars, NameTransformer} import Chars.isOperatorPart @@ -49,14 +49,14 @@ object NameOps { } } - class PrefixNameExtractor(pre: TermName, info: NameInfo) { + class PrefixNameExtractor(pre: TermName, bldr: NameExtractors.PrefixNameExtractor) { def apply(name: TermName): TermName = - if (Config.semanticNames) name.derived(info) else pre ++ name + if (Config.semanticNames) bldr(name) else pre ++ name def unapply(name: TermName): Option[TermName] = if (Config.semanticNames) name match { - case DerivedTermName(original, `info`) => Some(original) + case bldr(original) => Some(original) case _ => None } else tryUnmangle(name) @@ -66,8 +66,8 @@ object NameOps { else None } - object SuperAccessorName extends PrefixNameExtractor(nme.SUPER_PREFIX, NameInfo.SuperAccessor) - object InitializerName extends PrefixNameExtractor(nme.INITIALIZER_PREFIX, NameInfo.Initializer) + object SuperAccessorName extends PrefixNameExtractor(nme.SUPER_PREFIX, NameExtractors.SuperAccessorName) + object InitializerName extends PrefixNameExtractor(nme.INITIALIZER_PREFIX, NameExtractors.InitializerName) implicit class NameDecorator[N <: Name](val name: N) extends AnyVal { import nme._ @@ -83,12 +83,12 @@ object NameOps { def isProtectedAccessorName = name startsWith PROTECTED_PREFIX def isReplWrapperName = name.toSimpleName containsSlice INTERPRETER_IMPORT_WRAPPER def isTraitSetterName = - if (Config.semanticNames) name.is(NameInfo.TraitSetterKind) + if (Config.semanticNames) name.is(TraitSetterName) else name containsSlice TRAIT_SETTER_SEPARATOR def isSetterName = name endsWith SETTER_SUFFIX def isSingletonName = name endsWith SINGLETON_SUFFIX def isModuleClassName = - if (Config.semanticNames) name.is(NameInfo.ModuleClass.kind) + if (Config.semanticNames) name.is(ModuleClassName) else name endsWith MODULE_SUFFIX def isAvoidClashName = name endsWith AVOID_CLASH_SUFFIX def isImportName = name startsWith IMPORT @@ -138,7 +138,7 @@ object NameOps { /** Convert this module name to corresponding module class name */ def moduleClassName: TypeName = - if (Config.semanticNames) name.derived(NameInfo.ModuleClass).toTypeName + if (Config.semanticNames) name.derived(ModuleClassName).toTypeName else (name ++ tpnme.MODULE_SUFFIX).toTypeName /** Convert this module class name to corresponding source module name */ @@ -147,7 +147,7 @@ object NameOps { /** If name ends in module class suffix, drop it */ def stripModuleClassSuffix: Name = if (isModuleClassName) - if (Config.semanticNames) name.exclude(NameInfo.ModuleClass.kind) + if (Config.semanticNames) name.exclude(ModuleClassName) else name dropRight MODULE_SUFFIX.length else name @@ -166,7 +166,7 @@ object NameOps { /** The superaccessor for method with given name */ def superName: TermName = - if (Config.semanticNames) name.derived(NameInfo.SuperAccessor).toTermName + if (Config.semanticNames) SuperAccessorName(name.toTermName) else (nme.SUPER_PREFIX ++ name).toTermName /** The expanded name of `name` relative to given class `base`. @@ -182,11 +182,11 @@ object NameOps { likeTyped( if (Config.semanticNames) { def qualify(name: SimpleTermName) = - prefix.derived(NameInfo.qualifier(separator.toString)(name)) + separatorToQualified(separator.toString)(prefix.toTermName, name) name rewrite { case name: SimpleTermName => qualify(name) - case DerivedTermName(_, _: NameInfo.Qualified) => + case AnyQualifiedName(_, _) => // Note: an expanded name may itself be expanded. For example, look at javap of scala.App.initCode qualify(name.toSimpleName) } @@ -204,7 +204,7 @@ object NameOps { def unexpandedName: N = if (Config.semanticNames) likeTyped { - name.rewrite { case DerivedTermName(_, NameInfo.Expand(unexp)) => unexp } + name.rewrite { case XpandedName(_, unexp) => unexp } } else unexpandedNameOfMangled @@ -222,7 +222,7 @@ object NameOps { def expandedPrefix: N = if (Config.semanticNames) likeTyped { - name.rewrite { case DerivedTermName(prefix, NameInfo.Expand(_)) => prefix } + name.rewrite { case XpandedName(prefix, _) => prefix } } else expandedPrefixOfMangled @@ -236,7 +236,8 @@ object NameOps { if (Config.semanticNames && name.isSimple) { val unmangled = unexpandedNameOfMangled if (name eq unmangled) name - else likeTyped(expandedPrefixOfMangled.derived(NameInfo.Expand(unmangled.asSimpleName))) + else likeTyped( + XpandedName(expandedPrefixOfMangled.toTermName, unmangled.asSimpleName)) } else name @@ -440,7 +441,7 @@ object NameOps { if (name.isSetterName) { if (name.isTraitSetterName) { if (Config.semanticNames) { - val DerivedTermName(_, NameInfo.TraitSetter(original)) = name + val TraitSetterName(_, original) = name original.fieldName } else { @@ -468,7 +469,7 @@ object NameOps { * @note Default getter name suffixes start at 1, so `pos` has to be adjusted by +1 */ def defaultGetterName(pos: Int): TermName = - if (Config.semanticNames) name.derived(NameInfo.DefaultGetter(pos)) + if (Config.semanticNames) DefaultGetterName(name, pos) else { val prefix = if (name.isConstructorName) DEFAULT_GETTER_INIT else name prefix ++ DEFAULT_GETTER ++ (pos + 1).toString @@ -478,7 +479,7 @@ object NameOps { def defaultGetterToMethod: TermName = if (Config.semanticNames) name rewrite { - case DerivedTermName(methName, NameInfo.DefaultGetter(_)) => methName + case DefaultGetterName(methName, _) => methName } else defaultGetterToMethodOfMangled @@ -495,7 +496,7 @@ object NameOps { def defaultGetterIndex: Int = if (Config.semanticNames) name collect { - case DerivedTermName(methName, NameInfo.DefaultGetter(num)) => num + case DefaultGetterName(_, num) => num } getOrElse -1 else defaultGetterIndexOfMangled @@ -600,7 +601,7 @@ object NameOps { if (Config.semanticNames && name.isSimple) SuperAccessorName.tryUnmangle(name.lastPart) match { case scala.Some(original) => - name.mapLast(_ => original.asSimpleName).derived(NameInfo.SuperAccessor) + SuperAccessorName(name.mapLast(_ => original.asSimpleName)) case None => name } diff --git a/compiler/src/dotty/tools/dotc/core/Names.scala b/compiler/src/dotty/tools/dotc/core/Names.scala index 407dc149a..4524f2061 100644 --- a/compiler/src/dotty/tools/dotc/core/Names.scala +++ b/compiler/src/dotty/tools/dotc/core/Names.scala @@ -19,6 +19,7 @@ import java.util.HashMap //import annotation.volatile object Names { + import NameExtractors._ /** A common class for things that can be turned into names. * Instances are both names and strings, the latter via a decorator. @@ -74,8 +75,9 @@ object Names { def likeKinded(name: Name): ThisName def derived(info: NameInfo): ThisName - def exclude(kind: NameInfo.Kind): ThisName - def is(kind: NameInfo.Kind): Boolean + def derived(kind: ClassifiedNameExtractor): ThisName = derived(kind.info) + def exclude(kind: NameExtractor): ThisName + def is(kind: NameExtractor): Boolean def debugString: String def toText(printer: Printer): Text = printer.toText(this) @@ -128,7 +130,7 @@ object Names { def likeKinded(name: Name): TermName = name.toTermName - def info = NameInfo.TermName + def info: NameInfo = simpleTermNameInfo def underlying: TermName = unsupported("underlying") @sharable private var derivedNames: AnyRef /* SimpleMap | j.u.HashMap */ = @@ -169,26 +171,26 @@ object Names { * name as underlying name. */ def derived(info: NameInfo): TermName = { - val ownKind = this.info.kind - if (ownKind < info.kind || NameInfo.definesNewName(info.kind)) add(info) - else if (ownKind > info.kind) underlying.derived(info).add(this.info) + val ownTag = this.info.tag + if (ownTag < info.tag || definesNewName(info.tag)) add(info) + else if (ownTag > info.tag) underlying.derived(info).add(this.info) else { assert(info == this.info) this } } - def exclude(kind: NameInfo.Kind): TermName = { - val ownKind = this.info.kind - if (ownKind < kind || NameInfo.definesNewName(ownKind)) this - else if (ownKind > kind) underlying.exclude(kind).add(this.info) + def exclude(kind: NameExtractor): TermName = { + val ownTag = this.info.tag + if (ownTag < kind.tag || definesNewName(ownTag)) this + else if (ownTag > kind.tag) underlying.exclude(kind).add(this.info) else underlying } - def is(kind: NameInfo.Kind): Boolean = { - val ownKind = info.kind - ownKind == kind || - !NameInfo.definesNewName(ownKind) && ownKind > kind && underlying.is(kind) + def is(kind: NameExtractor): Boolean = { + val ownTag = this.info.tag + ownTag == kind.tag || + !definesNewName(ownTag) && ownTag > kind.tag && underlying.is(kind) } override def hashCode = System.identityHashCode(this) @@ -200,6 +202,9 @@ object Names { def apply(n: Int) = chrs(start + n) + //override def derived(info: NameInfo): TermName = add(info) + //override def is(kind: NameExtractor) = false + private def contains(ch: Char): Boolean = { var i = 0 while (i < length && chrs(start + i) != ch) i += 1 @@ -289,8 +294,8 @@ object Names { def likeKinded(name: Name): TypeName = name.toTypeName def derived(info: NameInfo): TypeName = toTermName.derived(info).toTypeName - def exclude(kind: NameInfo.Kind): TypeName = toTermName.exclude(kind).toTypeName - def is(kind: NameInfo.Kind) = toTermName.is(kind) + def exclude(kind: NameExtractor): TypeName = toTermName.exclude(kind).toTypeName + def is(kind: NameExtractor) = toTermName.is(kind) override def toString = toTermName.toString override def debugString = toTermName.debugString + "/T" @@ -306,7 +311,7 @@ object Names { def decode: Name = underlying.decode.derived(info.map(_.decode)) def firstPart = underlying.firstPart def lastPart = info match { - case qual: NameInfo.Qualified => qual.name + case qual: QualifiedInfo => qual.name case _ => underlying.lastPart } override def toString = info.mkString(underlying) @@ -319,26 +324,26 @@ object Names { def rewrite(f: PartialFunction[Name, Name]): ThisName = if (f.isDefinedAt(this)) likeKinded(f(this)) else info match { - case qual: NameInfo.Qualified => this + case qual: QualifiedInfo => this case _ => underlying.rewrite(f).derived(info) } def collect[T](f: PartialFunction[Name, T]): Option[T] = if (f.isDefinedAt(this)) Some(f(this)) else info match { - case qual: NameInfo.Qualified => None + case qual: QualifiedInfo => None case _ => underlying.collect(f) } def mapLast(f: SimpleTermName => SimpleTermName): ThisName = info match { - case qual: NameInfo.Qualified => underlying.derived(qual.map(f)) + case qual: QualifiedInfo => underlying.derived(qual.map(f)) case _ => underlying.mapLast(f).derived(info) } def mapParts(f: SimpleTermName => SimpleTermName): ThisName = info match { - case qual: NameInfo.Qualified => underlying.mapParts(f).derived(qual.map(f)) + case qual: QualifiedInfo => underlying.mapParts(f).derived(qual.map(f)) case _ => underlying.mapParts(f).derived(info) } } @@ -506,17 +511,16 @@ object Names { implicit val NameOrdering: Ordering[Name] = new Ordering[Name] { private def compareInfos(x: NameInfo, y: NameInfo): Int = - if (x.kind != y.kind) x.kind - y.kind + if (x.tag != y.tag) x.tag - y.tag else x match { - case x: NameInfo.Qualified => + case x: QualifiedInfo => y match { - case y: NameInfo.Qualified => - val s = x.separator.compareTo(y.separator) - if (s == 0) compareSimpleNames(x.name, y.name) else s + case y: QualifiedInfo => + compareSimpleNames(x.name, y.name) } - case x: NameInfo.Numbered => + case x: NumberedInfo => y match { - case y: NameInfo.Numbered => + case y: NumberedInfo => x.num - y.num } case _ => diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index e5e2165ce..70730b841 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -18,6 +18,8 @@ object StdNames { object str { val EXPAND_SEPARATOR = "$$" val TRAIT_SETTER_SEPARATOR = "$_setter_$" + val SUPER_PREFIX = "super$" + val INITIALIZER_PREFIX = "initial$" } abstract class DefinedNames[N <: Name] { diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index 845da95f2..fa39c9782 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -4,7 +4,7 @@ package core import Periods._, Contexts._, Symbols._, Denotations._, Names._, NameOps._, Annotations._ import Types._, Flags._, Decorators._, DenotTransformers._, StdNames._, Scopes._, Comments._ -import NameOps._ +import NameOps._, NameExtractors._ import Scopes.Scope import collection.mutable import collection.immutable.BitSet @@ -406,14 +406,14 @@ object SymDenotations { } var prefix = encl.fullNameSeparated(separator) val fn = - if (Config.semanticNames && NameInfo.qualifier.contains(sep)) { + if (Config.semanticNames && separatorToQualified.contains(sep)) { if (sep == "$") // duplicate scalac's behavior: don't write a double '$$' for module class members. - prefix = prefix.exclude(NameInfo.ModuleClassKind) + prefix = prefix.exclude(ModuleClassName) name rewrite { case n: SimpleTermName => val n1 = if (filler.isEmpty) n else termName(filler ++ n) - prefix.derived(NameInfo.qualifier(sep)(n1)) + separatorToQualified(sep)(prefix.toTermName, n1) } } else { diff --git a/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala b/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala index 61a2c7fc5..e82a9b618 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala @@ -4,8 +4,10 @@ package core package tasty import collection.mutable -import Names.{Name, chrs, DerivedTermName, SimpleTermName} -import Decorators._, NameOps._ +import Names.{Name, chrs, SimpleTermName} +import NameOps.NameDecorator +import NameExtractors._ +import Decorators._ import TastyBuffer._ import scala.io.Codec import TastyName._ @@ -27,20 +29,19 @@ class NameBuffer extends TastyBuffer(10000) { def nameIndex(name: Name, toTasty: SimpleTermName => TastyName): NameRef = { val tname = name.toTermName match { - case DerivedTermName(name1, NameInfo.ModuleClass) => + case ModuleClassName(name1) => ModuleClass(nameIndex(name1, toTasty)) - case DerivedTermName(name1, NameInfo.SuperAccessor) => + case SuperAccessorName(name1) => SuperAccessor(nameIndex(name1, toTasty)) - case DerivedTermName(prefix, qual: NameInfo.Qualified) => - val tcon: (NameRef, NameRef) => TastyName = qual match { - case _: NameInfo.Select => Qualified - case _: NameInfo.Flatten => Flattened - case _: NameInfo.Expand => Expanded - } - tcon(nameIndex(prefix, toTasty), nameIndex(qual.name)) - case DerivedTermName(prefix, NameInfo.DefaultGetter(num)) => + case QualifiedName(prefix, selector) => + Qualified(nameIndex(prefix, toTasty), nameIndex(selector)) + case FlattenedName(prefix, selector) => + Flattened(nameIndex(prefix, toTasty), nameIndex(selector)) + case XpandedName(prefix, selector) => + Expanded(nameIndex(prefix, toTasty), nameIndex(selector)) + case DefaultGetterName(prefix, num) => DefaultGetter(nameIndex(prefix, toTasty), num) - case DerivedTermName(prefix, NameInfo.Variant(sign)) => + case VariantName(prefix, sign) => Variant(nameIndex(prefix, toTasty), sign) case name1 => if (name1.isShadowedName) Shadowed(nameIndex(name1.revertShadowed, toTasty)) diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala index e73d6ed0d..d25adfd29 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -9,7 +9,7 @@ import TastyFormat._ import Contexts._, Symbols._, Types._, Names._, Constants._, Decorators._, Annotations._, StdNames.tpnme, NameOps._ import collection.mutable import typer.Inliner -import NameOps._ +import NameOps._, NameExtractors._ import StdNames.nme import TastyBuffer._ import TypeApplications._ @@ -62,13 +62,13 @@ class TreePickler(pickler: TastyPickler) { private def pickleName(sym: Symbol)(implicit ctx: Context): Unit = { val nameRef = if (Config.semanticNames) { - if (sym is Flags.ExpandedName) assert(sym.name.is(NameInfo.ExpandKind)) + if (sym is Flags.ExpandedName) assert(sym.name.is(XpandedName)) nameIndex(sym.name) } else { def encodeSuper(name: Name): TastyName.NameRef = if (sym is Flags.SuperAccessor) { - val SuperAccessorName(n) = name + val NameOps.SuperAccessorName(n) = name nameIndex(TastyName.SuperAccessor(nameIndex(n))) } else nameIndex(name) if (sym is Flags.ExpandedName) diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index e83a6f195..f74cdc36a 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -5,6 +5,7 @@ package tasty import Contexts._, Symbols._, Types._, Scopes._, SymDenotations._, Names._, NameOps._ import StdNames._, Denotations._, Flags._, Constants._, Annotations._ +import NameExtractors._ import util.Positions._ import ast.{tpd, Trees, untpd} import Trees._ @@ -91,11 +92,11 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle case ModuleClass(original) => toTermName(original).moduleClassName.toTermName case SuperAccessor(accessed) => toTermName(accessed).superName case DefaultGetter(meth, num) => toTermName(meth).defaultGetterName(num) - case Variant(original, sign) => toTermName(original).derived(NameInfo.Variant(sign)) + case Variant(original, sign) => VariantName(toTermName(original), sign) } private def qualTermName(qual: NameRef, name: NameRef, sep: String) = - toTermName(qual).derived(NameInfo.qualifier(sep)(toTermName(name).asSimpleName)) + separatorToQualified(sep)(toTermName(qual), toTermName(name).asSimpleName) def toTermName(ref: NameRef): TermName = toTermName(tastyName(ref)) def toTypeName(ref: NameRef): TypeName = toTermName(ref).toTypeName -- cgit v1.2.3