@@ -506,21 +506,6 @@ object Symbols {
506506 def MutableSymbolMap [T ](): EqHashMap [Symbol , T ] = EqHashMap [Symbol , T ]()
507507 def MutableSymbolMap [T ](initialCapacity : Int ): EqHashMap [Symbol , T ] = EqHashMap [Symbol , T ](initialCapacity)
508508
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-
524509// ---- Symbol creation methods ----------------------------------
525510
526511 /** Create a symbol from its fields (info may be lazy) */
@@ -531,20 +516,12 @@ object Symbols {
531516 info : Type ,
532517 privateWithin : Symbol = NoSymbol ,
533518 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 }]
535520 val denot = SymDenotation (sym, owner, name, flags, info, privateWithin)
536521 sym.denot = denot
537522 sym
538523 }
539524
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-
548525 /** Create a class symbol from its non-info fields and a function
549526 * producing its info (the produced info may be lazy).
550527 */
@@ -557,7 +534,7 @@ object Symbols {
557534 coord : Coord = NoCoord ,
558535 assocFile : AbstractFile = null )(using Context ): ClassSymbol
559536 = {
560- val cls = newNakedClassSymbol (coord, assocFile)
537+ val cls = new ClassSymbol (coord, assocFile, ctx.base.nextSymId )
561538 val denot = SymDenotation (cls, owner, name, flags, infoFn(cls), privateWithin)
562539 cls.denot = denot
563540 cls
@@ -620,19 +597,15 @@ object Symbols {
620597 assocFile : AbstractFile = null )(using Context ): TermSymbol
621598 = {
622599 val base = owner.thisType
623- val module = newNakedSymbol[TermName ](coord)
624- val modcls = newNakedClassSymbol(coord, assocFile)
625600 val modclsFlags = clsFlags | ModuleClassCreationFlags
626601 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)
636609 module
637610 }
638611
@@ -802,12 +775,13 @@ object Symbols {
802775 originals
803776 else {
804777 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)
811785 val ttmap1 = ttmap.withSubstitution(originals, copies)
812786 originals.lazyZip(copies) foreach { (original, copy) =>
813787 val odenot = original.denot
@@ -845,13 +819,7 @@ object Symbols {
845819
846820 end completer
847821
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
855823 copy.denot match
856824 case cd : ClassDenotation =>
857825 cd.registeredCompanion = cd.unforcedRegisteredCompanion.subst(originals, copies)
0 commit comments