summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2005-09-28 15:14:00 +0000
committerMartin Odersky <odersky@gmail.com>2005-09-28 15:14:00 +0000
commit9055a919a643f98e38c342d15037655dc50bca19 (patch)
tree71afa87274541c0ab4f483e0743397bfdd435acf /sources
parentb65ef22c4d8de7784d021e0314fc520a5098092b (diff)
downloadscala-9055a919a643f98e38c342d15037655dc50bca19.tar.gz
scala-9055a919a643f98e38c342d15037655dc50bca19.tar.bz2
scala-9055a919a643f98e38c342d15037655dc50bca19.zip
*** empty log message ***
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/tools/nsc/CompilerCommand.scala2
-rwxr-xr-xsources/scala/tools/nsc/CompilerRun.scala18
-rwxr-xr-xsources/scala/tools/nsc/Global.scala286
-rw-r--r--sources/scala/tools/nsc/Interpreter.scala2
-rwxr-xr-xsources/scala/tools/nsc/Main.scala34
-rw-r--r--sources/scala/tools/nsc/Phase.scala7
-rw-r--r--sources/scala/tools/nsc/Settings.scala3
-rw-r--r--sources/scala/tools/nsc/ast/TreePrinters.scala2
-rwxr-xr-xsources/scala/tools/nsc/symtab/Definitions.scala7
-rw-r--r--sources/scala/tools/nsc/symtab/Flags.scala1
-rw-r--r--sources/scala/tools/nsc/symtab/InfoTransformers.scala18
-rwxr-xr-xsources/scala/tools/nsc/symtab/SymbolLoaders.scala3
-rwxr-xr-xsources/scala/tools/nsc/symtab/SymbolTable.scala13
-rwxr-xr-xsources/scala/tools/nsc/symtab/Symbols.scala55
-rwxr-xr-xsources/scala/tools/nsc/symtab/Types.scala26
-rwxr-xr-xsources/scala/tools/nsc/symtab/classfile/Pickler.scala4
-rwxr-xr-xsources/scala/tools/nsc/symtab/classfile/UnPickler.scala2
-rwxr-xr-xsources/scala/tools/nsc/transform/AddInterfaces.scala21
-rwxr-xr-xsources/scala/tools/nsc/transform/Erasure.scala6
-rwxr-xr-xsources/scala/tools/nsc/transform/InfoTransform.scala12
-rwxr-xr-xsources/scala/tools/nsc/transform/Mixin.scala6
-rw-r--r--sources/scala/tools/nsc/transform/Transform.scala3
-rw-r--r--sources/scala/tools/nsc/typechecker/Analyzer.scala2
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Contexts.scala8
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Infer.scala2
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Namers.scala6
-rwxr-xr-xsources/scala/tools/nsc/typechecker/RefChecks.scala6
-rw-r--r--sources/scala/tools/nsc/typechecker/TreeCheckers.scala4
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Typers.scala8
29 files changed, 289 insertions, 278 deletions
diff --git a/sources/scala/tools/nsc/CompilerCommand.scala b/sources/scala/tools/nsc/CompilerCommand.scala
index 09faa06317..9768eaa621 100644
--- a/sources/scala/tools/nsc/CompilerCommand.scala
+++ b/sources/scala/tools/nsc/CompilerCommand.scala
@@ -33,7 +33,7 @@ class CompilerCommand(arguments: List[String], error: String => unit, interactiv
format(setting.helpSyntax) + " " + setting.helpDescription)
.mkString(
"Usage: scalac <options | source files>\n" +
- "where possible options include: \n",
+ "where possible options include: \n ",
"\n ",
"\n");
}
diff --git a/sources/scala/tools/nsc/CompilerRun.scala b/sources/scala/tools/nsc/CompilerRun.scala
new file mode 100755
index 0000000000..a361a1ff28
--- /dev/null
+++ b/sources/scala/tools/nsc/CompilerRun.scala
@@ -0,0 +1,18 @@
+/* NSC -- new scala compiler
+ * Copyright 2005 LAMP/EPFL
+ * @author Martin Odersky
+ */
+// $Id$
+package scala.tools.nsc;
+
+class CompilerRun {
+ def firstPhase: Phase = NoPhase;
+ def terminalPhase: Phase = NoPhase;
+ def namerPhase: Phase = NoPhase;
+ def typerPhase: Phase = NoPhase;
+ def refchecksPhase: Phase = NoPhase;
+ def erasurePhase: Phase = NoPhase;
+ def flattenPhase: Phase = NoPhase;
+ def phaseNamed(name: String): Phase = NoPhase;
+}
+
diff --git a/sources/scala/tools/nsc/Global.scala b/sources/scala/tools/nsc/Global.scala
index 37c90b3eca..3c5f45806a 100755
--- a/sources/scala/tools/nsc/Global.scala
+++ b/sources/scala/tools/nsc/Global.scala
@@ -20,7 +20,6 @@ import matching.TransMatcher;
import transform._;
import backend.icode.{ICodes, GenICode, Checkers};
import backend.ScalaPrimitives;
-import backend.jvm.BytecodeGenerators;
class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
with Trees
@@ -73,11 +72,6 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
val copy = new LazyTreeCopier();
- type AttrInfo = Pair[Type, List[Any]];
-
- /** A map from symbols to their attributes */
- val attributes = new HashMap[Symbol, List[AttrInfo]];
-
// reporting -------------------------------------------------------
def error(msg: String) = reporter.error(null, msg);
@@ -154,9 +148,14 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
var globalPhase: Phase = NoPhase;
+ val MaxPhases = 64;
+
+ val phaseWithId = new Array[Phase](MaxPhases);
+ { for (val i <- List.range(0, MaxPhases)) phaseWithId(i) = NoPhase }
abstract class GlobalPhase(prev: Phase) extends Phase(prev) {
- def run: unit = units foreach applyPhase;
+ phaseWithId(id) = this;
+ def run: unit = currentRun.units foreach applyPhase;
def apply(unit: CompilationUnit): unit;
private val isErased = prev.name == "erasure" || prev.erasedTypes;
override def erasedTypes: boolean = isErased;
@@ -180,11 +179,6 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
val global: Global.this.type = Global.this
}
-/*
- object syntheticMethods extends SyntheticMethods {
- val global: Global.this.type = Global.this
- }
-*/
object refchecks extends RefChecks {
val global: Global.this.type = Global.this;
}
@@ -241,8 +235,17 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
val global: Global.this.type = Global.this;
}
- object genJVM extends BytecodeGenerators {
- val global: Global.this.type = Global.this;
+ object icodeChecker extends checkers.ICodeChecker();
+
+ object typer extends analyzer.Typer(analyzer.NoContext.make(EmptyTree, Global.this.definitions.RootClass, new Scope())) {
+ override def typed(tree: Tree, mode: int, pt: Type): Tree = {
+ if (settings.debug.value) log("typing [[" + tree + "]]");
+ val result = super.typed(tree, mode, pt);
+ if (settings.debug.value) log(" ==> " + result + ":" + result.tpe);
+ result
+ }
+ override def typed(tree: Tree): Tree = super.typed(tree);
+ override def typed(tree: Tree, pt: Type): Tree = super.typed(tree, pt);
}
def phaseDescriptors: List[SubComponent] = List(
@@ -260,155 +263,141 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
flatten,
constructors,
mixin,
- genicode,
- genJVM,
- sampleTransform);
-
- val parserPhase = syntaxAnalyzer.newPhase(NoPhase);
- val firstPhase = parserPhase;
- currentRun = NoRun + 1;
- phase = parserPhase;
- definitions.init; // needs firstPhase and phase to be defined != NoPhase,
- // that's why it is placed here.
-
- val icodeChecker = new checkers.ICodeChecker();
-
- private var p = phase;
- private var stopped = false;
- for (val pd <- phaseDescriptors) {
- if (!stopped) {
- if (!(settings.skip contains pd.phaseName)) p = pd.newPhase(p);
- stopped = settings.stop contains pd.phaseName;
- }
- }
+ if (settings.Xshowicode.value) genicode
+ else sampleTransform);
- val terminalPhase = new GlobalPhase(p) {
- def name = "terminal";
- def apply(unit: CompilationUnit): unit = {}
- }
+// Runs ----------------------------------------------------------------
- def phaseNamed(name: String): Phase = {
- var p: Phase = firstPhase;
- while (p.next != p && p.name != name) p = p.next;
- if (p.name != name) NoPhase else p
- }
+ private var curRun: Run = NoRun;
+ override def currentRun: Run = curRun;
- val namerPhase = phaseNamed("namer");
- val typerPhase = phaseNamed("typer");
- val refchecksPhase = phaseNamed("refchecks");
- val erasurePhase = phaseNamed("erasure");
- val flattenPhase = phaseNamed("flatten");
- val delegateMixins = phaseNamed("mixin") != NoPhase;
+ type AttrInfo = Pair[Type, List[Any]];
- val typer = new analyzer.Typer(analyzer.NoContext.make(EmptyTree, definitions.RootClass, new Scope())) {
- override def typed(tree: Tree, mode: int, pt: Type): Tree = {
- if (settings.debug.value) log("typing [[" + tree + "]]");
- val result = super.typed(tree, mode, pt);
- if (settings.debug.value) log(" ==> " + result + ":" + result.tpe);
- result
+ class Run extends CompilerRun {
+ curRun = this;
+ override val firstPhase = syntaxAnalyzer.newPhase(NoPhase);
+ phase = firstPhase;
+ definitions.init; // needs firstPhase and phase to be defined != NoPhase,
+ // that's why it is placed here.
+
+ private var p: Phase = firstPhase;
+ private var stopped = false;
+ for (val pd <- phaseDescriptors) {
+ if (!stopped) {
+ if (!(settings.skip contains pd.phaseName)) p = pd.newPhase(p);
+ stopped = settings.stop contains pd.phaseName;
+ }
}
- }
- val infer = typer.infer;
-// Units and how to compile them -------------------------------------
+ override val terminalPhase = new GlobalPhase(p) {
+ def name = "terminal";
+ def apply(unit: CompilationUnit): unit = {}
+ }
- private var unitbuf = new ListBuffer[CompilationUnit];
- private var fileset = new HashSet[AbstractFile];
+ override def phaseNamed(name: String): Phase = {
+ var p: Phase = firstPhase;
+ while (p.next != p && p.name != name) p = p.next;
+ if (p.name != name) NoPhase else p
+ }
- private def addUnit(unit: CompilationUnit): unit = {
- unitbuf += unit;
- fileset += unit.source.getFile();
- }
+ override val namerPhase = phaseNamed("namer");
+ override val typerPhase = phaseNamed("typer");
+ override val refchecksPhase = phaseNamed("refchecks");
+ override val erasurePhase = phaseNamed("erasure");
+ override val flattenPhase = phaseNamed("flatten");
+
+ /** A map from symbols to their attributes */
+ val attributes = new HashMap[Symbol, List[AttrInfo]];
- def units: Iterator[CompilationUnit] = unitbuf.elements;
+ private var unitbuf = new ListBuffer[CompilationUnit];
+ private var fileset = new HashSet[AbstractFile];
- /** A map from compiled top-level symbols to their source files */
- val symSource = new HashMap[Symbol, AbstractFile];
+ private def addUnit(unit: CompilationUnit): unit = {
+ unitbuf += unit;
+ fileset += unit.source.getFile();
+ }
- /** A map from compiled top-level symbols to their picklers */
- val symData = new HashMap[Symbol, PickleBuffer];
+ def units: Iterator[CompilationUnit] = unitbuf.elements;
- def compileSources(sources: List[SourceFile]): unit = {
- val startTime = System.currentTimeMillis();
- unitbuf.clear;
- fileset.clear;
- symSource.clear;
- symData.clear;
- reporter.resetCounters();
- phase = firstPhase;
- while (phase != terminalPhase) { phase.resetPhase; phase = phase.next }
+ /** A map from compiled top-level symbols to their source files */
+ val symSource = new HashMap[Symbol, AbstractFile];
- for (val source <- sources)
- addUnit(new CompilationUnit(source));
+ /** A map from compiled top-level symbols to their picklers */
+ val symData = new HashMap[Symbol, PickleBuffer];
- globalPhase = firstPhase;
- while (globalPhase != terminalPhase && reporter.errors() == 0) {
+ def compileSources(sources: List[SourceFile]): unit = {
val startTime = System.currentTimeMillis();
- phase = globalPhase;
- globalPhase.run;
- if (settings.print contains globalPhase.name) treePrinter.printAll();
- if (settings.browse contains globalPhase.name) treeBrowser.browse(units);
- informTime(globalPhase.description, startTime);
- globalPhase = globalPhase.next;
- if (settings.check contains globalPhase.name) {
- phase = globalPhase;
- if (globalPhase.name == "terminal")
- icodeChecker.checkICodes;
- else
- checker.checkTrees;
+ reporter.resetCounters();
+
+ for (val source <- sources)
+ addUnit(new CompilationUnit(source));
+
+ globalPhase = firstPhase;
+ while (globalPhase != terminalPhase && reporter.errors() == 0) {
+ val startTime = System.currentTimeMillis();
+ phase = globalPhase;
+ globalPhase.run;
+ if (settings.print contains globalPhase.name) treePrinter.printAll();
+ if (settings.browse contains globalPhase.name) treeBrowser.browse(units);
+ informTime(globalPhase.description, startTime);
+ globalPhase = globalPhase.next;
+ if (settings.check contains globalPhase.name) {
+ phase = globalPhase;
+ if (globalPhase.name == "terminal" && settings.Xshowicode.value) icodeChecker.checkICodes;
+ else checker.checkTrees;
+ }
+ if (settings.statistics.value) statistics.print(phase);
}
- if (settings.statistics.value) statistics.print(phase);
- }
- if (settings.Xshowcls.value != "") showDef(newTermName(settings.Xshowcls.value), false);
- if (settings.Xshowobj.value != "") showDef(newTermName(settings.Xshowobj.value), true);
- if (settings.Xshowicode.value) writeICode();
-
- if (reporter.errors() == 0) {
- for (val Pair(sym, pickled) <- symData.elements.toList) {
- sym setPos Position.NOPOS;
- if (symData contains sym) {
- symData -= sym;
- symData -= sym.linkedSym;
- writeSymblFile(sym, pickled)
+ if (settings.Xshowcls.value != "") showDef(newTermName(settings.Xshowcls.value), false);
+ if (settings.Xshowobj.value != "") showDef(newTermName(settings.Xshowobj.value), true);
+ if (settings.Xshowicode.value) printICode();
+
+ if (reporter.errors() == 0) {
+ for (val Pair(sym, pickled) <- symData.elements.toList) {
+ sym setPos Position.NOPOS;
+ if (symData contains sym) {
+ symData -= sym;
+ symData -= sym.linkedSym;
+ writeSymblFile(sym, pickled)
+ }
+ }
+ } else {
+ for (val Pair(sym, file) <- symSource.elements) {
+ sym.reset(new loaders.SourcefileLoader(file));
+ if (sym.isTerm) sym.moduleClass.reset(loaders.errorLoader);
}
}
- currentRun = currentRun + 1;
- } else {
- for (val Pair(sym, file) <- symSource.elements) {
- sym.reset(new loaders.SourcefileLoader(file));
- if (sym.isTerm) sym.moduleClass.reset(loaders.errorLoader);
- }
+ informTime("total", startTime);
}
- informTime("total", startTime);
- }
-
- def compileLate(file: AbstractFile): unit =
- if (fileset == null)
- throw new FatalError("No symbol file for " + file + " was found\n(This file cannot be loaded as a source file)");
- else if (!(fileset contains file)) {
- val unit = new CompilationUnit(getSourceFile(file));
- addUnit(unit);
- var localPhase = parserPhase.asInstanceOf[GlobalPhase];
- while (localPhase.id < globalPhase.id || localPhase.id <= parserPhase.next.id) {
- atPhase(localPhase)(localPhase.applyPhase(unit));
- localPhase = localPhase.next.asInstanceOf[GlobalPhase];
+
+ def compileLate(file: AbstractFile): unit =
+ if (fileset == null)
+ throw new FatalError("No symbol file for " + file + " was found\n(This file cannot be loaded as a source file)");
+ else if (!(fileset contains file)) {
+ val unit = new CompilationUnit(getSourceFile(file));
+ addUnit(unit);
+ var localPhase = firstPhase.asInstanceOf[GlobalPhase];
+ while (localPhase.id < globalPhase.id || localPhase.id <= namerPhase.id) {
+ atPhase(localPhase)(localPhase.applyPhase(unit));
+ localPhase = localPhase.next.asInstanceOf[GlobalPhase];
+ }
}
- }
- def compileFiles(files: List[AbstractFile]): unit =
- try {
- compileSources(files map getSourceFile)
- } catch {
- case ex: IOException => error(ex.getMessage());
- }
+ def compileFiles(files: List[AbstractFile]): unit =
+ try {
+ compileSources(files map getSourceFile)
+ } catch {
+ case ex: IOException => error(ex.getMessage());
+ }
- def compile(filenames: List[String]): unit =
- try {
- compileSources(filenames map getSourceFile)
- } catch {
- case ex: IOException => error(ex.getMessage());
- }
+ def compile(filenames: List[String]): unit =
+ try {
+ compileSources(filenames map getSourceFile)
+ } catch {
+ case ex: IOException => error(ex.getMessage());
+ }
+ }
def showDef(name: Name, module: boolean): unit = {
def getSym(name: Name, module: boolean): Symbol = {
@@ -458,21 +447,8 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
}
}
- private def writeICode(): Unit = {
+ private def printICode(): Unit = {
val printer = new icodePrinter.TextPrinter(new PrintWriter(System.out, true));
- icodes.classes.foreach((cls) => {
- val file = getFile(cls.symbol, ".icode");
- try {
- val stream = new FileOutputStream(file);
- printer.setWriter(new PrintWriter(stream, true));
- printer.printClass(cls);
- informProgress("wrote " + file);
- } catch {
- case ex: IOException =>
- if (settings.debug.value) ex.printStackTrace();
- error("could not write file " + file);
- }
-
- });
+ icodes.classes.foreach(printer.printClass);
}
}
diff --git a/sources/scala/tools/nsc/Interpreter.scala b/sources/scala/tools/nsc/Interpreter.scala
index 31a0571acf..c87fa66917 100644
--- a/sources/scala/tools/nsc/Interpreter.scala
+++ b/sources/scala/tools/nsc/Interpreter.scala
@@ -47,7 +47,7 @@ abstract class Interpreter {
// first phase: compile auto-generated file
val args = List.fromString(filename, ' ');
val command = new CompilerCommand(args, error, true);
- compiler.compile(command.files);
+ compiler.currentRun.compile(command.files);
/*
//todo: if no errors in compilation then
diff --git a/sources/scala/tools/nsc/Main.scala b/sources/scala/tools/nsc/Main.scala
index 686b077372..9c158c85b1 100755
--- a/sources/scala/tools/nsc/Main.scala
+++ b/sources/scala/tools/nsc/Main.scala
@@ -24,19 +24,18 @@ object Main {
def error(msg: String): unit =
reporter.error(new Position(PRODUCT),
- msg + "\n " + PRODUCT + " -help gives more information");
+ msg + "\n " + PRODUCT + " -help gives more information");
def errors() = reporter.errors();
- def interactive(gCompiler: Global): unit = {
+ def resident(compiler: Global): unit = {
val in = new BufferedReader(new InputStreamReader(System.in));
- val interpreter = new Interpreter {
- val compiler: gCompiler.type = gCompiler
- };
System.out.print(prompt);
var line = in.readLine();
while (line != null && line.length() > 0) {
- interpreter.interpret(line.trim(), reporter);
+ val args = List.fromString(line, ' ');
+ val command = new CompilerCommand(args, error, true);
+ (new compiler.Run) compile command.files;
System.out.print(prompt);
line = in.readLine();
}
@@ -52,18 +51,18 @@ object Main {
reporter.info(null, command.usageMsg, true)
else {
try {
- val compiler = new Global(command.settings, reporter);
- if (command.settings.interactive.value)
- interactive(compiler);
- else if (command.files.isEmpty)
- reporter.info(null, command.usageMsg, true)
- else
- compiler.compile(command.files);
+ val compiler = new Global(command.settings, reporter);
+ if (command.settings.resident.value)
+ resident(compiler);
+ else if (command.files.isEmpty)
+ reporter.info(null, command.usageMsg, true)
+ else
+ (new compiler.Run) compile command.files;
} catch {
- case ex @ FatalError(msg) =>
- if (command.settings.debug.value)
- ex.printStackTrace();
- reporter.error(null, "fatal error: " + msg);
+ case ex @ FatalError(msg) =>
+ if (command.settings.debug.value)
+ ex.printStackTrace();
+ reporter.error(null, "fatal error: " + msg);
}
reporter.printSummary()
}
@@ -73,4 +72,5 @@ object Main {
process(args);
System.exit(if (reporter.errors() > 0) 1 else 0);
}
+
}
diff --git a/sources/scala/tools/nsc/Phase.scala b/sources/scala/tools/nsc/Phase.scala
index ce77502452..4ca3aa2e9c 100644
--- a/sources/scala/tools/nsc/Phase.scala
+++ b/sources/scala/tools/nsc/Phase.scala
@@ -8,15 +8,16 @@ package scala.tools.nsc;
import symtab.Flags;
abstract class Phase(val prev: Phase) {
- val id: int = if (prev == null) 0 else prev.id + 1;
+
+ type Id = int;
+
+ val id: Id = if (prev == null) 0 else prev.id + 1;
def newFlags: long = 0l;
private var fmask: long =
if (prev == null) Flags.InitialFlags else prev.flagMask | newFlags;
def flagMask: long = fmask;
- def resetPhase: unit = {}
-
private var nx: Phase = this;
if (prev != null) prev.nx = this;
diff --git a/sources/scala/tools/nsc/Settings.scala b/sources/scala/tools/nsc/Settings.scala
index 4055c49345..885af03ede 100644
--- a/sources/scala/tools/nsc/Settings.scala
+++ b/sources/scala/tools/nsc/Settings.scala
@@ -29,7 +29,8 @@ class Settings(error: String => unit) {
val debug = BooleanSetting("-debug", "Output debugging messages");
val statistics = BooleanSetting("-statistics", "Print compiler statistics");
val explaintypes = BooleanSetting("-explaintypes", "Explain type errors in more detail");
- val interactive = BooleanSetting("-interactive", "Interactive mode");
+ val interprete = BooleanSetting("-interprete", "Run interpreter");
+ val resident = BooleanSetting("-resident", "Compiler stays resident, files to compile are read from standard input");
val uniqid = BooleanSetting("-uniqid", "Print identifiers with unique names (debugging option)");
val printtypes = BooleanSetting("-printtypes", "Print tree types (debugging option)");
val prompt = BooleanSetting("-prompt", "Display a prompt after each error (debugging option)");
diff --git a/sources/scala/tools/nsc/ast/TreePrinters.scala b/sources/scala/tools/nsc/ast/TreePrinters.scala
index 3c017acb3b..07623404ee 100644
--- a/sources/scala/tools/nsc/ast/TreePrinters.scala
+++ b/sources/scala/tools/nsc/ast/TreePrinters.scala
@@ -283,7 +283,7 @@ abstract class TreePrinters {
def printAll(): unit = {
print("[[syntax trees at end of " + phase + "]]");
- for (val unit <- global.units) print(unit)
+ for (val unit <- global.currentRun.units) print(unit)
}
}
diff --git a/sources/scala/tools/nsc/symtab/Definitions.scala b/sources/scala/tools/nsc/symtab/Definitions.scala
index 4bb6f60e7d..37b4330575 100755
--- a/sources/scala/tools/nsc/symtab/Definitions.scala
+++ b/sources/scala/tools/nsc/symtab/Definitions.scala
@@ -265,7 +265,11 @@ abstract class Definitions: SymbolTable {
else tp.symbol.fullNameString
}
- def init = {
+ private var isInitialized = false;
+
+ def init: unit = {
+ if (isInitialized) return;
+ isInitialized = true;
RootClass =
NoSymbol.newClass(Position.NOPOS, nme.ROOT.toTypeName)
.setFlag(FINAL | MODULE | PACKAGE | JAVA).setInfo(rootLoader);
@@ -275,7 +279,6 @@ abstract class Definitions: SymbolTable {
EmptyPackageClass = EmptyPackage.moduleClass;
EmptyPackageClass.setInfo(ClassInfoType(List(), new Scope(), EmptyPackageClass));
-
EmptyPackage.setInfo(EmptyPackageClass.tpe);
RootClass.info.decls.enter(EmptyPackage);
diff --git a/sources/scala/tools/nsc/symtab/Flags.scala b/sources/scala/tools/nsc/symtab/Flags.scala
index 4fc5330461..f0360b1809 100644
--- a/sources/scala/tools/nsc/symtab/Flags.scala
+++ b/sources/scala/tools/nsc/symtab/Flags.scala
@@ -77,6 +77,7 @@ object Flags {
final val lateINTERFACE = (INTERFACE: long) << LateShift;
final val lateMODULE = (MODULE: long) << LateShift;
final val lateFINAL = (FINAL: long) << LateShift;
+ final val lateMETHOD = (METHOD: long) << LateShift;
final val notPRIVATE = (PRIVATE: long) << AntiShift;
final val notPROTECTED = (PROTECTED: long) << AntiShift;
final val notABSTRACT = (ABSTRACT: long) << AntiShift;
diff --git a/sources/scala/tools/nsc/symtab/InfoTransformers.scala b/sources/scala/tools/nsc/symtab/InfoTransformers.scala
index bb03eaac8e..6489302aeb 100644
--- a/sources/scala/tools/nsc/symtab/InfoTransformers.scala
+++ b/sources/scala/tools/nsc/symtab/InfoTransformers.scala
@@ -11,15 +11,15 @@ abstract class InfoTransformers: SymbolTable {
var prev: InfoTransformer = this;
var next: InfoTransformer = this;
- val phase: Phase;
+ val pid: Phase#Id;
val changesBaseClasses: boolean;
def transform(sym: Symbol, tpe: Type): Type;
def insert(that: InfoTransformer): unit = {
- assert(this.phase.id != that.phase.id);
- if (that.phase.id < this.phase.id) {
+ assert(this.pid != that.pid);
+ if (that.pid < this.pid) {
prev insert that
- } else if (next.phase.id <= that.phase.id && next.phase != NoPhase) {
+ } else if (next.pid <= that.pid && next.pid != NoPhase.id) {
next insert that
} else {
that.next = next;
@@ -29,12 +29,12 @@ abstract class InfoTransformers: SymbolTable {
}
}
- def nextFrom(from: Phase): InfoTransformer =
- if (from.id == this.phase.id) this
- else if (from.id < this.phase.id)
- if (prev.phase.id < from.id) this
+ def nextFrom(from: Phase#Id): InfoTransformer =
+ if (from == this.pid) this
+ else if (from < this.pid)
+ if (prev.pid < from) this
else prev.nextFrom(from);
- else if (next.phase == NoPhase) next
+ else if (next.pid == NoPhase.id) next
else next.nextFrom(from);
}
}
diff --git a/sources/scala/tools/nsc/symtab/SymbolLoaders.scala b/sources/scala/tools/nsc/symtab/SymbolLoaders.scala
index 1900dd82c8..ba59532556 100755
--- a/sources/scala/tools/nsc/symtab/SymbolLoaders.scala
+++ b/sources/scala/tools/nsc/symtab/SymbolLoaders.scala
@@ -38,7 +38,6 @@ abstract class SymbolLoaders {
try {
val start = System.currentTimeMillis();
val currentphase = phase;
- phase = firstPhase;
doComplete(root);
phase = currentphase;
def source = kindString + " " + file;
@@ -170,7 +169,7 @@ abstract class SymbolLoaders {
}
class SourcefileLoader(file: AbstractFile) extends SymbolLoader(file) {
- protected def doComplete(root: Symbol): unit = global.compileLate(file);
+ protected def doComplete(root: Symbol): unit = global.currentRun.compileLate(file);
protected def kindString: String = "source file";
}
diff --git a/sources/scala/tools/nsc/symtab/SymbolTable.scala b/sources/scala/tools/nsc/symtab/SymbolTable.scala
index ebc63b9ab8..eb29dad289 100755
--- a/sources/scala/tools/nsc/symtab/SymbolTable.scala
+++ b/sources/scala/tools/nsc/symtab/SymbolTable.scala
@@ -18,7 +18,6 @@ abstract class SymbolTable extends Names
def settings: Settings;
def rootLoader: LazyType;
def log(msg: Object): unit;
- def firstPhase: Phase;
private var ph: Phase = NoPhase;
def phase: Phase = ph;
@@ -28,12 +27,10 @@ abstract class SymbolTable extends Names
ph = p
}
- final val NoRun = 0;
+ final val NoRun = null;
- /** The number of the current compiler run. Runs start at 1 and increment each time
- * after Global.compileSources is called.
- */
- var currentRun: int = NoRun;
+ /** The current compiler run. */
+ def currentRun: CompilerRun;
def atPhase[T](ph: Phase)(op: => T): T = {
val current = phase;
@@ -44,8 +41,10 @@ abstract class SymbolTable extends Names
}
var infoTransformers = new InfoTransformer {
- val phase = NoPhase;
+ val pid = NoPhase.id;
val changesBaseClasses = true;
def transform(sym: Symbol, tpe: Type): Type = tpe;
}
+
+ val phaseWithId: Array[Phase];
}
diff --git a/sources/scala/tools/nsc/symtab/Symbols.scala b/sources/scala/tools/nsc/symtab/Symbols.scala
index ee4a5744ff..0aa534e568 100755
--- a/sources/scala/tools/nsc/symtab/Symbols.scala
+++ b/sources/scala/tools/nsc/symtab/Symbols.scala
@@ -28,7 +28,8 @@ abstract class Symbols: SymbolTable {
private var rawflags: long = 0;
private var rawpos = initPos;
val id = { ids = ids + 1; ids }
- var validForRun: int = NoRun;
+
+ var validForRun: CompilerRun = NoRun;
def pos = rawpos;
def setPos(pos: int): this.type = { this.rawpos = pos; this }
@@ -239,7 +240,7 @@ abstract class Symbols: SymbolTable {
// Info and Type -------------------------------------------------------------------
private var infos: TypeHistory = null;
- private var limit: Phase = NoPhase;
+ private var limit: Phase#Id = 0;
/** Get type. The type of a symbol is:
* for a type symbol, the type corresponding to the symbol itself
@@ -253,6 +254,7 @@ abstract class Symbols: SymbolTable {
final def info: Type = {
var cnt = 0;
while (validForRun != currentRun) {
+ //if (settings.debug.value) System.out.println("completing " + this);//DEBUG
var ifs = infos;
assert(ifs != null, this.name);
while (ifs.prev != null) {
@@ -267,7 +269,7 @@ abstract class Symbols: SymbolTable {
rawflags = rawflags | LOCKED;
val current = phase;
try {
- phase = ifs.start;
+ phase = phaseWithId(ifs.start);
tp.complete(this);
// if (settings.debug.value && (validForRun == currentRun) System.out.println("completed " + this/* + ":" + info*/);//DEBUG
rawflags = rawflags & ~LOCKED
@@ -285,8 +287,8 @@ abstract class Symbols: SymbolTable {
/** Set initial info. */
def setInfo(info: Type): this.type = {
assert(info != null);
- infos = new TypeHistory(phase, info, null);
- limit = phase;
+ infos = new TypeHistory(phase.id, info, null);
+ limit = phase.id;
if (info.isComplete) {
rawflags = rawflags & ~LOCKED;
validForRun = currentRun
@@ -299,36 +301,36 @@ abstract class Symbols: SymbolTable {
/** Set new info valid from start of this phase. */
final def updateInfo(info: Type): Symbol = {
- assert(infos.start.id <= phase.id);
- if (infos.start == phase) infos = infos.prev;
- infos = new TypeHistory(phase, info, infos);
+ assert(infos.start <= phase.id);
+ if (infos.start == phase.id) infos = infos.prev;
+ infos = new TypeHistory(phase.id, info, infos);
this
}
/** Return info without checking for initialization or completing */
final def rawInfo: Type = {
- if (limit.id < phase.id) {
+ if (limit < phase.id) {
if (validForRun == currentRun) {
val current = phase;
var itr = infoTransformers.nextFrom(limit);
infoTransformers = itr; // caching optimization
- while (itr.phase != NoPhase && itr.phase.id < current.id) {
- phase = itr.phase;
+ while (itr.pid != NoPhase.id && itr.pid < current.id) {
+ phase = phaseWithId(itr.pid);
val info1 = itr.transform(this, infos.info);
+ limit = phase.id + 1;
if (info1 ne infos.info) {
- infos = new TypeHistory(phase.next, info1, infos);
+ infos = new TypeHistory(limit, info1, infos);
}
- limit = phase.next;
itr = itr.nextFrom(limit)
}
phase = current;
- limit = current;
+ limit = current.id;
}
assert(infos != null, name);
infos.info
} else {
var infos = this.infos;
- while (phase.id < infos.start.id && infos.prev != null) infos = infos.prev;
+ while (phase.id < infos.start && infos.prev != null) infos = infos.prev;
infos.info
}
}
@@ -340,9 +342,9 @@ abstract class Symbols: SymbolTable {
}
/** Was symbol's type updated during given phase? */
- final def isUpdatedAt(phase: Phase): boolean = {
+ final def isUpdatedAt(pid: Phase#Id): boolean = {
var infos = this.infos;
- while (infos != null && infos.start != phase.next) infos = infos.prev;
+ while (infos != null && infos.start != pid + 1) infos = infos.prev;
infos != null
}
@@ -366,7 +368,7 @@ abstract class Symbols: SymbolTable {
resetFlags;
rawpos = Position.NOPOS;
infos = null;
- limit = NoPhase;
+ limit = NoPhase.id;
setInfo(completer)
}
@@ -795,6 +797,7 @@ abstract class Symbols: SymbolTable {
class TypeSymbol(initOwner: Symbol, initPos: int, initName: Name) extends Symbol(initOwner, initPos, initName) {
override def isType = true;
private var tyconCache: Type = null;
+ private var tyconRun: CompilerRun = null;
private var tpeCache: Type = _;
private var tpePhase: Phase = null;
override def tpe: Type = {
@@ -814,10 +817,12 @@ abstract class Symbols: SymbolTable {
tpeCache
}
override def typeConstructor: Type = {
- if (tyconCache == null)
- tyconCache = typeRef(if (isTypeParameter) NoPrefix else owner.thisType,
- this, List());
- tyconCache;
+ if (tyconCache == null || tyconRun != currentRun) {
+ tyconCache = typeRef(if (isTypeParameter) NoPrefix else owner.thisType, this, List());
+ tyconRun = currentRun;
+ }
+ assert(tyconCache != null);
+ tyconCache
}
override def setInfo(tp: Type): this.type = {
tpePhase = null;
@@ -941,8 +946,8 @@ abstract class Symbols: SymbolTable {
case class CyclicReference(sym: Symbol, info: Type) extends TypeError("illegal cyclic reference involving " + sym);
/** A class for type histories */
- private case class TypeHistory(start: Phase, info: Type, prev: TypeHistory) {
- assert(prev == null || start.id > prev.start.id, this);
- override def toString() = "TypeHistory" + info.hashCode() + "(" + start + "," + info + "," + prev + ")";
+ private case class TypeHistory(start: Phase#Id, info: Type, prev: TypeHistory) {
+ assert(prev == null || start > prev.start, this);
+ override def toString() = "TypeHistory(" + phaseWithId(start) + "," + info + "," + prev + ")";
}
}
diff --git a/sources/scala/tools/nsc/symtab/Types.scala b/sources/scala/tools/nsc/symtab/Types.scala
index a3106c18ce..cf8e81b6e2 100755
--- a/sources/scala/tools/nsc/symtab/Types.scala
+++ b/sources/scala/tools/nsc/symtab/Types.scala
@@ -178,10 +178,8 @@ abstract class Types: SymbolTable {
sym.info.asSeenFrom(this, sym.owner);
/** The type of `sym', seen as a memeber of this type. */
- def memberType(sym: Symbol): Type = {
- //System.out.println("" + this + " memberType " + sym + ":" + sym.tpe);//DEBUG
+ def memberType(sym: Symbol): Type =
sym.tpe.asSeenFrom(this, sym.owner);
- }
/** Substitute types `to' for occurrences of references to symbols `from'
* in this type. */
@@ -299,10 +297,10 @@ abstract class Types: SymbolTable {
else {
/*if (sym.owner.isClass) complete(sym.owner);*/
val this1 = adaptToNewRunMap(this);
- System.out.println("adapting " + sym);//debug
+ //System.out.println("adapting " + sym);//DEBUG
if (this1 eq this) sym.validForRun = currentRun
else {
- System.out.println("new type of " + sym + "=" + this1);//debug
+ //System.out.println("new type of " + sym + "=" + this1);//DEBUG
sym.setInfo(this1);
}
}
@@ -1268,7 +1266,7 @@ abstract class Types: SymbolTable {
if (sym.isModuleClass) adaptToNewRun(pre, sym.sourceModule).moduleClass;
else if ((pre eq NoPrefix) || (pre eq NoType) || sym.owner.isPackageClass) sym
else {
- val rebind0 = pre.nonPrivateMember(sym.name);
+ val rebind0 = pre.member(sym.name);
val rebind = rebind0.suchThat(sym => sym.isType || sym.isStable);
if (rebind == NoSymbol) throw new MalformedType(pre, sym.name.toString());
rebind
@@ -1315,18 +1313,18 @@ abstract class Types: SymbolTable {
// Helper Methods -------------------------------------------------------------
final def isValid(p: Phase): boolean =
- p != null && {
- if (phase.id > p.id) infoTransformers.nextFrom(p).phase.id >= phase.id
- else infoTransformers.nextFrom(phase).phase.id >= p.id
+ p != null && phaseWithId(p.id) == p && {
+ if (phase.id > p.id) infoTransformers.nextFrom(p.id).pid >= phase.id
+ else infoTransformers.nextFrom(phase.id).pid >= p.id
}
final def isValidForBaseClasses(p: Phase): boolean = {
- def noChangeInBaseClasses(it: InfoTransformer, limit: Phase): boolean =
- it.phase.id >= limit.id ||
+ def noChangeInBaseClasses(it: InfoTransformer, limit: Phase#Id): boolean =
+ it.pid >= limit ||
!it.changesBaseClasses && noChangeInBaseClasses(it.next, limit);
- p != null && {
- if (phase.id > p.id) noChangeInBaseClasses(infoTransformers.nextFrom(p), phase)
- else noChangeInBaseClasses(infoTransformers.nextFrom(phase), p)
+ p != null && phaseWithId(p.id) == p && {
+ if (phase.id > p.id) noChangeInBaseClasses(infoTransformers.nextFrom(p.id), phase.id)
+ else noChangeInBaseClasses(infoTransformers.nextFrom(phase.id), p.id)
}
}
diff --git a/sources/scala/tools/nsc/symtab/classfile/Pickler.scala b/sources/scala/tools/nsc/symtab/classfile/Pickler.scala
index 172bf358a7..6efdc34a37 100755
--- a/sources/scala/tools/nsc/symtab/classfile/Pickler.scala
+++ b/sources/scala/tools/nsc/symtab/classfile/Pickler.scala
@@ -26,10 +26,10 @@ abstract class Pickler extends SubComponent {
def pickle(tree: Tree): unit = {
def add(sym: Symbol, pickle: Pickle) = {
- if (!sym.isExternal && !symData.contains(sym)) {
+ if (!sym.isExternal && !currentRun.symData.contains(sym)) {
if (settings.debug.value) log("pickling " + sym);
pickle.putSymbol(sym);
- symData(sym) = pickle;
+ currentRun.symData(sym) = pickle;
}
}
diff --git a/sources/scala/tools/nsc/symtab/classfile/UnPickler.scala b/sources/scala/tools/nsc/symtab/classfile/UnPickler.scala
index 222fcdacd2..23a523f87b 100755
--- a/sources/scala/tools/nsc/symtab/classfile/UnPickler.scala
+++ b/sources/scala/tools/nsc/symtab/classfile/UnPickler.scala
@@ -210,7 +210,7 @@ abstract class UnPickler {
throw new RuntimeException("malformed Scala signature of " + classRoot.name + " at " + readIndex + "; " + msg);
private class LazyTypeRef(i: int) extends LazyType {
- private val definedAtRun: int = currentRun;
+ private val definedAtRun = currentRun;
override def complete(sym: Symbol): unit = {
val tp = at(i, readType);
sym setInfo tp;
diff --git a/sources/scala/tools/nsc/transform/AddInterfaces.scala b/sources/scala/tools/nsc/transform/AddInterfaces.scala
index 7b1638cc65..00fe47c7ca 100755
--- a/sources/scala/tools/nsc/transform/AddInterfaces.scala
+++ b/sources/scala/tools/nsc/transform/AddInterfaces.scala
@@ -24,23 +24,26 @@ abstract class AddInterfaces extends InfoTransform {
private val implClassMap = new HashMap[Symbol, Symbol];
private val implMethodMap = new HashMap[Symbol, Symbol];
- override def resetTransform: unit = {
+ override def newPhase(prev: scala.tools.nsc.Phase): StdPhase = {
implClassMap.clear;
- implMethodMap.clear
+ implMethodMap.clear;
+ super.newPhase(prev)
}
private def needsImplMethod(sym: Symbol): boolean =
sym.isMethod && isInterfaceMember(sym) &&
(!(sym hasFlag (DEFERRED | SUPERACCESSOR)) || (sym hasFlag lateDEFERRED));
- private def isInterfaceMember(sym: Symbol): boolean =
+ private def isInterfaceMember(sym: Symbol): boolean = {
+ sym.info; // to set lateMETHOD flag if necessary
sym.isType ||
- sym.isMethod && !(sym hasFlag (PRIVATE | BRIDGE | LABEL)) && !sym.isConstructor;
+ sym.isMethod && !(sym hasFlag (PRIVATE | BRIDGE | LABEL)) && !sym.isConstructor
+ }
def implClass(iface: Symbol): Symbol = implClassMap.get(iface) match {
case Some(c) => c
case None =>
- atPhase(erasurePhase) {
+ atPhase(currentRun.erasurePhase) {
val implName = nme.implClassName(iface.name);
var impl = if (iface.owner.isClass) iface.owner.info.decls.lookup(implName) else NoSymbol;
if (impl == NoSymbol) {
@@ -64,12 +67,14 @@ abstract class AddInterfaces extends InfoTransform {
for (val sym <- ifaceDecls.elements) {
if (isInterfaceMember(sym)) {
if (needsImplMethod(sym)) {
- val impl = sym.cloneSymbol(implClass).setInfo(sym.info);
+ val impl = sym.cloneSymbol(implClass).setInfo(sym.info).resetFlag(lateDEFERRED);
if (!impl.isExternal) implMethodMap(sym) = impl;
decls enter impl;
sym setFlag lateDEFERRED
}
} else {
+ if (sym.name == newTermName("definitions"))
+ System.out.println("definitions to impl class " + sym.isMethod + " " + sym.getFlag(PRIVATE | BRIDGE | LABEL));
sym.owner = implClass;
decls enter sym;
}
@@ -88,7 +93,7 @@ abstract class AddInterfaces extends InfoTransform {
case PolyType(tparams, restpe) =>
PolyType(tparams, implType(restpe))
}
- sym.setInfo(atPhase(erasurePhase)(implType(iface.info)));
+ sym.setInfo(atPhase(currentRun.erasurePhase)(implType(iface.info)));
}
override def load(clazz: Symbol): unit = complete(clazz)
@@ -211,7 +216,7 @@ abstract class AddInterfaces extends InfoTransform {
val mix1 =
if (mix == nme.EMPTY.toTypeName) mix
else {
- val ps = atPhase(erasurePhase) {
+ val ps = atPhase(currentRun.erasurePhase) {
tree.symbol.info.parents dropWhile (p => p.symbol.name != mix)
}
assert(!ps.isEmpty, tree);
diff --git a/sources/scala/tools/nsc/transform/Erasure.scala b/sources/scala/tools/nsc/transform/Erasure.scala
index f0a7e0d1f8..6da38a28bd 100755
--- a/sources/scala/tools/nsc/transform/Erasure.scala
+++ b/sources/scala/tools/nsc/transform/Erasure.scala
@@ -309,8 +309,8 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
*/
private def checkNoDoubleDefs(root: Symbol): unit = {
def doubleDefError(sym1: Symbol, sym2: Symbol) = {
- val tpe1 = atPhase(refchecksPhase.next)(root.tpe.memberType(sym1));
- val tpe2 = atPhase(refchecksPhase.next)(root.tpe.memberType(sym2));
+ val tpe1 = atPhase(currentRun.refchecksPhase.next)(root.tpe.memberType(sym1));
+ val tpe2 = atPhase(currentRun.refchecksPhase.next)(root.tpe.memberType(sym2));
unit.error(
if (sym1.owner == root) sym1.pos else root.pos,
(if (sym1.owner == sym2.owner) "double definition:\n"
@@ -344,7 +344,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
atPhase(phase.next)(sym1.tpe =:= sym2.tpe)
}
while (opc.hasNext) {
- if (!atPhase(refchecksPhase.next)(
+ if (!atPhase(currentRun.refchecksPhase.next)(
root.thisType.memberType(opc.overriding) matches
root.thisType.memberType(opc.overridden))) {
if (settings.debug.value) log("" + opc.overriding.locationString + " " + opc.overriding.infosString + opc.overridden.locationString + " " + opc.overridden.infosString);
diff --git a/sources/scala/tools/nsc/transform/InfoTransform.scala b/sources/scala/tools/nsc/transform/InfoTransform.scala
index 5710dc7483..a5af6beb06 100755
--- a/sources/scala/tools/nsc/transform/InfoTransform.scala
+++ b/sources/scala/tools/nsc/transform/InfoTransform.scala
@@ -18,12 +18,14 @@ abstract class InfoTransform extends Transform {
protected def changesBaseClasses = true;
class Phase(prev: scala.tools.nsc.Phase) extends super.Phase(prev) {
- val infoTransformer = new InfoTransformer {
- val phase = Phase.this;
- val changesBaseClasses = InfoTransform.this.changesBaseClasses;
- def transform(sym: Symbol, tpe: Type): Type = transformInfo(sym, tpe);
+ if (infoTransformers.nextFrom(id).pid != id) {
+ val infoTransformer = new InfoTransformer {
+ val pid = id;
+ val changesBaseClasses = InfoTransform.this.changesBaseClasses;
+ def transform(sym: Symbol, tpe: Type): Type = transformInfo(sym, tpe);
+ }
+ infoTransformers.insert(infoTransformer)
}
- infoTransformers.insert(infoTransformer)
}
}
diff --git a/sources/scala/tools/nsc/transform/Mixin.scala b/sources/scala/tools/nsc/transform/Mixin.scala
index 7e120adb69..bf8c94e572 100755
--- a/sources/scala/tools/nsc/transform/Mixin.scala
+++ b/sources/scala/tools/nsc/transform/Mixin.scala
@@ -29,9 +29,13 @@ abstract class Mixin extends InfoTransform {
private def rebindSuper(base: Symbol, member: Symbol, prevowner: Symbol): Symbol = {
var bcs = base.info.baseClasses.dropWhile(prevowner !=).tail;
+ assert(!bcs.isEmpty, "" + prevowner + " " + base.info.baseClasses);//debug
var sym: Symbol = NoSymbol;
while (!bcs.isEmpty && sym == NoSymbol) {
- if (settings.debug.value) log("rebindsuper " + bcs.head + " " + bcs.head.info.nonPrivateDecl(member.name));
+ if (settings.debug.value) {
+ val other = bcs.head.info.nonPrivateDecl(member.name);
+ log("rebindsuper " + bcs.head + " " + other + " " + other.tpe + " " + sym.tpe + " " + other.hasFlag(DEFERRED));
+ }
sym = member.overridingSymbol(bcs.head).suchThat(sym => !sym.hasFlag(DEFERRED));
bcs = bcs.tail
}
diff --git a/sources/scala/tools/nsc/transform/Transform.scala b/sources/scala/tools/nsc/transform/Transform.scala
index 4d7aebbc71..cfdf796f27 100644
--- a/sources/scala/tools/nsc/transform/Transform.scala
+++ b/sources/scala/tools/nsc/transform/Transform.scala
@@ -13,14 +13,11 @@ abstract class Transform extends SubComponent {
/** The transformer factory */
protected def newTransformer(unit: global.CompilationUnit): global.Transformer;
- def resetTransform: unit = {}
-
/** Create a new phase which applies transformer */
def newPhase(prev: scala.tools.nsc.Phase): StdPhase = new Phase(prev);
/** The phase defined by this transform */
class Phase(prev: scala.tools.nsc.Phase) extends StdPhase(prev) {
- override def resetPhase: unit = resetTransform;
def apply(unit: global.CompilationUnit): unit = {
newTransformer(unit).transformUnit(unit);
}
diff --git a/sources/scala/tools/nsc/typechecker/Analyzer.scala b/sources/scala/tools/nsc/typechecker/Analyzer.scala
index f08cb58fda..5c974bbb7a 100644
--- a/sources/scala/tools/nsc/typechecker/Analyzer.scala
+++ b/sources/scala/tools/nsc/typechecker/Analyzer.scala
@@ -33,7 +33,7 @@ abstract class Analyzer
val global: Analyzer.this.global.type = Analyzer.this.global;
val phaseName = "typer";
def newPhase(_prev: Phase): StdPhase = new StdPhase(_prev) {
- override def resetPhase: unit = resetTyper;
+ resetTyper;
def apply(unit: CompilationUnit): unit =
unit.body = newTyper(startContext.make(unit)).typed(unit.body)
}
diff --git a/sources/scala/tools/nsc/typechecker/Contexts.scala b/sources/scala/tools/nsc/typechecker/Contexts.scala
index d164999752..0a32baab75 100755
--- a/sources/scala/tools/nsc/typechecker/Contexts.scala
+++ b/sources/scala/tools/nsc/typechecker/Contexts.scala
@@ -43,9 +43,7 @@ abstract class Contexts: Analyzer {
var sc = startContext;
while (sc != NoContext) {
sc.tree match {
- case Import(qual, _) =>
- qual.tpe = singleType(qual.symbol.owner.thisType, qual.symbol);
- System.out.println("resetting " + qual + " to " + qual.tpe)
+ case Import(qual, _) => qual.tpe = singleType(qual.symbol.owner.thisType, qual.symbol);
case _ =>
}
sc = sc.outer
@@ -192,6 +190,7 @@ abstract class Contexts: Analyzer {
}
private var implicitsCache: List[List[ImplicitInfo]] = null;
+ private var implicitsRun: CompilerRun = NoRun;
private def collectImplicits(syms: List[Symbol], pre: Type): List[ImplicitInfo] =
for (val sym <- syms; sym.hasFlag(IMPLICIT) && isAccessible(sym, pre, false))
@@ -215,7 +214,8 @@ abstract class Contexts: Analyzer {
}
def implicitss: List[List[ImplicitInfo]] = {
- if (implicitsCache == null) {
+ if (implicitsRun != currentRun) {
+ implicitsRun = currentRun;
val newImplicits: List[ImplicitInfo] =
if (owner != outer.owner && owner.isClass && !owner.isPackageClass) {
if (!owner.isInitialized) return outer.implicitss;
diff --git a/sources/scala/tools/nsc/typechecker/Infer.scala b/sources/scala/tools/nsc/typechecker/Infer.scala
index b6bd8a99dc..580dd3b20b 100755
--- a/sources/scala/tools/nsc/typechecker/Infer.scala
+++ b/sources/scala/tools/nsc/typechecker/Infer.scala
@@ -502,7 +502,7 @@ abstract class Infer: Analyzer {
{val tp1 = pre.memberType(sym1);
val tp2 = pre.memberType(sym2);
tp2 == ErrorType ||
- !global.infer.isCompatible(tp2, pt) && global.infer.isCompatible(tp1, pt) ||
+ !global.typer.infer.isCompatible(tp2, pt) && global.typer.infer.isCompatible(tp1, pt) ||
(tp2.paramSectionCount > 0) && (tp1.paramSectionCount == 0 || specializes(tp1, tp2))
});
val best = ((NoSymbol: Symbol) /: alts1) ((best, alt) =>
diff --git a/sources/scala/tools/nsc/typechecker/Namers.scala b/sources/scala/tools/nsc/typechecker/Namers.scala
index 2b3a277244..9fe435c167 100755
--- a/sources/scala/tools/nsc/typechecker/Namers.scala
+++ b/sources/scala/tools/nsc/typechecker/Namers.scala
@@ -72,7 +72,7 @@ trait Namers: Analyzer {
private def enterClassSymbol(pos: int, mods: int, name: Name): Symbol = {
val c: Symbol = context.scope.lookup(name);
if (c.isType && c.isExternal && context.scope == c.owner.info.decls) {
- symSource(c) = context.unit.source.getFile();
+ currentRun.symSource(c) = context.unit.source.getFile();
updatePosFlags(c, pos, mods);
} else {
enterInScope(context.owner.newClass(pos, name).setFlag(mods))
@@ -82,7 +82,7 @@ trait Namers: Analyzer {
private def enterModuleSymbol(pos: int, mods: int, name: Name): Symbol = {
val m: Symbol = context.scope.lookup(name);
if (m.isTerm && !m.isPackage && m.isExternal && (context.scope == m.owner.info.decls)) {
- symSource(m) = context.unit.source.getFile();
+ currentRun.symSource(m) = context.unit.source.getFile();
updatePosFlags(m, pos, mods)
} else {
val newm = context.owner.newModule(pos, name);
@@ -95,7 +95,7 @@ trait Namers: Analyzer {
private def enterCaseFactorySymbol(pos: int, mods: int, name: Name): Symbol = {
val m: Symbol = context.scope.lookup(name);
if (m.isTerm && !m.isPackage && m.isExternal && context.scope == m.owner.info.decls) {
- symSource(m) = context.unit.source.getFile();
+ currentRun.symSource(m) = context.unit.source.getFile();
updatePosFlags(m, pos, mods)
} else {
enterInScope(context.owner.newMethod(pos, name).setFlag(mods))
diff --git a/sources/scala/tools/nsc/typechecker/RefChecks.scala b/sources/scala/tools/nsc/typechecker/RefChecks.scala
index bd2785fde6..8a908a6304 100755
--- a/sources/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/sources/scala/tools/nsc/typechecker/RefChecks.scala
@@ -42,12 +42,14 @@ abstract class RefChecks extends InfoTransform {
/** the following two members override abstract members in Transform */
val phaseName: String = "refchecks";
+ override def phaseNewFlags: long = lateMETHOD;
+
def newTransformer(unit: CompilationUnit): Transformer = new RefCheckTransformer(unit);
override def changesBaseClasses = false;
def transformInfo(sym: Symbol, tp: Type): Type = {
if (sym.isModule && !sym.isStatic) {
- sym setFlag (METHOD | STABLE);
+ sym setFlag (lateMETHOD | STABLE);
PolyType(List(), tp)
} else tp
}
@@ -477,7 +479,7 @@ abstract class RefChecks extends InfoTransform {
/* Check whether argument types conform to bounds of type parameters */
def checkBounds(tparams: List[Symbol], argtps: List[Type]): unit = try {
- infer.checkBounds(tree.pos, tparams, argtps, "");
+ typer.infer.checkBounds(tree.pos, tparams, argtps, "");
} catch {
case ex: TypeError => unit.error(tree.pos, ex.getMessage());
}
diff --git a/sources/scala/tools/nsc/typechecker/TreeCheckers.scala b/sources/scala/tools/nsc/typechecker/TreeCheckers.scala
index 95a3af20bf..e2bb54384f 100644
--- a/sources/scala/tools/nsc/typechecker/TreeCheckers.scala
+++ b/sources/scala/tools/nsc/typechecker/TreeCheckers.scala
@@ -16,7 +16,7 @@ abstract class TreeCheckers extends Analyzer {
def checkTrees: unit = {
System.out.println("[consistency check at start of phase " + phase + "]");
- for (val unit <- units) check(unit);
+ for (val unit <- currentRun.units) check(unit);
}
def check(unit: CompilationUnit): unit = {
@@ -89,7 +89,7 @@ abstract class TreeCheckers extends Analyzer {
}
if (tree.pos == Position.NOPOS && tree != EmptyTree) {
error(tree.pos, "tree without position: " + tree)
- } else if (tree.tpe == null && phase.id >= typerPhase.id) {
+ } else if (tree.tpe == null && phase.id >= currentRun.typerPhase.id) {
error(tree.pos, "tree without type: " + tree);
} else if (tree.isDef && tree.symbol.owner != currentOwner) {
var owner = currentOwner;
diff --git a/sources/scala/tools/nsc/typechecker/Typers.scala b/sources/scala/tools/nsc/typechecker/Typers.scala
index e5d409abe9..a1f1c02171 100755
--- a/sources/scala/tools/nsc/typechecker/Typers.scala
+++ b/sources/scala/tools/nsc/typechecker/Typers.scala
@@ -533,7 +533,7 @@ abstract class Typers: Analyzer {
validateParentClasses(parents1, selfType);
val body1 = templ.body flatMap addGetterSetter;
var body2 = typedStats(body1, templ.symbol);
- if (clazz.isTrait && phase.id <= typerPhase.id) {
+ if (clazz.isTrait && phase.id <= currentRun.typerPhase.id) {
val superAccs = new ListBuffer[Tree];
new AddSuperAccessors(clazz, superAccs).traverseTrees(body2);
body2 = superAccs.toList ::: body2;
@@ -546,7 +546,7 @@ abstract class Typers: Analyzer {
var tpt1 = checkNoEscaping.privates(sym, typedType(vdef.tpt));
val rhs1 =
if (vdef.rhs.isEmpty) {
- if (sym.isVariable && sym.owner.isTerm && phase.id <= typerPhase.id)
+ if (sym.isVariable && sym.owner.isTerm && phase.id <= currentRun.typerPhase.id)
error(vdef.pos, "local variables must be initialized");
vdef.rhs
} else {
@@ -1078,11 +1078,11 @@ abstract class Typers: Analyzer {
case Attributed(attr, defn) =>
val attr1 = typed(attr, AttributeClass.tpe);
val defn1 = typed(defn, mode, pt);
- val existing = attributes.get(defn1.symbol) match {
+ val existing = currentRun.attributes.get(defn1.symbol) match {
case None => List()
case Some(attrs) => attrs
}
- attributes(defn1.symbol) = attrInfo(attr1) :: existing;
+ currentRun.attributes(defn1.symbol) = attrInfo(attr1) :: existing;
defn1
case DocDef(comment, defn) =>