Skip to content

Commit 21ab9a1

Browse files
committed
Get rid of ExpandedName flag
1 parent 0efd6b9 commit 21ab9a1

20 files changed

+57
-48
lines changed

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
421421
val Flag_METHOD: Flags = Flags.Method.bits
422422
val ExcludedForwarderFlags: Flags = {
423423
Flags.Specialized | Flags.Lifted | Flags.Protected | Flags.JavaStatic |
424-
Flags.ExpandedName | Flags.Bridge | Flags.VBridge | Flags.Private | Flags.Macro
424+
Flags.Bridge | Flags.VBridge | Flags.Private | Flags.Macro
425425
}.bits
426426

427427

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ object desugar {
244244
def typeDef(tdef: TypeDef)(implicit ctx: Context): Tree = {
245245
if (tdef.mods is PrivateLocalParam) {
246246
val tparam = cpy.TypeDef(tdef)(name = tdef.name.expandedName(ctx.owner))
247-
.withMods(tdef.mods &~ PrivateLocal | ExpandedName)
247+
.withMods(tdef.mods &~ PrivateLocal)
248248
val alias = cpy.TypeDef(tdef)(rhs = refOfDef(tparam))
249249
.withMods(tdef.mods & VarianceFlags | PrivateLocalParamAccessor | Synthetic)
250250
Thicket(tparam, alias)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Definitions {
6767
enterTypeField(cls, name, flags | ClassTypeParamCreationFlags, scope)
6868

6969
private def enterSyntheticTypeParam(cls: ClassSymbol, paramFlags: FlagSet, scope: MutableScope, suffix: String = "T0") =
70-
enterTypeParam(cls, suffix.toTypeName.expandedName(cls), ExpandedName | paramFlags, scope)
70+
enterTypeParam(cls, suffix.toTypeName.expandedName(cls), paramFlags, scope)
7171

7272
// NOTE: Ideally we would write `parentConstrs: => Type*` but SIP-24 is only
7373
// implemented in Dotty and not in Scala 2.

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,6 @@ object Flags {
272272
*/
273273
final val Synthetic = commonFlag(18, "<synthetic>")
274274

275-
/** Symbol's name is expanded */
276-
final val ExpandedName = commonFlag(19, "<expandedname>")
277-
278275
/** A covariant type variable / an outer accessor */
279276
final val CovariantOrOuter = commonFlag(20, "")
280277
final val Covariant = typeFlag(20, "<covariant>")
@@ -308,7 +305,6 @@ object Flags {
308305
final val CaseAccessor = termFlag(25, "<caseaccessor>")
309306

310307
/** A binding for a type parameter of a base class or trait.
311-
* TODO: Replace with combination of isType, ExpandedName, and Override?
312308
*/
313309
final val BaseTypeArg = typeFlag(25, "<basetypearg>")
314310

@@ -409,9 +405,6 @@ object Flags {
409405
final val Scala2ExistentialCommon = commonFlag(55, "<existential>")
410406
final val Scala2Existential = Scala2ExistentialCommon.toTypeFlags
411407

412-
/** An overloaded symbol (Scala 2.x only) */
413-
final val Scala2Overloaded = termFlag(56, "<overloaded>")
414-
415408
/** A module variable (Scala 2.x only) */
416409
final val Scala2ModuleVar = termFlag(57, "<modulevar>")
417410

@@ -424,6 +417,13 @@ object Flags {
424417
/** A method that is known to have inherited default parameters */
425418
final val InheritedDefaultParams = termFlag(60, "<inherited-default-param>")
426419

420+
/** Translation of Scala2's EXPANDEDNAME flag. This flag is never stored in
421+
* symbols, is only used locally when reading the flags of a Scala2 symbol.
422+
* It's therefore safe to share the code with `InheritedDefaultParams` because
423+
* the latter is never present in Scala2 unpickle info.
424+
*/
425+
final val Scala2ExpandedName = InheritedDefaultParams.toCommonFlags
426+
427427
/** A method that is known to have no default parameters */
428428
final val NoDefaultParams = termFlag(61, "<no-default-param>")
429429

@@ -475,7 +475,7 @@ object Flags {
475475

476476
/** Flags that are passed from a type parameter of a class to a refinement symbol
477477
* that sets the type parameter */
478-
final val RetainedTypeArgFlags = VarianceFlags | ExpandedName | Protected | Local
478+
final val RetainedTypeArgFlags = VarianceFlags | Protected | Local
479479

480480
/** Modules always have these flags set */
481481
final val ModuleCreationFlags = ModuleVal | Lazy | Final | Stable
@@ -502,7 +502,7 @@ object Flags {
502502
*/
503503
final val RetainedModuleValAndClassFlags: FlagSet =
504504
AccessFlags | Package | Case |
505-
Synthetic | ExpandedName | JavaDefined | JavaStatic | Artifact |
505+
Synthetic | JavaDefined | JavaStatic | Artifact |
506506
Erroneous | Lifted | MixedIn | Specialized
507507

508508
/** Flags that can apply to a module val */
@@ -550,9 +550,6 @@ object Flags {
550550
/** A private accessor */
551551
final val PrivateAccessor = allOf(Private, Accessor)
552552

553-
/** A type parameter with synthesized name */
554-
final val ExpandedTypeParam = allOf(ExpandedName, TypeParam)
555-
556553
/** An inline method */
557554
final val InlineMethod = allOf(Inline, Method)
558555

@@ -578,7 +575,7 @@ object Flags {
578575
final val FinalOrInline = Final | Inline
579576

580577
/** If symbol of a type alias has these flags, prefer the alias */
581-
final val AliasPreferred = TypeParam | BaseTypeArg | ExpandedName
578+
final val AliasPreferred = TypeParam | BaseTypeArg
582579

583580
/** A covariant type parameter instance */
584581
final val LocalCovariant = allOf(Local, Covariant)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ object NameExtractors {
4545

4646
class PrefixNameExtractor(tag: Int, prefix: String, infoString: String) extends ClassifiedNameExtractor(tag, infoString) {
4747
def mkString(underlying: TermName, info: ThisInfo) =
48-
underlying.mapLast(n => termName(prefix + n)).toString
48+
underlying.mapLast(n => termName(prefix + n.toString)).toString
4949
}
5050

5151
class SuffixNameExtractor(tag: Int, suffix: String, infoString: String) extends ClassifiedNameExtractor(tag, infoString) {
@@ -99,7 +99,7 @@ object NameExtractors {
9999

100100
object QualifiedName extends QualifiedNameExtractor(QUALIFIED, ".", "Qualified")
101101
object FlattenedName extends QualifiedNameExtractor(FLATTENED, "$", "Flattened")
102-
object XpandedName extends QualifiedNameExtractor(EXPANDED, str.EXPAND_SEPARATOR, "Expanded")
102+
object ExpandedName extends QualifiedNameExtractor(EXPANDED, str.EXPAND_SEPARATOR, "Expanded")
103103
object TraitSetterName extends QualifiedNameExtractor(TRAITSETTER, str.TRAIT_SETTER_SEPARATOR, "TraitSetter")
104104

105105
object DefaultGetterName extends NumberedNameExtractor(DEFAULTGETTER, "DefaultGetter") {
@@ -146,6 +146,6 @@ object NameExtractors {
146146
val separatorToQualified: Map[String, QualifiedNameExtractor] =
147147
Map("." -> QualifiedName,
148148
"$" -> FlattenedName,
149-
str.EXPAND_SEPARATOR -> XpandedName,
149+
str.EXPAND_SEPARATOR -> ExpandedName,
150150
str.TRAIT_SETTER_SEPARATOR -> TraitSetterName)
151151
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ object NameOps {
138138
/** The expanded name of `name` relative to given class `base`.
139139
*/
140140
def expandedName(base: Symbol, separator: Name)(implicit ctx: Context): N =
141-
expandedName(if (base is Flags.ExpandedName) base.name else base.fullNameSeparated("$"), separator)
141+
expandedName(if (base.name.is(ExpandedName)) base.name else base.fullNameSeparated("$"), separator)
142142

143143
def expandedName(base: Symbol)(implicit ctx: Context): N = expandedName(base, nme.EXPAND_SEPARATOR)
144144

@@ -161,7 +161,7 @@ object NameOps {
161161

162162
/** Revert the expanded name. */
163163
def unexpandedName: N = likeTyped {
164-
name.rewrite { case XpandedName(_, unexp) => unexp }
164+
name.rewrite { case ExpandedName(_, unexp) => unexp }
165165
}
166166

167167
def unexpandedNameOfMangled: N = likeTyped {
@@ -175,8 +175,8 @@ object NameOps {
175175
if (idx < 0) name else (name drop (idx + nme.EXPAND_SEPARATOR.length))
176176
}
177177

178-
def expandedPrefix: N = likeTyped { name.exclude(XpandedName) }
179-
178+
def expandedPrefix: N = likeTyped { name.exclude(ExpandedName) }
179+
180180
def expandedPrefixOfMangled: N = {
181181
val idx = name.lastIndexOfSlice(nme.EXPAND_SEPARATOR)
182182
assert(idx >= 0)
@@ -188,7 +188,7 @@ object NameOps {
188188
val unmangled = unexpandedNameOfMangled
189189
if (name eq unmangled) name
190190
else likeTyped(
191-
XpandedName(expandedPrefixOfMangled.toTermName, unmangled.asSimpleName))
191+
ExpandedName(expandedPrefixOfMangled.toTermName, unmangled.asSimpleName))
192192
}
193193
else name
194194

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ import scala.annotation.tailrec
3434
case class Signature(paramsSig: List[TypeName], resSig: TypeName) {
3535
import Signature._
3636

37+
/* FIXME does not compile under dotty, we get a missing param error
38+
def checkUnqual(name: TypeName) = name mapParts { part =>
39+
assert(!part.contains('.'), name)
40+
part
41+
}
42+
paramsSig.foreach(checkUnqual)
43+
checkUnqual(resSig)
44+
*/
3745
/** Two names are consistent if they are the same or one of them is tpnme.Uninstantiated */
3846
private def consistent(name1: TypeName, name2: TypeName) =
3947
name1 == name2 || name1 == tpnme.Uninstantiated || name2 == tpnme.Uninstantiated

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ object SymDenotations {
367367

368368
/** The expanded name of this denotation. */
369369
final def expandedName(implicit ctx: Context) =
370-
if (is(ExpandedName) || isConstructor) name
370+
if (name.is(ExpandedName) || isConstructor) name
371371
else {
372372
def legalize(name: Name): Name = // JVM method names may not contain `<' or `>' characters
373373
if (is(Method)) name.replace('<', '(').replace('>', ')') else name
@@ -1210,9 +1210,7 @@ object SymDenotations {
12101210
/** If denotation is private, remove the Private flag and expand the name if necessary */
12111211
def ensureNotPrivate(implicit ctx: Context) =
12121212
if (is(Private))
1213-
copySymDenotation(
1214-
name = expandedName,
1215-
initFlags = this.flags &~ Private | ExpandedName)
1213+
copySymDenotation(name = expandedName, initFlags = this.flags &~ Private)
12161214
else this
12171215
}
12181216

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import util.Stats._
1111
import util.common._
1212
import Names._
1313
import NameOps._
14+
import NameExtractors._
1415
import Flags._
1516
import StdNames.tpnme
1617
import util.Positions.Position
@@ -464,11 +465,6 @@ class TypeApplications(val self: Type) extends AnyVal {
464465
self
465466
case _ =>
466467
val v = tparam.paramVariance
467-
/* Not neeeded.
468-
if (v > 0 && !(tparam is Local) && !(tparam is ExpandedTypeParam)) TypeBounds.upper(self)
469-
else if (v < 0 && !(tparam is Local) && !(tparam is ExpandedTypeParam)) TypeBounds.lower(self)
470-
else
471-
*/
472468
TypeAlias(self, v)
473469
}
474470

@@ -510,13 +506,14 @@ class TypeApplications(val self: Type) extends AnyVal {
510506
*/
511507
final def baseTypeWithArgs(base: Symbol)(implicit ctx: Context): Type = ctx.traceIndented(s"btwa ${self.show} wrt $base", core, show = true) {
512508
def default = self.baseTypeRef(base).appliedTo(baseArgInfos(base))
509+
def isExpandedTypeParam(sym: Symbol) = sym.is(TypeParam) && sym.name.is(ExpandedName)
513510
self match {
514511
case tp: TypeRef =>
515512
tp.info match {
516513
case TypeBounds(_, hi) => hi.baseTypeWithArgs(base)
517514
case _ => default
518515
}
519-
case tp @ RefinedType(parent, name, _) if !tp.member(name).symbol.is(ExpandedTypeParam) =>
516+
case tp @ RefinedType(parent, name, _) if !isExpandedTypeParam(tp.member(name).symbol) =>
520517
tp.wrapIfMember(parent.baseTypeWithArgs(base))
521518
case tp: TermRef =>
522519
tp.underlying.baseTypeWithArgs(base)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class NameBuffer extends TastyBuffer(10000) {
6262
withLength { writeNameRef(qualified); writeNameRef(selector) }
6363
case FlattenedName(qualified, selector) =>
6464
withLength { writeNameRef(qualified); writeNameRef(selector) }
65-
case XpandedName(prefix, original) =>
65+
case ExpandedName(prefix, original) =>
6666
withLength { writeNameRef(prefix); writeNameRef(original) }
6767
case SignedName(original, Signature(params, result)) =>
6868
withLength(

0 commit comments

Comments
 (0)