summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala17
-rw-r--r--src/compiler/scala/tools/nsc/GlobalSymbolLoaders.scala30
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/ICodes.scala11
-rw-r--r--src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala18
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala2
5 files changed, 36 insertions, 42 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index ceab0625f8..296ba08eef 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -353,22 +353,9 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
}
lazy val loaders = new {
- val symbolTable: Global.this.type = Global.this
+ val global: Global.this.type = Global.this
val platform: Global.this.platform.type = Global.this.platform
- } with SymbolLoaders {
- protected override def lookupMemberAtTyperPhaseIfPossible(sym: Symbol, name: Name): Symbol = {
- def lookup = sym.info.member(name)
- // if loading during initialization of `definitions` typerPhase is not yet set.
- // in that case we simply load the member at the current phase
- if (currentRun.typerPhase eq null)
- lookup
- else
- enteringTyper { lookup }
- }
- protected override def compileLate(srcfile: AbstractFile): Unit =
- currentRun.compileLate(srcfile)
-
- }
+ } with GlobalSymbolLoaders
/** Returns the mirror that loaded given symbol */
def mirrorThatLoaded(sym: Symbol): Mirror = rootMirror
diff --git a/src/compiler/scala/tools/nsc/GlobalSymbolLoaders.scala b/src/compiler/scala/tools/nsc/GlobalSymbolLoaders.scala
new file mode 100644
index 0000000000..6921548230
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/GlobalSymbolLoaders.scala
@@ -0,0 +1,30 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2013 LAMP/EPFL
+ * @author Martin Odersky
+ */
+
+package scala
+package tools
+package nsc
+
+/**
+ * Symbol loaders implementation that wires dependencies using Global.
+ */
+abstract class GlobalSymbolLoaders extends symtab.SymbolLoaders {
+ val global: Global
+ val symbolTable: global.type = global
+ val platform: symbolTable.platform.type
+ import global._
+ def lookupMemberAtTyperPhaseIfPossible(sym: Symbol, name: Name): Symbol = {
+ def lookup = sym.info.member(name)
+ // if loading during initialization of `definitions` typerPhase is not yet set.
+ // in that case we simply load the member at the current phase
+ if (currentRun.typerPhase eq null)
+ lookup
+ else
+ enteringTyper { lookup }
+ }
+
+ protected def compileLate(srcfile: io.AbstractFile): Unit =
+ currentRun.compileLate(srcfile)
+}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala
index fca18eb09e..b9eb8f8aac 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala
@@ -110,15 +110,8 @@ abstract class ICodes extends AnyRef
object icodeReader extends ICodeReader {
lazy val global: ICodes.this.global.type = ICodes.this.global
import global._
- def lookupMemberAtTyperPhaseIfPossible(sym: Symbol, name: Name): Symbol = {
- def lookup = sym.info.member(name)
- // if loading during initialization of `definitions` typerPhase is not yet set.
- // in that case we simply load the member at the current phase
- if (currentRun.typerPhase eq null)
- lookup
- else
- enteringTyper { lookup }
- }
+ def lookupMemberAtTyperPhaseIfPossible(sym: Symbol, name: Name): Symbol =
+ global.loaders.lookupMemberAtTyperPhaseIfPossible(sym, name)
lazy val symbolTable: global.type = global
lazy val loaders: global.loaders.type = global.loaders
def classPath: util.ClassPath[AbstractFile] = ICodes.this.global.platform.classPath
diff --git a/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala b/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala
index 0d756fd309..4b9e056df3 100644
--- a/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala
+++ b/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala
@@ -12,28 +12,12 @@ import scala.tools.nsc.io.AbstractFile
* This class should be used whenever file dependencies and recompile sets
* are managed automatically.
*/
-abstract class BrowsingLoaders extends SymbolLoaders {
+abstract class BrowsingLoaders extends GlobalSymbolLoaders {
val global: Global
- val symbolTable: global.type
- protected def compileLate(srcfile: AbstractFile) = global.currentRun.compileLate(srcfile)
import global._
import syntaxAnalyzer.{OutlineParser, MalformedInput}
- /*
- * BrowsingLoaders has dependency on Global so we can implement this method here instead of forcing subclasses
- * of BrowsingLoaders (e.g. in interactive) to implement it.
- */
- override def lookupMemberAtTyperPhaseIfPossible(sym: Symbol, name: Name): Symbol = {
- def lookup = sym.info.member(name)
- // if loading during initialization of `definitions` typerPhase is not yet set.
- // in that case we simply load the member at the current phase
- if (currentRun.typerPhase eq null)
- lookup
- else
- enteringTyper { lookup }
- }
-
/** In browse mode, it can happen that an encountered symbol is already
* present. For instance, if the source file has a name different from
* the classes and objects it contains, the symbol loader will always
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
index d22352154b..6f27eb8660 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
@@ -30,7 +30,7 @@ abstract class SymbolLoaders {
/**
* Required by ClassfileParser. Check documentation in that class for details.
*/
- protected def lookupMemberAtTyperPhaseIfPossible(sym: Symbol, name: Name): Symbol
+ def lookupMemberAtTyperPhaseIfPossible(sym: Symbol, name: Name): Symbol
/**
* Should forward to `Run.compileLate`. The more principled fix would be to
* determine why this functionality is needed and extract it into a separate