Skip to content

Commit 9f4042a

Browse files
committed
Implement newNormalizedModuleSymbol
Similar to newNormalizedClassSymbol but for modules.
1 parent 429103e commit 9f4042a

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,32 @@ object Symbols {
630630
owner.thisType, modcls, parents, decls, TermRef(owner.thisType, module)),
631631
privateWithin, coord, assocFile)
632632

633+
/** Same as `newCompleteModuleSymbol` except that `parents` can be a list of arbitrary
634+
* types which get normalized into type refs and parameter bindings.
635+
*/
636+
def newNormalizedModuleSymbol(
637+
owner: Symbol,
638+
name: TermName,
639+
modFlags: FlagSet,
640+
clsFlags: FlagSet,
641+
parentTypes: List[Type],
642+
decls: Scope,
643+
privateWithin: Symbol = NoSymbol,
644+
coord: Coord = NoCoord,
645+
assocFile: AbstractFile | Null = null)(using Context): TermSymbol = {
646+
def completer(module: Symbol) = new LazyType {
647+
def complete(denot: SymDenotation)(using Context): Unit = {
648+
val cls = denot.asClass.classSymbol
649+
val decls = newScope
650+
denot.info = ClassInfo(owner.thisType, cls, parentTypes.map(_.dealias), decls, TermRef(owner.thisType, module))
651+
}
652+
}
653+
newModuleSymbol(
654+
owner, name, modFlags, clsFlags,
655+
(module, modcls) => completer(module),
656+
privateWithin, coord, assocFile)
657+
}
658+
633659
/** Create a package symbol with associated package class
634660
* from its non-info fields and a lazy type for loading the package's members.
635661
*/

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,12 +2484,12 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
24842484

24852485
def newModule(owner: Symbol, name: String, modFlags: Flags, clsFlags: Flags, parents: List[TypeRepr], decls: Symbol => List[Symbol], privateWithin: Symbol): Symbol =
24862486
assert(parents.nonEmpty && !parents.head.typeSymbol.is(dotc.core.Flags.Trait), "First parent must be a class")
2487-
val mod = dotc.core.Symbols.newCompleteModuleSymbol(
2487+
val mod = dotc.core.Symbols.newNormalizedModuleSymbol(
24882488
owner,
24892489
name.toTermName,
24902490
modFlags | dotc.core.Flags.ModuleValCreationFlags,
24912491
clsFlags | dotc.core.Flags.ModuleClassCreationFlags,
2492-
parents.asInstanceOf, // FIXME
2492+
parents,
24932493
dotc.core.Scopes.newScope,
24942494
privateWithin)
24952495
val cls = mod.moduleClass.asClass

0 commit comments

Comments
 (0)