Skip to content

Commit 11fd151

Browse files
committed
Rename ConstructorProxy to PhantomSymbol
1 parent c4482f1 commit 11fd151

File tree

12 files changed

+27
-34
lines changed

12 files changed

+27
-34
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ object Flags {
434434
val (Permanent @ _, _, _) = newFlags(61, "<permanent>")
435435

436436
/** Symbol is a constructor proxy (either companion, or apply method) */
437-
val (ConstructorProxy @ _, _, _) = newFlags(62, "<constructor proxy>") // (could be merged with Lifted)
437+
val (PhantomSymbol @ _, _, _) = newFlags(62, "<phantom symbol>") // (could be merged with Lifted)
438438

439-
val CaptureParam = ConstructorProxy
439+
val CaptureParam = PhantomSymbol
440440

441441
// --------- Combined Flag Sets and Conjunctions ----------------------
442442

@@ -473,7 +473,7 @@ object Flags {
473473
Scala2SpecialFlags, MutableOrOpen, Opaque, Touched, JavaStatic,
474474
OuterOrCovariant, LabelOrContravariant, CaseAccessor, Tracked,
475475
Extension, NonMember, Implicit, Given, Permanent, Synthetic, Exported,
476-
SuperParamAliasOrScala2x, Inline, Macro, ConstructorProxy, Invisible)
476+
SuperParamAliasOrScala2x, Inline, Macro, PhantomSymbol, Invisible)
477477

