@@ -506,21 +506,6 @@ object Symbols {
506
506
def MutableSymbolMap [T ](): EqHashMap [Symbol , T ] = EqHashMap [Symbol , T ]()
507
507
def MutableSymbolMap [T ](initialCapacity : Int ): EqHashMap [Symbol , T ] = EqHashMap [Symbol , T ](initialCapacity)
508
508
509
- // ---- Factory methods for symbol creation ----------------------
510
- //
511
- // All symbol creations should be done via the next two methods.
512
-
513
- /** Create a symbol without a denotation.
514
- * Note this uses a cast instead of a direct type refinement because
515
- * it's debug-friendlier not to create an anonymous class here.
516
- */
517
- def newNakedSymbol [N <: Name ](coord : Coord = NoCoord )(using Context ): Symbol { type ThisName = N } =
518
- new Symbol (coord, ctx.base.nextSymId).asInstanceOf [Symbol { type ThisName = N }]
519
-
520
- /** Create a class symbol without a denotation. */
521
- def newNakedClassSymbol (coord : Coord = NoCoord , assocFile : AbstractFile = null )(using Context ): ClassSymbol =
522
- new ClassSymbol (coord, assocFile, ctx.base.nextSymId)
523
-
524
509
// ---- Symbol creation methods ----------------------------------
525
510
526
511
/** Create a symbol from its fields (info may be lazy) */
@@ -531,20 +516,12 @@ object Symbols {
531
516
info : Type ,
532
517
privateWithin : Symbol = NoSymbol ,
533
518
coord : Coord = NoCoord )(using Context ): Symbol { type ThisName = N } = {
534
- val sym = newNakedSymbol[ N ] (coord)
519
+ val sym = new Symbol (coord, ctx.base.nextSymId). asInstanceOf [ Symbol { type ThisName = N }]
535
520
val denot = SymDenotation (sym, owner, name, flags, info, privateWithin)
536
521
sym.denot = denot
537
522
sym
538
523
}
539
524
540
- /** Create a class symbol from a function producing its denotation */
541
- def newClassSymbolDenoting (denotFn : ClassSymbol => SymDenotation ,
542
- coord : Coord = NoCoord , assocFile : AbstractFile = null )(using Context ): ClassSymbol = {
543
- val cls = newNakedClassSymbol(coord, assocFile)
544
- cls.denot = denotFn(cls)
545
- cls
546
- }
547
-
548
525
/** Create a class symbol from its non-info fields and a function
549
526
* producing its info (the produced info may be lazy).
550
527
*/
@@ -557,7 +534,7 @@ object Symbols {
557
534
coord : Coord = NoCoord ,
558
535
assocFile : AbstractFile = null )(using Context ): ClassSymbol
559
536
= {
560
- val cls = newNakedClassSymbol (coord, assocFile)
537
+ val cls = new ClassSymbol (coord, assocFile, ctx.base.nextSymId )
561
538
val denot = SymDenotation (cls, owner, name, flags, infoFn(cls), privateWithin)
562
539
cls.denot = denot
563
540
cls
@@ -620,19 +597,15 @@ object Symbols {
620
597
assocFile : AbstractFile = null )(using Context ): TermSymbol
621
598
= {
622
599
val base = owner.thisType
623
- val module = newNakedSymbol[TermName ](coord)
624
- val modcls = newNakedClassSymbol(coord, assocFile)
625
600
val modclsFlags = clsFlags | ModuleClassCreationFlags
626
601
val modclsName = name.toTypeName.adjustIfModuleClass(modclsFlags)
627
- val cdenot = SymDenotation (
628
- modcls, owner, modclsName, modclsFlags,
629
- infoFn(module, modcls), privateWithin)
630
- val mdenot = SymDenotation (
631
- module, owner, name, modFlags | ModuleValCreationFlags ,
632
- if (cdenot.isCompleted) TypeRef (owner.thisType, modcls)
633
- else new ModuleCompleter (modcls))
634
- module.denot = mdenot
635
- modcls.denot = cdenot
602
+ val module = newSymbol(
603
+ owner, name, modFlags | ModuleValCreationFlags , NoCompleter , privateWithin, coord)
604
+ val modcls = newClassSymbol(
605
+ owner, modclsName, modclsFlags, infoFn(module, _), privateWithin, coord, assocFile)
606
+ module.info =
607
+ if (modcls.isCompleted) TypeRef (owner.thisType, modcls)
608
+ else new ModuleCompleter (modcls)
636
609
module
637
610
}
638
611
@@ -802,12 +775,13 @@ object Symbols {
802
775
originals
803
776
else {
804
777
val copies : List [Symbol ] = for (original <- originals) yield
805
- original match {
806
- case original : ClassSymbol =>
807
- newNakedClassSymbol(original.coord, original.assocFile)
808
- case _ =>
809
- newNakedSymbol[original.ThisName ](original.coord)
810
- }
778
+ val odenot = original.denot
779
+ original.copy(
780
+ owner = ttmap.mapOwner(odenot.owner),
781
+ flags = odenot.flags &~ Touched ,
782
+ info = NoCompleter ,
783
+ privateWithin = ttmap.mapOwner(odenot.privateWithin),
784
+ coord = original.coord)
811
785
val ttmap1 = ttmap.withSubstitution(originals, copies)
812
786
originals.lazyZip(copies) foreach { (original, copy) =>
813
787
val odenot = original.denot
@@ -845,13 +819,7 @@ object Symbols {
845
819
846
820
end completer
847
821
848
- copy.denot = odenot.copySymDenotation(
849
- symbol = copy,
850
- owner = ttmap1.mapOwner(odenot.owner),
851
- initFlags = odenot.flags &~ Touched ,
852
- info = completer,
853
- privateWithin = ttmap1.mapOwner(odenot.privateWithin), // since this refers to outer symbols, need not include copies (from->to) in ownermap here.
854
- annotations = odenot.annotations)
822
+ copy.info = completer
855
823
copy.denot match
856
824
case cd : ClassDenotation =>
857
825
cd.registeredCompanion = cd.unforcedRegisteredCompanion.subst(originals, copies)
0 commit comments