Skip to content

Commit d18cce9

Browse files
committed
Drop InSuperCall flag
and special handling involved in it. Require to be after phase HoistInSuperCall instead.
1 parent 959676b commit d18cce9

File tree

10 files changed

+14
-33
lines changed

10 files changed

+14
-33
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,6 @@ object Flags {
372372
/** Symbol always defines a fresh named type */
373373
final val Fresh = commonFlag(45, "<fresh>")
374374

375-
/** Symbol is defined in a super call */
376-
final val InSuperCall = commonFlag(46, "<in supercall>")
377-
378375
/** Denotation is in train of being loaded and completed, used to catch cyclic dependencies */
379376
final val Touched = commonFlag(48, "<touched>")
380377

@@ -451,7 +448,7 @@ object Flags {
451448
/** Flags guaranteed to be set upon symbol creation */
452449
final val FromStartFlags =
453450
Module | Package | Deferred | MethodOrHKCommon | Param | ParamAccessor |
454-
Scala2ExistentialCommon | Mutable.toCommonFlags | InSuperCall | Touched | JavaStatic |
451+
Scala2ExistentialCommon | Mutable.toCommonFlags | Touched | JavaStatic |
455452
CovariantOrOuter | ContravariantOrLabel | CaseAccessorOrBaseTypeArg |
456453
Fresh | Frozen | Erroneous | ImplicitCommon | Permanent | Synthetic |
457454
SuperAccessorOrScala2x | Inline
@@ -511,8 +508,7 @@ object Flags {
511508
Accessor | AbsOverride | Stable | Captured | Synchronized
512509

513510
/** Flags that can apply to a module class */
514-
final val RetainedModuleClassFlags: FlagSet = RetainedModuleValAndClassFlags |
515-
InSuperCall | ImplClass
511+
final val RetainedModuleClassFlags: FlagSet = RetainedModuleValAndClassFlags | ImplClass
516512

517513
/** Packages and package classes always have these flags set */
518514
final val PackageCreationFlags =

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

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

852852
/** The class containing this denotation.
853853
* If this denotation is already a class, return itself
854-
* Definitions flagged with InSuperCall are treated specially.
854+
* Definitions flagged with JavaStatic are treated specially.
855855
* Their enclosing class is not the lexically enclosing class,
856856
* but in turn the enclosing class of the latter. This reflects
857857
* the context created by `Context#superCallContext`, `Context#thisCallArgContext`
@@ -862,7 +862,7 @@ object SymDenotations {
862862
*/
863863
final def enclosingClass(implicit ctx: Context): Symbol = {
864864
def enclClass(sym: Symbol, skip: Boolean): Symbol = {
865-
def newSkip = sym.is(InSuperCall) || sym.is(JavaStaticTerm)
865+
def newSkip = sym.is(JavaStaticTerm)
866866
if (!sym.exists)
867867
NoSymbol
868868
else if (sym.isClass)

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ Standard-Section: "ASTs" TopLevelStat*
186186
CONTRAVARIANT // type param marked “-”
187187
SCALA2X // Imported from Scala2.x
188188
DEFAULTparameterized // Method with default params
189-
INSUPERCALL // defined in the argument of a constructor supercall
190189
STABLE // Method that is assumed to be stable
191190
Annotation
192191
Annotation = ANNOTATION Length tycon_Type fullAnnotation_Term
@@ -278,8 +277,7 @@ object TastyFormat {
278277
final val CONTRAVARIANT = 28
279278
final val SCALA2X = 29
280279
final val DEFAULTparameterized = 30
281-
final val INSUPERCALL = 31
282-
final val STABLE = 32
280+
final val STABLE = 31
283281

284282
final val SHARED = 64
285283
final val TERMREFdirect = 65
@@ -403,7 +401,6 @@ object TastyFormat {
403401
| CONTRAVARIANT
404402
| SCALA2X
405403
| DEFAULTparameterized
406-
| INSUPERCALL
407404
| STABLE
408405
| ANNOTATION
409406
| PRIVATEqualified
@@ -469,7 +466,6 @@ object TastyFormat {
469466
case CONTRAVARIANT => "CONTRAVARIANT"
470467
case SCALA2X => "SCALA2X"
471468
case DEFAULTparameterized => "DEFAULTparameterized"
472-
case INSUPERCALL => "INSUPERCALL"
473469
case STABLE => "STABLE"
474470

475471
case SHARED => "SHARED"

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,6 @@ class TreePickler(pickler: TastyPickler) {
577577
if (flags is Synthetic) writeByte(SYNTHETIC)
578578
if (flags is Artifact) writeByte(ARTIFACT)
579579
if (flags is Scala2x) writeByte(SCALA2X)
580-
if (flags is InSuperCall) writeByte(INSUPERCALL)
581580
if (sym.isTerm) {
582581
if (flags is Implicit) writeByte(IMPLICIT)
583582
if ((flags is Lazy) && !(sym is Module)) writeByte(LAZY)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
510510
case CONTRAVARIANT => addFlag(Contravariant)
511511
case SCALA2X => addFlag(Scala2x)
512512
case DEFAULTparameterized => addFlag(DefaultParameterized)
513-
case INSUPERCALL => addFlag(InSuperCall)
514513
case STABLE => addFlag(Stable)
515514
case PRIVATEqualified =>
516515
readByte()

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ class Constructors extends MiniPhaseTransform with IdentityDenotTransformer { th
3030
import tpd._
3131

3232
override def phaseName: String = "constructors"
33-
override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[Memoize])
34-
33+
override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[Memoize], classOf[HoistSuperArgs])
3534

3635
// Collect all private parameter accessors and value definitions that need
3736
// to be retained. There are several reasons why a parameter accessor or
@@ -103,7 +102,7 @@ class Constructors extends MiniPhaseTransform with IdentityDenotTransformer { th
103102
* outer link, so no parameter accessors need to be rewired to parameters
104103
*/
105104
private def noDirectRefsFrom(tree: Tree)(implicit ctx: Context) =
106-
tree.isDef && tree.symbol.isClass && !tree.symbol.is(InSuperCall)
105+
tree.isDef && tree.symbol.isClass
107106

108107
/** Class members that can be eliminated if referenced only from their own
109108
* constructor.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform
5858

5959
override def phaseName: String = "elimByName"
6060

61+
override def runsAfter = Set(classOf[HoistSuperCalls])
6162
override def runsAfterGroupsOf = Set(classOf[Splitter])
6263
// assumes idents and selects have symbols; interferes with splitter distribution
6364
// that's why it's "after group".
@@ -78,9 +79,8 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform
7879
if qual.tpe.derivesFrom(defn.FunctionClass(0)) && isPureExpr(qual) =>
7980
qual
8081
case _ =>
81-
val inSuper = if (ctx.mode.is(Mode.InSuperCall)) InSuperCall else EmptyFlags
8282
val meth = ctx.newSymbol(
83-
ctx.owner, nme.ANON_FUN, Synthetic | Method | inSuper, MethodType(Nil, Nil, argType))
83+
ctx.owner, nme.ANON_FUN, Synthetic | Method, MethodType(Nil, Nil, argType))
8484
Closure(meth, _ =>
8585
atGroupEnd { implicit ctx: Context =>
8686
arg.changeOwner(ctx.owner, meth)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransf
4646
/** List of names of phases that should have finished their processing of all compilation units
4747
* before this phase starts
4848
*/
49-
override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[PatternMatcher])
49+
override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[PatternMatcher], classOf[HoistSuperArgs])
5050

5151
/** Add outer accessors if a class always needs an outer pointer */
5252
override def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context) = tp match {

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
6666

6767
override def relaxedTyping = true
6868

69-
override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[Constructors])
69+
override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[Constructors], classOf[HoistSuperArgs])
7070
// Constructors has to happen before LambdaLift because the lambda lift logic
7171
// becomes simpler if it can assume that parameter accessors have already been
7272
// converted to parameters in super calls. Without this it is very hard to get
@@ -146,14 +146,10 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
146146
if (sym.maybeOwner.isTerm &&
147147
owner.isProperlyContainedIn(liftedOwner(sym)) &&
148148
owner != sym) {
149-
if (sym.is(InSuperCall) && owner.isProperlyContainedIn(sym.enclosingClass))
150-
narrowLiftedOwner(sym, sym.enclosingClass)
151-
else {
152149
ctx.log(i"narrow lifted $sym to $owner")
153150
changedLiftedOwner = true
154151
liftedOwner(sym) = owner
155152
}
156-
}
157153

158154
/** Mark symbol `sym` as being free in `enclosure`, unless `sym` is defined
159155
* in `enclosure` or there is an intermediate class properly containing `enclosure`
@@ -387,7 +383,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
387383
local.copySymDenotation(
388384
owner = newOwner,
389385
name = newName(local),
390-
initFlags = local.flags &~ (InSuperCall | Module) | Private | maybeStatic,
386+
initFlags = local.flags &~ Module | Private | maybeStatic,
391387
// drop Module because class is no longer a singleton in the lifted context.
392388
info = liftedInfo(local)).installAfter(thisTransform)
393389
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,12 @@ class Namer { typer: Typer =>
278278
else name
279279
}
280280

281-
val inSuperCall = if (ctx.mode is Mode.InSuperCall) InSuperCall else EmptyFlags
282-
283281
tree match {
284282
case tree: TypeDef if tree.isClassDef =>
285283
val name = checkNoConflict(tree.name.encode).toTypeName
286284
val flags = checkFlags(tree.mods.flags &~ Implicit)
287285
val cls = recordSym(ctx.newClassSymbol(
288-
ctx.owner, name, flags | inSuperCall,
286+
ctx.owner, name, flags,
289287
cls => adjustIfModule(new ClassCompleter(cls, tree)(ctx), tree),
290288
privateWithinClass(tree.mods), tree.namePos, ctx.source.file), tree)
291289
cls.completer.asInstanceOf[ClassCompleter].init()
@@ -296,8 +294,6 @@ class Namer { typer: Typer =>
296294
val isDeferred = lacksDefinition(tree)
297295
val deferred = if (isDeferred) Deferred else EmptyFlags
298296
val method = if (tree.isInstanceOf[DefDef]) Method else EmptyFlags
299-
val inSuperCall1 = if (tree.mods is ParamOrAccessor) EmptyFlags else inSuperCall
300-
// suppress inSuperCall for constructor parameters
301297
val higherKinded = tree match {
302298
case TypeDef(_, LambdaTypeTree(_, _)) if isDeferred => HigherKinded
303299
case _ => EmptyFlags
@@ -320,7 +316,7 @@ class Namer { typer: Typer =>
320316
}
321317

322318
recordSym(ctx.newSymbol(
323-
ctx.owner, name, flags | deferred | method | higherKinded | inSuperCall1,
319+
ctx.owner, name, flags | deferred | method | higherKinded,
324320
adjustIfModule(completer, tree),
325321
privateWithinClass(tree.mods), tree.namePos), tree)
326322
case tree: Import =>

0 commit comments

Comments
 (0)