Skip to content

Commit c2faa98

Browse files
committed
Avoid recomputations of sourceModule and moduleClass
1 parent b01e6a3 commit c2faa98

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,6 +2455,8 @@ object SymDenotations {
24552455
def apply(module: TermSymbol, modcls: ClassSymbol): LazyType = this
24562456

24572457
private var myDecls: Scope = EmptyScope
2458+
private var mySourceModule: Symbol = null
2459+
private var myModuleClass: Symbol = null
24582460
private var mySourceModuleFn: Context ?=> Symbol = LazyType.NoSymbolFn
24592461
private var myModuleClassFn: Context ?=> Symbol = LazyType.NoSymbolFn
24602462

@@ -2464,8 +2466,12 @@ object SymDenotations {
24642466
else sym.info.typeParams
24652467

24662468
def decls: Scope = myDecls
2467-
def sourceModule(using Context): Symbol = mySourceModuleFn
2468-
def moduleClass(using Context): Symbol = myModuleClassFn
2469+
def sourceModule(using Context): Symbol =
2470+
if mySourceModule == null then mySourceModule = mySourceModuleFn
2471+
mySourceModule
2472+
def moduleClass(using Context): Symbol =
2473+
if myModuleClass == null then myModuleClass = myModuleClassFn
2474+
myModuleClass
24692475

24702476
def withDecls(decls: Scope): this.type = { myDecls = decls; this }
24712477
def withSourceModule(sourceModuleFn: Context ?=> Symbol): this.type = { mySourceModuleFn = sourceModuleFn; this }

0 commit comments

Comments
 (0)