Skip to content

Turn SymbolLoaders into an object #4507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/JavaPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class JavaPlatform extends Platform {
currentClassPath = Some(subst.getOrElse(cp, cp))
}

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

/** Is the SAMType `cls` also a SAM under the rules of the JVM? */
def isSam(cls: ClassSymbol)(implicit ctx: Context): Boolean =
Expand Down
3 changes: 0 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,6 @@ object Contexts {
/** The initial context */
val initialCtx: Context = new InitialContext(this, settings)

/** The symbol loaders */
val loaders = new SymbolLoaders

/** The platform, initialized by `initPlatform()`. */
private[this] var _platform: Platform = _

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ object SymDenotations {
* Right now, the only usage is for the AnyRef alias in Definitions.
*/
final private[core] def currentPackageDecls(implicit ctx: Context): MutableScope = myInfo match {
case pinfo: SymbolLoaders # PackageLoader => pinfo.currentDecls
case pinfo: SymbolLoaders.PackageLoader => pinfo.currentDecls
case _ => unforcedDecls.openForMutations
}

Expand Down
9 changes: 3 additions & 6 deletions compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@ import parsing.Parsers.OutlineParser
import reporting.trace

object SymbolLoaders {
import ast.untpd._

/** A marker trait for a completer that replaces the original
* Symbol loader for an unpickled root.
*/
trait SecondCompleter
}

/** A base class for Symbol loaders with some overridable behavior */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that SymbolLoaders was meant to be extended. Make the protected members private?

class SymbolLoaders {
import ast.untpd._

protected def enterNew(
private def enterNew(
owner: Symbol, member: Symbol,
completer: SymbolLoader, scope: Scope = EmptyScope)(implicit ctx: Context): Symbol = {
val comesFromScan =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ class ClassfileParser(
}

def enterClassAndModule(entry: InnerClassEntry, file: AbstractFile, jflags: Int) = {
ctx.base.loaders.enterClassAndModule(
SymbolLoaders.enterClassAndModule(
getOwner(jflags),
entry.originalName,
new ClassfileLoader(file),
Expand Down