Skip to content

Commit 6b69732

Browse files
committed
Turn SymbolLoaders into an object
The extra flexibility of a class isn't useful here and leads to worse code being generated (e.g. it requires PackageLoader to carry an outer accessor).
1 parent d109c0b commit 6b69732

File tree

5 files changed

+6
-12
lines changed

5 files changed

+6
-12
lines changed

compiler/src/dotty/tools/dotc/config/JavaPlatform.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class JavaPlatform extends Platform {
3535
currentClassPath = Some(subst.getOrElse(cp, cp))
3636
}
3737

38-
def rootLoader(root: TermSymbol)(implicit ctx: Context): SymbolLoader = new ctx.base.loaders.PackageLoader(root, classPath)
38+
def rootLoader(root: TermSymbol)(implicit ctx: Context): SymbolLoader = new SymbolLoaders.PackageLoader(root, classPath)
3939

4040
/** Is the SAMType `cls` also a SAM under the rules of the JVM? */
4141
def isSam(cls: ClassSymbol)(implicit ctx: Context): Boolean =

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,6 @@ object Contexts {
551551
/** The initial context */
552552
val initialCtx: Context = new InitialContext(this, settings)
553553

554-
/** The symbol loaders */
555-
val loaders = new SymbolLoaders
556-
557554
/** The platform, initialized by `initPlatform()`. */
558555
private[this] var _platform: Platform = _
559556

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ object SymDenotations {
377377
* Right now, the only usage is for the AnyRef alias in Definitions.
378378
*/
379379
final private[core] def currentPackageDecls(implicit ctx: Context): MutableScope = myInfo match {
380-
case pinfo: SymbolLoaders # PackageLoader => pinfo.currentDecls
380+
case pinfo: SymbolLoaders.PackageLoader => pinfo.currentDecls
381381
case _ => unforcedDecls.openForMutations
382382
}
383383

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,14 @@ import parsing.Parsers.OutlineParser
1919
import reporting.trace
2020

2121
object SymbolLoaders {
22+
import ast.untpd._
23+
2224
/** A marker trait for a completer that replaces the original
2325
* Symbol loader for an unpickled root.
2426
*/
2527
trait SecondCompleter
26-
}
27-
28-
/** A base class for Symbol loaders with some overridable behavior */
29-
class SymbolLoaders {
30-
import ast.untpd._
3128

32-
protected def enterNew(
29+
private def enterNew(
3330
owner: Symbol, member: Symbol,
3431
completer: SymbolLoader, scope: Scope = EmptyScope)(implicit ctx: Context): Symbol = {
3532
val comesFromScan =

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ class ClassfileParser(
703703
}
704704

705705
def enterClassAndModule(entry: InnerClassEntry, file: AbstractFile, jflags: Int) = {
706-
ctx.base.loaders.enterClassAndModule(
706+
SymbolLoaders.enterClassAndModule(
707707
getOwner(jflags),
708708
entry.originalName,
709709
new ClassfileLoader(file),

0 commit comments

Comments
 (0)