478478
/** Flags that are not (re)set when completing the denotation, or, if symbol is
479479
* a top-level class or object, when completing the denotation once the class
@@ -527,7 +527,7 @@ object Flags {
527527
val RetainedModuleValAndClassFlags: FlagSet =
528528
AccessFlags | Package | Case |
529529
Synthetic | JavaDefined | JavaStatic | Artifact |
530-
Lifted | MixedIn | Specialized | ConstructorProxy | Invisible | Erased
530+
Lifted | MixedIn | Specialized | PhantomSymbol | Invisible | Erased
531531

532532
/** Flags that can apply to a module val */
533533
val RetainedModuleValFlags: FlagSet = RetainedModuleValAndClassFlags |
@@ -567,8 +567,8 @@ object Flags {
567567
val EnumCase: FlagSet = Case | Enum
568568
val CovariantLocal: FlagSet = Covariant | Local // A covariant type parameter
569569
val ContravariantLocal: FlagSet = Contravariant | Local // A contravariant type parameter
570-
val EffectivelyErased = ConstructorProxy | Erased
571-
val ConstructorProxyModule: FlagSet = ConstructorProxy | Module
570+
val EffectivelyErased = PhantomSymbol | Erased
571+
val ConstructorProxyModule: FlagSet = PhantomSymbol | Module
572572
val DefaultParameter: FlagSet = HasDefault | Param // A Scala 2x default parameter
573573
val DeferredInline: FlagSet = Deferred | Inline
574574
val DeferredMethod: FlagSet = Deferred | Method
@@ -581,7 +581,7 @@ object Flags {
581581
val FinalOrInline: FlagSet = Final | Inline
582582
val FinalOrModuleClass: FlagSet = Final | ModuleClass // A module class or a final class
583583
val EffectivelyFinalFlags: FlagSet = Final | Private
584-
val ExcludedForwarder: Flags.FlagSet = Specialized | Lifted | Protected | JavaStatic | Private | Macro | ConstructorProxy
584+
val ExcludedForwarder: Flags.FlagSet = Specialized | Lifted | Protected | JavaStatic | Private | Macro | PhantomSymbol
585585
val FinalOrSealed: FlagSet = Final | Sealed
586586
val GivenOrImplicit: FlagSet = Given | Implicit
587587
val GivenOrImplicitVal: FlagSet = GivenOrImplicit.toTermFlags

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ object NamerOps:
114114
private val NoConstructorProxyNeededFlags = Abstract | Trait | Case | Synthetic | Module | Invisible
115115

116116
/** The flags of a constructor companion */
117-
private val ConstructorCompanionFlags = Synthetic | ConstructorProxy
117+
private val ConstructorCompanionFlags = Synthetic | PhantomSymbol
118118

119119
/** The flags of an `apply` method that serves as a constructor proxy */
120-
val ApplyProxyFlags = Synthetic | ConstructorProxy | Inline | Method
120+
val ApplyProxyFlags = Synthetic | PhantomSymbol | Inline | Method
121121

122122
/** If this is a reference to a class and the reference has a stable prefix, the reference
123123
* otherwise NoType
@@ -217,7 +217,7 @@ object NamerOps:
217217
underlyingStableClassRef(mbr.info.loBound): @unchecked match
218218
case ref: TypeRef =>
219219
val proxy = ref.symbol.registeredCompanion
220-
if proxy.is(ConstructorProxy) && !memberExists(cls, mbr.name.toTermName) then
220+
if proxy.is(PhantomSymbol) && !memberExists(cls, mbr.name.toTermName) then
221221
typeConstructorCompanion(mbr, ref.prefix, proxy).entered
222222

223223
if cls.is(Module)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ object SymDenotations {
538538
// doesn't find them it will invalidate whatever referenced them, so
539539
// any reference to a fake companion will lead to extra recompilations.
540540
// Instead, use the class name since it's guaranteed to exist at runtime.
541-
val clsFlatName = if isOneOf(JavaDefined | ConstructorProxy) then flatName.stripModuleClassSuffix else flatName
541+
val clsFlatName = if isOneOf(JavaDefined | PhantomSymbol) then flatName.stripModuleClassSuffix else flatName
542542
builder.append(clsFlatName.mangledString)
543543
builder.toString
544544

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ class SymUtils:
9090
def isContextBoundCompanion(using Context): Boolean =
9191
self.is(Synthetic) && self.infoOrCompleter.typeSymbol == defn.CBCompanion
9292

93-
def isDummyCaptureParam(using Context): Boolean =
94-
self.is(Synthetic) && self.is(CaptureParam)
95-
9693
/** Is this a case class for which a product mirror is generated?
9794
* Excluded are value classes, abstract classes and case classes with more than one
9895
* parameter section.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ object TypeErasure {
271271

272272
if (defn.isPolymorphicAfterErasure(sym)) eraseParamBounds(sym.info.asInstanceOf[PolyType])
273273
else if (sym.isAbstractOrParamType) TypeAlias(WildcardType)
274-
else if sym.is(ConstructorProxy) then NoType
274+
else if sym.is(PhantomSymbol) then NoType
275275
else if (sym.isConstructor) outer.addParam(sym.owner.asClass, erase(tp)(using preErasureCtx))
276276
else if (sym.is(Label)) erase.eraseResult(sym.info)(using preErasureCtx)
277277
else erase.eraseInfo(tp, sym)(using preErasureCtx) match {

compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ object ExtractSemanticDB:
262262

263263
private def excludeSymbol(sym: Symbol)(using Context): Boolean =
264264
!sym.exists
265-
|| sym.is(ConstructorProxy)
265+
|| sym.is(PhantomSymbol)
266266
|| sym.name.isWildcard
267267
|| excludeQual(sym)
268268

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,10 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
349349
def checkUsableAsValue(tree: Tree)(using Context): Tree =
350350
def unusable(msg: Symbol => Message) =
351351
errorTree(tree, msg(tree.symbol))
352-
if tree.symbol.is(ConstructorProxy) then
352+
if tree.symbol.is(PhantomSymbol) then
353353
unusable(ConstructorProxyNotValue(_))
354354
else if tree.symbol.isContextBoundCompanion then
355355
unusable(ContextBoundCompanionNotValue(_))
356-
else if tree.symbol.isDummyCaptureParam then
357-
throw new Exception(s"Dummy capture param ${tree.symbol} should not be used as a value")
358356
else
359357
tree
360358

@@ -709,7 +707,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
709707
case _ =>
710708
if parents1 ne info.parents then info.derivedClassInfo(declaredParents = parents1)
711709
else tp
712-
case _ if sym.is(ConstructorProxy) => NoType
710+
case _ if sym.is(PhantomSymbol) => NoType
713711
case _ => tp
714712

715713
private def argTypeOfCaseClassThatNeedsAbstractFunction1(sym: Symbol)(using Context): Option[List[Type]] =

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class TreeChecker extends Phase with SymTransformer {
6363
}
6464

6565
if (prev.exists)
66-
assert(cur.exists || prev.is(ConstructorProxy), i"companion disappeared from $symd")
66+
assert(cur.exists || prev.is(PhantomSymbol), i"companion disappeared from $symd")
6767
}
6868

6969
def transformSym(symd: SymDenotation)(using Context): SymDenotation = {
@@ -387,9 +387,7 @@ object TreeChecker {
387387
}
388388

389389
def isSymWithoutDef(sym: Symbol)(using Context): Boolean =
390-
sym.is(ConstructorProxy)
391-
|| sym.isContextBoundCompanion
392-
|| sym.isDummyCaptureParam
390+
sym.is(PhantomSymbol) || sym.isContextBoundCompanion
393391

394392
/** Exclude from double definition checks any erased symbols that were
395393
* made `private` in phase `UnlinkErasedDecls`. These symbols will be removed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,8 +2110,8 @@ trait Applications extends Compatibility {
21102110
else 0
21112111
end compareWithTypes
21122112

2113-
if alt1.symbol.is(ConstructorProxy) && !alt2.symbol.is(ConstructorProxy) then -1
2114-
else if alt2.symbol.is(ConstructorProxy) && !alt1.symbol.is(ConstructorProxy) then 1
2113+
if alt1.symbol.is(PhantomSymbol) && !alt2.symbol.is(PhantomSymbol) then -1
2114+
else if alt2.symbol.is(PhantomSymbol) && !alt1.symbol.is(PhantomSymbol) then 1
21152115
else
21162116
val fullType1 = widenGiven(alt1.widen, alt1)
21172117
val fullType2 = widenGiven(alt2.widen, alt2)

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class Namer { typer: Typer =>
140140

141141
def conflict(conflicting: Symbol) =
142142
val other =
143-
if conflicting.is(ConstructorProxy) then conflicting.companionClass
143+
if conflicting.is(PhantomSymbol) then conflicting.companionClass
144144
else conflicting
145145
report.error(AlreadyDefined(name, owner, other), ctx.source.atSpan(span))
146146
conflictsDetected = true
@@ -947,7 +947,7 @@ class Namer { typer: Typer =>
947947
!sd.symbol.is(Deferred) && sd.matches(denot)))
948948

949949
val isClashingSynthetic =
950-
denot.is(Synthetic, butNot = ConstructorProxy) &&
950+
denot.is(Synthetic, butNot = PhantomSymbol) &&
951951
(
952952
(desugar.isRetractableCaseClassMethodName(denot.name)
953953
&& isCaseClassOrCompanion(denot.owner)
@@ -1200,7 +1200,7 @@ class Namer { typer: Typer =>
12001200
case _ => false
12011201
if !sym.isAccessibleFrom(pathType) then
12021202
No("is not accessible")
1203-
else if sym.isConstructor || sym.is(ModuleClass) || sym.is(Bridge) || sym.is(ConstructorProxy) || sym.isAllOf(JavaModule) then
1203+
else if sym.isConstructor || sym.is(ModuleClass) || sym.is(Bridge) || sym.is(PhantomSymbol) || sym.isAllOf(JavaModule) then
12041204
Skip
12051205
// if the cls is a subclass or mixes in the owner of the symbol
12061206
// and either
@@ -1393,7 +1393,7 @@ class Namer { typer: Typer =>
13931393

13941394
def addWildcardForwardersNamed(name: TermName, span: Span): Unit =
13951395
List(name, name.toTypeName)
1396-
.flatMap(pathType.memberBasedOnFlags(_, excluded = Private|Given|ConstructorProxy).alternatives)
1396+
.flatMap(pathType.memberBasedOnFlags(_, excluded = Private|Given|PhantomSymbol).alternatives)
13971397
.foreach(addForwarder(name, _, span)) // ignore if any are not added
13981398

13991399
def addWildcardForwarders(seen: List[TermName], span: Span): Unit =

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ object RefChecks {
434434
}
435435

436436
def emitOverrideError(fullmsg: Message) =
437-
if !(hasErrors && member.is(Synthetic) && member.is(Module) || member.isDummyCaptureParam) then
437+
if !(hasErrors && member.is(Synthetic) && member.is(Module) || member.is(PhantomSymbol)) then
438438
// suppress errors relating to synthetic companion objects if other override
439439
// errors (e.g. relating to the companion class) have already been reported.
440440
if (member.owner == clazz) report.error(fullmsg, member.srcPos)

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
210210
altImports: mutable.ListBuffer[TermRef] | Null = null)(using Context): Type = {
211211
val refctx = ctx
212212
val noImports = ctx.mode.is(Mode.InPackageClauseName)
213-
def suppressErrors = excluded.is(ConstructorProxy)
213+
def suppressErrors = excluded.is(PhantomSymbol)
214214
// when searching for references shadowed by a constructor proxy, do not report errors
215215
def fail(msg: Message) =
216216
if !suppressErrors then report.error(msg, pos)
@@ -649,8 +649,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
649649
*/
650650
def checkNotShadowed(ownType: Type): Type =
651651
ownType match
652-
case ownType: TermRef if ownType.symbol.is(ConstructorProxy) && !ctx.mode.is(Mode.InCaptureSet) =>
653-
findRef(name, pt, EmptyFlags, ConstructorProxy, tree.srcPos) match
652+
case ownType: TermRef if ownType.symbol.is(PhantomSymbol) && !ctx.mode.is(Mode.InCaptureSet) =>
653+
findRef(name, pt, EmptyFlags, PhantomSymbol, tree.srcPos) match
654654
case shadowed: TermRef if !shadowed.symbol.maybeOwner.isEmptyPackage =>
655655
pt match
656656
case pt: FunOrPolyProto =>

0 commit comments

Comments
 (0)