summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2006-06-02 14:32:27 +0000
committerMartin Odersky <odersky@gmail.com>2006-06-02 14:32:27 +0000
commit8f660e3ddaadbbc21055f942dbb8f132553f87ff (patch)
tree38ae80897d1ba12e55a7a065755f53a03543d087 /src/compiler
parent9040a1ea865b2be8ea3e7d034dc52541f9f52c3f (diff)
downloadscala-8f660e3ddaadbbc21055f942dbb8f132553f87ff.tar.gz
scala-8f660e3ddaadbbc21055f942dbb8f132553f87ff.tar.bz2
scala-8f660e3ddaadbbc21055f942dbb8f132553f87ff.zip
some changes to plug space leaks
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/CompilationUnits.scala6
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala14
-rw-r--r--src/compiler/scala/tools/nsc/Main.scala2
-rw-r--r--src/compiler/scala/tools/nsc/Phase.scala12
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala1
-rw-r--r--src/compiler/scala/tools/nsc/matching/Autom2.scala2
-rw-r--r--src/compiler/scala/tools/nsc/matching/CodeFactory.scala49
-rw-r--r--src/compiler/scala/tools/nsc/matching/SequenceMatchers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/matching/TransMatcher.scala7
-rw-r--r--src/compiler/scala/tools/nsc/symtab/RunId.scala11
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolTable.scala72
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala680
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala68
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala3
14 files changed, 454 insertions, 475 deletions
diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala
index 6633f7d311..46e95dbb29 100644
--- a/src/compiler/scala/tools/nsc/CompilationUnits.scala
+++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala
@@ -16,12 +16,6 @@ trait CompilationUnits requires Global {
private var unitCount = 0;
class CompilationUnit(val source: SourceFile) {
- unitCount = unitCount + 1
- if (settings.statistics.value) Console.println("creating unit: "+unitCount)
- override def finalize() = {
- unitCount = unitCount - 1
- if (settings.statistics.value) Console.println("collecting unit: "+unitCount)
- }
/** the fresh name creator */
var fresh = new FreshNameCreator;
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index d6b650c27c..a0d537b8cf 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -366,19 +366,15 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
private var curRun: Run = null
def currentRun: Run = curRun
- override def currentRunId: RunId = if (curRun == null) NoRunId else curRun.id
+ private var curRunId = 0
+ override def currentRunId = curRunId
private var runCount = 0;
class Run {
- runCount = runCount + 1
- if (settings.statistics.value) Console.println("creating run: "+runCount)
- override def finalize() = {
- runCount = runCount - 1
- if (settings.statistics.value) Console.println("collecting run: "+runCount)
- }
-
- val id = new RunId
+ curRunId = curRunId + 1
+ assert(curRunId > 0)
+ //Console.println("starting run: " + id);
var currentUnit: CompilationUnit = _
curRun = this
val firstPhase = syntaxAnalyzer.newPhase(NoPhase)
diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala
index 41345083e1..62fb2a0bdb 100644
--- a/src/compiler/scala/tools/nsc/Main.scala
+++ b/src/compiler/scala/tools/nsc/Main.scala
@@ -52,7 +52,7 @@ object Main extends Object with EvalLoop {
try {
object compiler extends Global(command.settings, reporter);
if (command.settings.resident.value)
- resident(compiler);
+ resident(compiler)
else if (command.files.isEmpty)
reporter.info(null, command.usageMsg, true)
else {
diff --git a/src/compiler/scala/tools/nsc/Phase.scala b/src/compiler/scala/tools/nsc/Phase.scala
index 4ca3aa2e9c..d863e2a5fd 100644
--- a/src/compiler/scala/tools/nsc/Phase.scala
+++ b/src/compiler/scala/tools/nsc/Phase.scala
@@ -7,8 +7,20 @@ package scala.tools.nsc;
import symtab.Flags;
+object Phase {
+ var phaseCount = 0;
+
+}
+
abstract class Phase(val prev: Phase) {
+ Phase.phaseCount = Phase.phaseCount + 1
+ Console.println("creating phase: "+Phase.phaseCount)
+ override def finalize() = {
+ Phase.phaseCount = Phase.phaseCount - 1
+ Console.println("collecting phase: "+Phase.phaseCount)
+ }
+
type Id = int;
val id: Id = if (prev == null) 0 else prev.id + 1;
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index b130ddb9a7..19dc40af97 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -53,6 +53,7 @@ abstract class GenICode extends SubComponent {
this.unit = unit;
log("Generating icode for " + unit);
gen(unit.body);
+ this.unit = null
}
def gen(tree: Tree): Context = gen(tree, new Context());
diff --git a/src/compiler/scala/tools/nsc/matching/Autom2.scala b/src/compiler/scala/tools/nsc/matching/Autom2.scala
index 5d097a38b7..8dbe154f66 100644
--- a/src/compiler/scala/tools/nsc/matching/Autom2.scala
+++ b/src/compiler/scala/tools/nsc/matching/Autom2.scala
@@ -153,7 +153,7 @@ trait Autom2 requires TransMatcher {
/** some error happened which is due to bug in translation/automaton
*/
final def code_error(): Tree = {
- ThrowMatchError( pos , funRetType() );
+ ThrowMatchError( pos , TypeTree(funRetType()) );
}
def code_fail(): Tree = {
diff --git a/src/compiler/scala/tools/nsc/matching/CodeFactory.scala b/src/compiler/scala/tools/nsc/matching/CodeFactory.scala
index 8470d6ef10..d879b9be47 100644
--- a/src/compiler/scala/tools/nsc/matching/CodeFactory.scala
+++ b/src/compiler/scala/tools/nsc/matching/CodeFactory.scala
@@ -188,17 +188,6 @@ trait CodeFactory requires TransMatcher {
def GreaterThan(left: Tree , right: Tree ): Tree = Apply(Select(left, nme.GT), List(right));
- //deprecated
- def ThrowMatchError(pos: Int, tpe: Type ) =
- atPos(pos) {
- Throw(
- New(
- TypeTree(definitions.MatchErrorClass.tpe),
- List(List(
- Literal(cunit.toString()),
- Literal(Position.line(cunit.source, pos))))))
- }
-//new
def ThrowMatchError(pos: Int, obj: Tree ) =
atPos(pos) {
Throw(
@@ -209,43 +198,5 @@ trait CodeFactory requires TransMatcher {
))))
}
-/*
- Apply(
- TypeApply(
- gen.mkAttributedRef(definitions.MatchError_fail),
- List(TypeTree(tpe))
- ),
- List(
- Literal(cunit.toString()),
- Literal(Position.line(cunit.source, pos))
- )
- );
-*/
-
- /* // ?!
- def ThrowMatchError(pos:int , tree:Tree ) =
- Apply(
- gen.mkAttributedRef(definitions.MatchError_report),
- List(
- Literal(cunit.toString()),
- Literal(Position.line(cunit.source, pos)),
- tree
- )
- );
- */
-
-// def Error(pos: Int) =
-// ThrowMatchError(pos);
-
-
- /*
- def newPair(left: Tree, right: Tree) =
- New(
- Apply(
- gen.mkAttributedRef(definitions.TupleClass(2)),
- List(left,right)
- )
- );
- */
}
diff --git a/src/compiler/scala/tools/nsc/matching/SequenceMatchers.scala b/src/compiler/scala/tools/nsc/matching/SequenceMatchers.scala
index f3b8d30170..46e5b54016 100644
--- a/src/compiler/scala/tools/nsc/matching/SequenceMatchers.scala
+++ b/src/compiler/scala/tools/nsc/matching/SequenceMatchers.scala
@@ -116,7 +116,7 @@ trait SequenceMatchers requires TransMatcher {
this._m = _m;
//assert body.length == pat.length;
if( defaultCase == null )
- defaultCase = ThrowMatchError( _m.pos, resultType );
+ defaultCase = ThrowMatchError( _m.pos, TypeTree(resultType) );
val seqType = pat( 0 ).tpe;
val elementType1 = getElemType_Sequence( seqType );
diff --git a/src/compiler/scala/tools/nsc/matching/TransMatcher.scala b/src/compiler/scala/tools/nsc/matching/TransMatcher.scala
index 45dbdb706e..23f33ac29f 100644
--- a/src/compiler/scala/tools/nsc/matching/TransMatcher.scala
+++ b/src/compiler/scala/tools/nsc/matching/TransMatcher.scala
@@ -31,7 +31,6 @@ with RightTracers {
val phaseName = "transmatcher";
protected def newTransformer(unit: global.CompilationUnit): global.Transformer = {
- cunit = unit;
new TransMatch
}
@@ -179,6 +178,12 @@ with RightTracers {
class TransMatch extends Transformer {
+ override def transformUnit(unit: CompilationUnit) = {
+ cunit = unit
+ super.transformUnit(unit)
+ cunit = null
+ }
+
/** a casedef with sequence subpatterns like
*
* case ..x @ ().. => body
diff --git a/src/compiler/scala/tools/nsc/symtab/RunId.scala b/src/compiler/scala/tools/nsc/symtab/RunId.scala
deleted file mode 100644
index 3dce5340d3..0000000000
--- a/src/compiler/scala/tools/nsc/symtab/RunId.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-/* NSC -- new Scala compiler
- * Copyright 2005-2006 LAMP/EPFL
- * @author Martin Odersky
- */
-// $Id: RunId.scala 7272 2006-04-27 17:40:29 +0200 (Thu, 27 Apr 2006) michelou $
-
-package scala.tools.nsc.symtab
-
-class RunId {
-}
-
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
index 1ff1bb2d5b..74642f0eb7 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
@@ -3,9 +3,9 @@
* @author Martin Odersky
*/
// $Id$
-package scala.tools.nsc.symtab;
+package scala.tools.nsc.symtab
-import util._;
+import util._
abstract class SymbolTable extends Names
with Symbols
@@ -16,38 +16,68 @@ abstract class SymbolTable extends Names
with InfoTransformers
with StdNames
{
- def settings: Settings;
- def rootLoader: LazyType;
- def log(msg: Object): unit;
+ def settings: Settings
+ def rootLoader: LazyType
+ def log(msg: Object): unit
- def forCLDC: Boolean;
+ /** Are we compiling for the J2ME CLDC platform? */
+ def forCLDC: Boolean
+
+ private var ph: Phase = NoPhase
+ private var period = 0
+
+ def phase: Phase = ph
- private var ph: Phase = NoPhase;
- def phase: Phase = ph;
def phase_=(p: Phase): unit = {
- //System.out.println("setting phase to " + p);
- assert(p != null && p != NoPhase);
+ //System.out.println("setting phase to " + p)
+ assert(p != null && p != NoPhase)
ph = p
+ period = (currentRunId << 8) + p.id
}
- final val NoRunId = null;
+ /** An ordinal number for compiler runs. First run has number 1. */
+ type RunId = int
+
+ val NoRunId = 0
+
+ /** The current compiler run identifier. */
+ def currentRunId: RunId
- /** The current compiler run. */
- def currentRunId: RunId;
+ /** A period is an ordinal number for a phase in a run.
+ * Phases in later runs have higher periods than phases in earlier runs.
+ * Later phases have higher periods than earlier phases in the same run.
+ */
+ type Period = int
+ val NoPeriod = -1
+
+ /** The run identifier of the given period */
+ def runId(period: Period): RunId = period >> 8
+
+ /** The phase identifier of the given period */
+ def phaseId(period: Period): Phase#Id = period & 0xFF
+
+ /** The current period */
+ def currentPeriod: Period = {
+ //assert(period == (currentRunId << 8) + phase.id)
+ period
+ }
+ /** Perform given operation at given phase */
def atPhase[T](ph: Phase)(op: => T): T = {
- val current = phase;
- phase = ph;
- val result = op;
- phase = current;
+ val current = phase
+ phase = ph
+ val result = op
+ phase = current
result
}
+ /** The set of all installed infotransformers */
var infoTransformers = new InfoTransformer {
- val pid = NoPhase.id;
- val changesBaseClasses = true;
- def transform(sym: Symbol, tpe: Type): Type = tpe;
+ val pid = NoPhase.id
+ val changesBaseClasses = true
+ def transform(sym: Symbol, tpe: Type): Type = tpe
}
- val phaseWithId: Array[Phase];
+ /** The phase which has given index as identifier */
+ val phaseWithId: Array[Phase]
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index c075908ca8..4db6d26e83 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -4,51 +4,51 @@
*/
// $Id$
-package scala.tools.nsc.symtab;
+package scala.tools.nsc.symtab
-import scala.tools.nsc.io.AbstractFile;
-import scala.tools.nsc.util.{Position, SourceFile};
-import Flags._;
+import scala.tools.nsc.io.AbstractFile
+import scala.tools.nsc.util.{Position, SourceFile}
+import Flags._
trait Symbols requires SymbolTable {
- import definitions._;
+ import definitions._
- private var ids = 0;
+ private var ids = 0
//for statistics:
- def symbolCount = ids;
- var typeSymbolCount = 0;
- var classSymbolCount = 0;
+ def symbolCount = ids
+ var typeSymbolCount = 0
+ var classSymbolCount = 0
- type AttrInfo = Pair[Type, List[Constant]];
+ type AttrInfo = Pair[Type, List[Constant]]
- val emptySymbolArray = new Array[Symbol](0);
+ val emptySymbolArray = new Array[Symbol](0)
/** The class for all symbols */
abstract class Symbol(initOwner: Symbol, initPos: int, initName: Name) {
- var rawowner = initOwner;
- var rawname = initName;
- var rawflags: long = 0;
- private var rawpos = initPos;
+ var rawowner = initOwner
+ var rawname = initName
+ var rawflags: long = 0
+ private var rawpos = initPos
val id = { ids = ids + 1; ids }
- var validForRunId: RunId = NoRunId;
+ var validForRunId: RunId = NoRunId
- def pos = rawpos;
+ def pos = rawpos
def setPos(pos: int): this.type = { this.rawpos = pos; this }
def namePos(source: SourceFile) = {
- val buf = source.content;
- if (pos == Position.NOPOS) Position.NOPOS;
- else if (isTypeParameter) pos - name.length;
+ val buf = source.content
+ if (pos == Position.NOPOS) Position.NOPOS
+ else if (isTypeParameter) pos - name.length
else if (isVariable || isMethod || isClass || isModule) {
- var ret = pos;
- if (buf(pos) == ',') ret = ret + 1;
- else if (isClass) ret = ret + ("class").length();
- else if (isModule) ret = ret + ("object").length();
- else ret = ret + ("var").length();
- while (Character.isWhitespace(buf(ret))) ret = ret + 1;
+ var ret = pos
+ if (buf(pos) == ',') ret = ret + 1
+ else if (isClass) ret = ret + ("class").length()
+ else if (isModule) ret = ret + ("object").length()
+ else ret = ret + ("var").length()
+ while (Character.isWhitespace(buf(ret))) ret = ret + 1
ret
}
else if (isValue) {
@@ -57,94 +57,94 @@ trait Symbols requires SymbolTable {
(buf(pos + 1) == 'a') &&
(buf(pos + 2) == 'l') &&
(buf(pos + 3) == ' ')) {
- var pos0 = pos + 4;
+ var pos0 = pos + 4
while (pos0 < buf.length && Character.isWhitespace(buf(pos0)))
- pos0 = pos0 + 1;
- pos0;
+ pos0 = pos0 + 1
+ pos0
- } else pos;
- } else pos;
+ } else pos
+ } else pos
}
- else -1;
+ else -1
}
- var attributes: List[AttrInfo] = List();
+ var attributes: List[AttrInfo] = List()
- var privateWithin: Symbol = _;
+ var privateWithin: Symbol = _
// Creators -------------------------------------------------------------------
final def newValue(pos: int, name: Name) =
- new TermSymbol(this, pos, name);
+ new TermSymbol(this, pos, name)
final def newVariable(pos: int, name: Name) =
- newValue(pos, name).setFlag(MUTABLE);
+ newValue(pos, name).setFlag(MUTABLE)
final def newValueParameter(pos: int, name: Name) =
- newValue(pos, name).setFlag(PARAM);
+ newValue(pos, name).setFlag(PARAM)
final def newLocalDummy(pos: int) =
- newValue(pos, nme.LOCAL(this)).setInfo(NoType);
+ newValue(pos, nme.LOCAL(this)).setInfo(NoType)
final def newMethod(pos: int, name: Name) =
- newValue(pos, name).setFlag(METHOD);
+ newValue(pos, name).setFlag(METHOD)
final def newLabel(pos: int, name: Name) =
- newMethod(pos, name).setFlag(LABEL);
+ newMethod(pos, name).setFlag(LABEL)
final def newConstructor(pos: int) =
- newMethod(pos, nme.CONSTRUCTOR);
+ newMethod(pos, nme.CONSTRUCTOR)
final def newModule(pos: int, name: Name, clazz: ClassSymbol) =
- new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL).setModuleClass(clazz);
+ new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL).setModuleClass(clazz)
final def newModule(pos: int, name: Name) = {
- val m = new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL);
+ val m = new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL)
m.setModuleClass(new ModuleClassSymbol(m))
}
final def newPackage(pos: int, name: Name) = {
- assert(name == nme.ROOT || isPackageClass);
- val m = newModule(pos, name).setFlag(JAVA | PACKAGE);
- m.moduleClass.setFlag(JAVA | PACKAGE);
+ assert(name == nme.ROOT || isPackageClass)
+ val m = newModule(pos, name).setFlag(JAVA | PACKAGE)
+ m.moduleClass.setFlag(JAVA | PACKAGE)
m
}
final def newThisSym(pos: int) = {
- newValue(pos, nme.this_).setFlag(SYNTHETIC);
+ newValue(pos, nme.this_).setFlag(SYNTHETIC)
}
final def newThisSkolem: Symbol =
new ThisSkolem(owner, pos, name, this)
- .setFlag(SYNTHETIC | FINAL);
+ .setFlag(SYNTHETIC | FINAL)
final def newImport(pos: int) =
- newValue(pos, nme.IMPORT).setFlag(SYNTHETIC);
+ newValue(pos, nme.IMPORT).setFlag(SYNTHETIC)
final def newOverloaded(pre: Type, alternatives: List[Symbol]): Symbol =
newValue(alternatives.head.pos, alternatives.head.name)
.setFlag(OVERLOADED)
.setInfo(OverloadedType(pre, alternatives))
final def newErrorValue(name: Name) =
- newValue(pos, name).setFlag(SYNTHETIC | IS_ERROR).setInfo(ErrorType);
+ newValue(pos, name).setFlag(SYNTHETIC | IS_ERROR).setInfo(ErrorType)
final def newAliasType(pos: int, name: Name) =
- new TypeSymbol(this, pos, name);
+ new TypeSymbol(this, pos, name)
final def newAbstractType(pos: int, name: Name) =
- new TypeSymbol(this, pos, name).setFlag(DEFERRED);
+ new TypeSymbol(this, pos, name).setFlag(DEFERRED)
final def newTypeParameter(pos: int, name: Name) =
- newAbstractType(pos, name).setFlag(PARAM);
+ newAbstractType(pos, name).setFlag(PARAM)
final def newTypeSkolem: Symbol =
new TypeSkolem(owner, pos, name, this)
- .setFlag(flags);
+ .setFlag(flags)
final def newClass(pos: int, name: Name) =
- new ClassSymbol(this, pos, name);
+ new ClassSymbol(this, pos, name)
final def newModuleClass(pos: int, name: Name) =
- new ModuleClassSymbol(this, pos, name);
+ new ModuleClassSymbol(this, pos, name)
final def newAnonymousClass(pos: int) =
- newClass(pos, nme.ANON_CLASS_NAME.toTypeName);
+ newClass(pos, nme.ANON_CLASS_NAME.toTypeName)
final def newAnonymousFunctionClass(pos: int) = {
- val anonfun = newClass(pos, nme.ANON_FUN_NAME.toTypeName);
+ val anonfun = newClass(pos, nme.ANON_FUN_NAME.toTypeName)
anonfun.attributes =
- Pair(definitions.SerializableAttr.tpe, List()) :: anonfun.attributes;
+ Pair(definitions.SerializableAttr.tpe, List()) :: anonfun.attributes
anonfun
}
final def newRefinementClass(pos: int) =
- newClass(pos, nme.REFINE_CLASS_NAME.toTypeName);
+ newClass(pos, nme.REFINE_CLASS_NAME.toTypeName)
final def newErrorClass(name: Name) = {
- val clazz = newClass(pos, name).setFlag(SYNTHETIC | IS_ERROR);
- clazz.setInfo(ClassInfoType(List(), new ErrorScope(this), clazz));
+ val clazz = newClass(pos, name).setFlag(SYNTHETIC | IS_ERROR)
+ clazz.setInfo(ClassInfoType(List(), new ErrorScope(this), clazz))
clazz
}
final def newErrorSymbol(name: Name): Symbol =
- if (name.isTypeName) newErrorClass(name) else newErrorValue(name);
+ if (name.isTypeName) newErrorClass(name) else newErrorValue(name)
// Tests ----------------------------------------------------------------------
@@ -152,91 +152,91 @@ trait Symbols requires SymbolTable {
def isType = false; //to be overridden
def isClass = false; //to be overridden
- final def isValue = isTerm && !(isModule && hasFlag(PACKAGE | JAVA));
- final def isVariable = isTerm && hasFlag(MUTABLE) && !isMethod;
- final def isCapturedVariable = isVariable && hasFlag(CAPTURED);
+ final def isValue = isTerm && !(isModule && hasFlag(PACKAGE | JAVA))
+ final def isVariable = isTerm && hasFlag(MUTABLE) && !isMethod
+ final def isCapturedVariable = isVariable && hasFlag(CAPTURED)
- final def isGetter = isTerm && hasFlag(ACCESSOR) && !nme.isSetterName(name);
- final def isSetter = isTerm && hasFlag(ACCESSOR) && nme.isSetterName(name);
+ final def isGetter = isTerm && hasFlag(ACCESSOR) && !nme.isSetterName(name)
+ final def isSetter = isTerm && hasFlag(ACCESSOR) && nme.isSetterName(name)
//todo: make independent of name, as this can be forged.
- final def hasGetter = isTerm && nme.isLocalName(name);
- final def isValueParameter = isTerm && hasFlag(PARAM);
- final def isLocalDummy = isTerm && nme.isLocalDummyName(name);
- final def isMethod = isTerm && hasFlag(METHOD);
- final def isSourceMethod = isTerm && (flags & (METHOD | STABLE)) == METHOD;
- final def isLabel = isTerm && hasFlag(LABEL);
- final def isClassConstructor = isTerm && (name == nme.CONSTRUCTOR);
- final def isMixinConstructor = isTerm && (name == nme.MIXIN_CONSTRUCTOR);
- final def isConstructor = isTerm && (name == nme.CONSTRUCTOR) || (name == nme.MIXIN_CONSTRUCTOR);
- final def isModule = isTerm && hasFlag(MODULE);
- final def isStaticModule = isModule && isStatic && !isMethod;
- final def isPackage = isModule && hasFlag(PACKAGE);
- final def isThisSym = isTerm && name == nme.this_;
- final def isThisSkolem = isTerm && deSkolemize != this;
- final def isError = hasFlag(IS_ERROR);
+ final def hasGetter = isTerm && nme.isLocalName(name)
+ final def isValueParameter = isTerm && hasFlag(PARAM)
+ final def isLocalDummy = isTerm && nme.isLocalDummyName(name)
+ final def isMethod = isTerm && hasFlag(METHOD)
+ final def isSourceMethod = isTerm && (flags & (METHOD | STABLE)) == METHOD
+ final def isLabel = isTerm && hasFlag(LABEL)
+ final def isClassConstructor = isTerm && (name == nme.CONSTRUCTOR)
+ final def isMixinConstructor = isTerm && (name == nme.MIXIN_CONSTRUCTOR)
+ final def isConstructor = isTerm && (name == nme.CONSTRUCTOR) || (name == nme.MIXIN_CONSTRUCTOR)
+ final def isModule = isTerm && hasFlag(MODULE)
+ final def isStaticModule = isModule && isStatic && !isMethod
+ final def isPackage = isModule && hasFlag(PACKAGE)
+ final def isThisSym = isTerm && name == nme.this_
+ final def isThisSkolem = isTerm && deSkolemize != this
+ final def isError = hasFlag(IS_ERROR)
final def isErroneous = isError || isInitialized && tpe.isErroneous
- final def isTrait = isClass & hasFlag(TRAIT);
- final def isAliasType = isType && !isClass && !hasFlag(DEFERRED);
- final def isAbstractType = isType && !isClass && hasFlag(DEFERRED);
- final def isTypeParameterOrSkolem = isType && hasFlag(PARAM);
- final def isTypeParameter = isTypeParameterOrSkolem && deSkolemize == this;
- final def isClassLocalToConstructor = isClass && hasFlag(INCONSTRUCTOR);
- final def isAnonymousClass = isClass && (originalName startsWith nme.ANON_CLASS_NAME);
+ final def isTrait = isClass & hasFlag(TRAIT)
+ final def isAliasType = isType && !isClass && !hasFlag(DEFERRED)
+ final def isAbstractType = isType && !isClass && hasFlag(DEFERRED)
+ final def isTypeParameterOrSkolem = isType && hasFlag(PARAM)
+ final def isTypeParameter = isTypeParameterOrSkolem && deSkolemize == this
+ final def isClassLocalToConstructor = isClass && hasFlag(INCONSTRUCTOR)
+ final def isAnonymousClass = isClass && (originalName startsWith nme.ANON_CLASS_NAME)
// startsWith necessary because name may grow when lifted and also because of anonymous function classes
final def isRefinementClass = isClass && name == nme.REFINE_CLASS_NAME.toTypeName; // no lifting for refinement classes
- final def isModuleClass = isClass && hasFlag(MODULE);
- final def isPackageClass = isClass && hasFlag(PACKAGE);
- final def isRoot = isPackageClass && name == nme.ROOT.toTypeName;
- final def isRootPackage = isPackage && name == nme.ROOT;
- final def isEmptyPackage = isPackage && name == nme.EMPTY_PACKAGE_NAME;
- final def isEmptyPackageClass = isPackageClass && name == nme.EMPTY_PACKAGE_NAME.toTypeName;
+ final def isModuleClass = isClass && hasFlag(MODULE)
+ final def isPackageClass = isClass && hasFlag(PACKAGE)
+ final def isRoot = isPackageClass && name == nme.ROOT.toTypeName
+ final def isRootPackage = isPackage && name == nme.ROOT
+ final def isEmptyPackage = isPackage && name == nme.EMPTY_PACKAGE_NAME
+ final def isEmptyPackageClass = isPackageClass && name == nme.EMPTY_PACKAGE_NAME.toTypeName
/** Does this symbol denote a stable value? */
final def isStable =
- isTerm && !hasFlag(MUTABLE) && (!hasFlag(METHOD | BYNAMEPARAM) || hasFlag(STABLE));
+ isTerm && !hasFlag(MUTABLE) && (!hasFlag(METHOD | BYNAMEPARAM) || hasFlag(STABLE))
/** Does this symbol denote the primary constructor of its enclosing class? */
final def isPrimaryConstructor =
- isConstructor && owner.primaryConstructor == this;
+ isConstructor && owner.primaryConstructor == this
/** Is this symbol an implementation class for a mixin? */
- final def isImplClass: boolean = isClass && hasFlag(IMPLCLASS);
+ final def isImplClass: boolean = isClass && hasFlag(IMPLCLASS)
/** Is this symbol a trait which needs an implementation class? */
final def needsImplClass: boolean =
- isTrait && (!hasFlag(INTERFACE) || hasFlag(lateINTERFACE)) && !isImplClass;
+ isTrait && (!hasFlag(INTERFACE) || hasFlag(lateINTERFACE)) && !isImplClass
/** Is this a symbol which exists only in the implementation class, not in its trait? */
final def isImplOnly: boolean = (
hasFlag(PRIVATE) ||
(owner.isImplClass || owner.isTrait) &&
(hasFlag(notPRIVATE | LIFTED) && !hasFlag(ACCESSOR | SUPERACCESSOR) || isConstructor)
- );
+ )
/** Is this symbol a module variable ? */
- final def isModuleVar: boolean = isVariable && hasFlag(MODULEVAR);
+ final def isModuleVar: boolean = isVariable && hasFlag(MODULEVAR)
/** Is this symbol static (i.e. with no outer instance)? */
final def isStatic: boolean =
- hasFlag(STATIC) || isRoot || owner.isStaticOwner;
+ hasFlag(STATIC) || isRoot || owner.isStaticOwner
/** Does this symbol denote a class that defines static symbols? */
final def isStaticOwner: boolean =
- isPackageClass || isModuleClass && isStatic;
+ isPackageClass || isModuleClass && isStatic
/** Is this symbol final?*/
final def isFinal: boolean = (
hasFlag(FINAL) ||
isTerm && (
hasFlag(PRIVATE) || isLocal || owner.isClass && owner.hasFlag(FINAL | MODULE))
- );
+ )
/** Is this symbol a sealed class?*/
final def isSealed: boolean =
- isClass && (hasFlag(SEALED) || isUnboxedClass(this));
+ isClass && (hasFlag(SEALED) || isUnboxedClass(this))
/** Is this symbol locally defined? I.e. not accessed from outside `this' instance */
- final def isLocal: boolean = owner.isTerm;
+ final def isLocal: boolean = owner.isTerm
/** Is this symbol a constant? */
final def isConstant: boolean =
@@ -245,11 +245,11 @@ trait Symbols requires SymbolTable {
case PolyType(_, ConstantType(_)) => true
case MethodType(_, ConstantType(_)) => true
case _ => false
- });
+ })
/** Is this class nested in another class or module (not a package)? */
final def isNestedClass: boolean =
- isClass && !isRoot && !owner.isPackageClass;
+ isClass && !isRoot && !owner.isPackageClass
/** Is this class locally defined?
* A class is local, if
@@ -259,7 +259,7 @@ trait Symbols requires SymbolTable {
*/
final def isLocalClass: boolean =
isClass && (isAnonymousClass || isRefinementClass || isLocal ||
- !owner.isPackageClass && owner.isLocalClass);
+ !owner.isPackageClass && owner.isLocalClass)
/** A a member of class `base' is incomplete if (1) it is declared deferred or
* (2) it is abstract override and its super symbol in `base' is nonexistent or inclomplete.
@@ -267,113 +267,113 @@ trait Symbols requires SymbolTable {
final def isIncompleteIn(base: Symbol): boolean = (
(this hasFlag DEFERRED) ||
(this hasFlag ABSOVERRIDE) && {
- val supersym = superSymbol(base);
+ val supersym = superSymbol(base)
supersym == NoSymbol || supersym.isIncompleteIn(base)
}
- );
+ )
final def exists: boolean =
- this != NoSymbol && (!owner.isPackageClass || { rawInfo.load(this); rawInfo != NoType });
+ this != NoSymbol && (!owner.isPackageClass || { rawInfo.load(this); rawInfo != NoType })
final def isInitialized: boolean =
- validForRunId == currentRunId;
+ validForRunId == currentRunId
- final def isCovariant: boolean = isType && hasFlag(COVARIANT);
+ final def isCovariant: boolean = isType && hasFlag(COVARIANT)
- final def isContravariant: boolean = isType && hasFlag(CONTRAVARIANT);
+ final def isContravariant: boolean = isType && hasFlag(CONTRAVARIANT)
/** The variance of this symbol as an integer */
final def variance: int =
if (isCovariant) 1
else if (isContravariant) -1
- else 0;
+ else 0
// Flags, owner, and name attributes --------------------------------------------------------------
- def owner: Symbol = rawowner;
+ def owner: Symbol = rawowner
final def owner_=(owner: Symbol): unit = { rawowner = owner }
- def ownerChain: List[Symbol] = this :: owner.ownerChain;
+ def ownerChain: List[Symbol] = this :: owner.ownerChain
- def name: Name = rawname;
+ def name: Name = rawname
final def name_=(name: Name): unit = { rawname = name }
- def originalName = nme.originalName(name);
+ def originalName = nme.originalName(name)
final def flags = {
- val fs = rawflags & phase.flagMask;
+ val fs = rawflags & phase.flagMask
(fs | ((fs & LateFlags) >>> LateShift)) & ~(fs >>> AntiShift)
}
- final def flags_=(fs: long) = rawflags = fs;
+ final def flags_=(fs: long) = rawflags = fs
final def setFlag(mask: long): this.type = { rawflags = rawflags | mask; this }
final def resetFlag(mask: long): this.type = { rawflags = rawflags & ~mask; this }
- final def getFlag(mask: long): long = flags & mask;
- final def hasFlag(mask: long): boolean = (flags & mask) != 0;
+ final def getFlag(mask: long): long = flags & mask
+ final def hasFlag(mask: long): boolean = (flags & mask) != 0
final def resetFlags: unit = { rawflags = rawflags & TopLevelCreationFlags }
// Info and Type -------------------------------------------------------------------
- private var infos: TypeHistory = null;
- private var limit: Phase#Id = 0;
+ private var infos: TypeHistory = null
+ 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
* for a term symbol, its usual type
*/
- def tpe: Type = info;
+ def tpe: Type = info
/** Get type info associated with symbol at current phase, after
* ensuring that symbol is initialized (i.e. type is completed).
*/
final def info: Type = {
- var cnt = 0;
+ var cnt = 0
while (validForRunId != currentRunId) {
//if (settings.debug.value) System.out.println("completing " + this);//DEBUG
- var ifs = infos;
- assert(ifs != null, this.name);
+ var ifs = infos
+ assert(ifs != null, this.name)
while (ifs.prev != null) {
- ifs = ifs.prev;
+ ifs = ifs.prev
}
- val tp = ifs.info;
+ val tp = ifs.info
//if (settings.debug.value) System.out.println("completing " + this.rawname + tp.getClass());//debug
if ((rawflags & LOCKED) != 0) {
- setInfo(ErrorType);
- throw CyclicReference(this, tp);
+ setInfo(ErrorType)
+ throw CyclicReference(this, tp)
}
- rawflags = rawflags | LOCKED;
- val current = phase;
+ rawflags = rawflags | LOCKED
+ val current = phase
try {
- phase = phaseWithId(ifs.start);
- tp.complete(this);
- // if (settings.debug.value && (validForRunId == currentRunId) System.out.println("completed " + this/* + ":" + info*/);//DEBUG
+ phase = phaseWithId(ifs.start)
+ tp.complete(this)
+ // if (settings.debug.value && validForRunId == currentRunId) System.out.println("completed " + this/* + ":" + info*/);//DEBUG
rawflags = rawflags & ~LOCKED
} finally {
phase = current
}
- cnt = cnt + 1;
+ cnt = cnt + 1
// allow for two completions:
// one: sourceCompleter to LazyType, two: LazyType to completed type
- if (cnt == 3) throw new Error("no progress in completing " + this + ":" + tp);
+ if (cnt == 3) throw new Error("no progress in completing " + this + ":" + tp)
}
rawInfo
}
/** Set initial info. */
def setInfo(info: Type): this.type = {
- assert(info != null);
- var pid = phase.id;
+ assert(info != null)
+ var pid = phase.id
if (pid == 0) {
// can happen when we initialize NoSymbol before running the compiler
- assert(name == nme.NOSYMBOL);
+ assert(name == nme.NOSYMBOL)
pid = 1
}
- infos = new TypeHistory(pid, info, null);
- limit = pid;
+ infos = new TypeHistory(pid, info, null)
+ limit = pid
if (info.isComplete) {
- rawflags = rawflags & ~LOCKED;
+ rawflags = rawflags & ~LOCKED
validForRunId = currentRunId
} else {
- rawflags = rawflags & ~LOCKED;
+ rawflags = rawflags & ~LOCKED
validForRunId = NoRunId
}
this
@@ -381,9 +381,9 @@ trait Symbols requires SymbolTable {
/** Set new info valid from start of this phase. */
final def updateInfo(info: Type): Symbol = {
- assert(infos.start <= phase.id);
- if (infos.start == phase.id) infos = infos.prev;
- infos = new TypeHistory(phase.id, info, infos);
+ assert(infos.start <= phase.id)
+ if (infos.start == phase.id) infos = infos.prev
+ infos = new TypeHistory(phase.id, info, infos)
this
}
@@ -391,40 +391,40 @@ trait Symbols requires SymbolTable {
final def rawInfo: Type = {
if (limit < phase.id) {
if (validForRunId == currentRunId) {
- val current = phase;
- var itr = infoTransformers.nextFrom(limit);
+ val current = phase
+ var itr = infoTransformers.nextFrom(limit)
infoTransformers = itr; // caching optimization
while (itr.pid != NoPhase.id && itr.pid < current.id) {
- phase = phaseWithId(itr.pid);
- val info1 = itr.transform(this, infos.info);
- limit = phase.id + 1;
+ phase = phaseWithId(itr.pid)
+ val info1 = itr.transform(this, infos.info)
+ limit = phase.id + 1
if (info1 ne infos.info) {
- infos = new TypeHistory(limit, info1, infos);
+ infos = new TypeHistory(limit, info1, infos)
}
itr = itr.nextFrom(limit)
}
- phase = current;
- limit = current.id;
+ phase = current
+ limit = current.id
}
- assert(infos != null, name);
+ assert(infos != null, name)
infos.info
} else {
- var infos = this.infos;
- while (phase.id < infos.start && infos.prev != null) infos = infos.prev;
+ var infos = this.infos
+ while (phase.id < infos.start && infos.prev != null) infos = infos.prev
infos.info
}
}
/** Initialize the symbol */
final def initialize: this.type = {
- if (!isInitialized) info;
+ if (!isInitialized) info
this
}
/** Was symbol's type updated during given phase? */
final def isUpdatedAt(pid: Phase#Id): boolean = {
- var infos = this.infos;
- while (infos != null && infos.start != pid + 1) infos = infos.prev;
+ var infos = this.infos
+ while (infos != null && infos.start != pid + 1) infos = infos.prev
infos != null
}
@@ -433,24 +433,24 @@ trait Symbols requires SymbolTable {
* excluding parameters.
* Not applicable for term symbols.
*/
- def typeConstructor: Type = throw new Error("typeConstructor inapplicable for " + this);
+ def typeConstructor: Type = throw new Error("typeConstructor inapplicable for " + this)
/** The type parameters of this symbol */
- def unsafeTypeParams: List[Symbol] = rawInfo.typeParams;
+ def unsafeTypeParams: List[Symbol] = rawInfo.typeParams
def typeParams: List[Symbol] = {
rawInfo.load(this); rawInfo.typeParams
}
def getAttributes(clazz: Symbol): List[AttrInfo] =
- attributes.filter(._1.symbol.isSubClass(clazz));
+ attributes.filter(._1.symbol.isSubClass(clazz))
/** Reset symbol to initial state
*/
def reset(completer: Type): unit = {
- resetFlags;
- infos = null;
- limit = NoPhase.id;
+ resetFlags
+ infos = null
+ limit = NoPhase.id
setInfo(completer)
}
@@ -463,13 +463,13 @@ trait Symbols requires SymbolTable {
final def isLess(that: Symbol): boolean = {
def closureLength(sym: Symbol) =
if (sym.isAbstractType) 1 + sym.info.bounds.hi.closure.length
- else sym.info.closure.length;
+ else sym.info.closure.length
if (this.isType)
(that.isType &&
- { val diff = closureLength(this) - closureLength(that);
+ { val diff = closureLength(this) - closureLength(that)
diff > 0 || diff == 0 && this.id < that.id })
else
- that.isType || this.id < that.id;
+ that.isType || this.id < that.id
}
/** A partial ordering between symbols.
@@ -477,7 +477,7 @@ trait Symbols requires SymbolTable {
* a class or method defining that symbol
*/
final def isNestedIn(that: Symbol): boolean =
- owner == that || owner != NoSymbol && (owner isNestedIn that);
+ owner == that || owner != NoSymbol && (owner isNestedIn that)
/** Is this class symbol a subclass of that symbol? */
final def isSubClass(that: Symbol): boolean = (
@@ -487,29 +487,29 @@ trait Symbols requires SymbolTable {
this == AllRefClass &&
(that == AnyClass ||
that != AllClass && (that isSubClass AnyRefClass))
- );
+ )
// Overloaded Alternatives ---------------------------------------------------------
def alternatives: List[Symbol] =
if (hasFlag(OVERLOADED)) info.asInstanceOf[OverloadedType].alternatives
- else List(this);
+ else List(this)
def filter(cond: Symbol => boolean): Symbol =
if (hasFlag(OVERLOADED)) {
//assert(info.isInstanceOf[OverloadedType], "" + this + ":" + info);//DEBUG
- val alts = alternatives;
- val alts1 = alts filter cond;
+ val alts = alternatives
+ val alts1 = alts filter cond
if (alts1 eq alts) this
else if (alts1.isEmpty) NoSymbol
else if (alts1.tail.isEmpty) alts1.head
else owner.newOverloaded(info.prefix, alts1)
} else if (cond(this)) this
- else NoSymbol;
+ else NoSymbol
def suchThat(cond: Symbol => boolean): Symbol = {
- val result = filter(cond);
- assert(!(result hasFlag OVERLOADED), result.alternatives);
+ val result = filter(cond)
+ assert(!(result hasFlag OVERLOADED), result.alternatives)
result
}
@@ -517,64 +517,64 @@ trait Symbols requires SymbolTable {
/** A clone of this symbol */
final def cloneSymbol: Symbol =
- cloneSymbol(owner);
+ cloneSymbol(owner)
/** A clone of this symbol, but with given owner */
final def cloneSymbol(owner: Symbol): Symbol =
- cloneSymbolImpl(owner).setInfo(info.cloneInfo(owner)).setFlag(this.rawflags);
+ cloneSymbolImpl(owner).setInfo(info.cloneInfo(owner)).setFlag(this.rawflags)
/** Internal method to clone a symbol's implementation without flags or type
*/
- def cloneSymbolImpl(owner: Symbol): Symbol;
+ def cloneSymbolImpl(owner: Symbol): Symbol
// Access to related symbols --------------------------------------------------
/** The next enclosing class */
- def enclClass: Symbol = if (isClass) this else owner.enclClass;
+ def enclClass: Symbol = if (isClass) this else owner.enclClass
/** The next enclosing method */
- def enclMethod: Symbol = if (isSourceMethod) this else owner.enclMethod;
+ def enclMethod: Symbol = if (isSourceMethod) this else owner.enclMethod
/** The primary constructor of a class */
def primaryConstructor: Symbol = {
- val c = info.decl(if (isTrait || isImplClass) nme.MIXIN_CONSTRUCTOR else nme.CONSTRUCTOR);
+ val c = info.decl(if (isTrait || isImplClass) nme.MIXIN_CONSTRUCTOR else nme.CONSTRUCTOR)
if (c hasFlag OVERLOADED) c.alternatives.head else c
}
/** The self symbol of a class with explicit self type, or else the symbol itself.
*/
- def thisSym: Symbol = this;
+ def thisSym: Symbol = this
/** The type of `this' in a class, or else the type of the symbol itself. */
- def typeOfThis = thisSym.tpe;
+ def typeOfThis = thisSym.tpe
/** Sets the type of `this' in a class */
- def typeOfThis_=(tp: Type): unit = throw new Error("typeOfThis cannot be set for " + this);
+ def typeOfThis_=(tp: Type): unit = throw new Error("typeOfThis cannot be set for " + this)
/** If symbol is a class, the type this.type in this class, otherwise NoPrefix */
- def thisType: Type = NoPrefix;
+ def thisType: Type = NoPrefix
/** Return every accessor of a primary constructor parameter in this case class
* todo: limit to accessors for first constructor parameter section.
*/
final def caseFieldAccessors: List[Symbol] =
- info.decls.toList filter (sym => !(sym hasFlag PRIVATE) && sym.hasFlag(CASEACCESSOR));
+ info.decls.toList filter (sym => !(sym hasFlag PRIVATE) && sym.hasFlag(CASEACCESSOR))
final def constrParamAccessors: List[Symbol] =
- info.decls.toList filter (sym => !sym.isMethod && sym.hasFlag(PARAMACCESSOR));
+ info.decls.toList filter (sym => !sym.isMethod && sym.hasFlag(PARAMACCESSOR))
/** The symbol accessed by this accessor function.
*/
final def accessed: Symbol = {
- assert(hasFlag(ACCESSOR));
+ assert(hasFlag(ACCESSOR))
owner.info.decl(nme.getterToLocal(if (isSetter) nme.setterToGetter(name) else name))
}
- final def implClass: Symbol = owner.info.decl(nme.implClassName(name));
+ final def implClass: Symbol = owner.info.decl(nme.implClassName(name))
/** For a paramaccessor: a superclass paramaccessor for which this symbol is
* an alias, NoSymbol for all others */
- def alias: Symbol = NoSymbol;
+ def alias: Symbol = NoSymbol
/** The class with the same name in the same package as this module or
* case class factory
@@ -582,7 +582,7 @@ trait Symbols requires SymbolTable {
final def linkedClass: Symbol = {
if (this != NoSymbol && owner.isPackageClass)
owner.info.decl(name.toTypeName).suchThat(sym => sym.rawInfo ne NoType)
- else NoSymbol;
+ else NoSymbol
}
/** The module or case class factory with the same name in the same
@@ -591,34 +591,34 @@ trait Symbols requires SymbolTable {
final def linkedModule: Symbol =
if (owner.isPackageClass)
owner.info.decl(name.toTermName).suchThat(
- sym => (sym hasFlag MODULE) && (sym.rawInfo ne NoType));
- else NoSymbol;
+ sym => (sym hasFlag MODULE) && (sym.rawInfo ne NoType))
+ else NoSymbol
/** The top-level class containing this symbol */
def toplevelClass: Symbol =
- if (isClass && owner.isPackageClass) this else owner.toplevelClass;
+ if (isClass && owner.isPackageClass) this else owner.toplevelClass
/** For a module its linked class, for a class its linked module or case factory otherwise */
final def linkedSym: Symbol =
if (isTerm) linkedClass
else if (isClass && owner.isPackageClass)
owner.info.decl(name.toTermName).suchThat(sym => sym.rawInfo ne NoType)
- else NoSymbol;
+ else NoSymbol
final def toInterface: Symbol =
if (isImplClass) {
- assert(!tpe.parents.isEmpty, this);
+ assert(!tpe.parents.isEmpty, this)
tpe.parents.last.symbol
- } else this;
+ } else this
/** The module corresponding to this module class (note that this
* is not updated when a module is cloned).
*/
- def sourceModule: Symbol = NoSymbol;
+ def sourceModule: Symbol = NoSymbol
/** The module class corresponding to this module.
*/
- def moduleClass: Symbol = NoSymbol;
+ def moduleClass: Symbol = NoSymbol
/** The non-abstract, symbol whose type matches the type of this symbol in in given class
* @param ofclazz The class containing the symbol's definition
@@ -626,34 +626,34 @@ trait Symbols requires SymbolTable {
*/
final def matchingSymbol(ofclazz: Symbol, site: Type): Symbol =
ofclazz.info.nonPrivateDecl(name).filter(sym =>
- !sym.isTerm || (site.memberType(this) matches site.memberType(sym)));
+ !sym.isTerm || (site.memberType(this) matches site.memberType(sym)))
/** The symbol overridden by this symbol in given class `ofclazz' */
final def overriddenSymbol(ofclazz: Symbol): Symbol =
- matchingSymbol(ofclazz, owner.thisType);
+ matchingSymbol(ofclazz, owner.thisType)
/** The symbol overriding this symbol in given subclass `ofclazz' */
final def overridingSymbol(ofclazz: Symbol): Symbol =
- matchingSymbol(ofclazz, ofclazz.thisType);
+ matchingSymbol(ofclazz, ofclazz.thisType)
final def allOverriddenSymbols: List[Symbol] =
if (owner.isClass)
- for (val bc <- owner.info.baseClasses;
- val s = overriddenSymbol(bc);
- s != NoSymbol) yield s
- else List();
+ for { val bc <- owner.info.baseClasses
+ val s = overriddenSymbol(bc)
+ s != NoSymbol } yield s
+ else List()
/** The symbol accessed by a super in the definition of this symbol when seen from
* class `base'. This symbol is always concrete.
* pre: `this.owner' is in the base class sequence of `base'.
*/
final def superSymbol(base: Symbol): Symbol = {
- var bcs = base.info.baseClasses.dropWhile(owner !=).tail;
- var sym: Symbol = NoSymbol;
+ var bcs = base.info.baseClasses.dropWhile(owner !=).tail
+ var sym: Symbol = NoSymbol
while (!bcs.isEmpty && sym == NoSymbol) {
if (!bcs.head.isImplClass)
sym = matchingSymbol(bcs.head, base.thisType).suchThat(
- sym => !sym.hasFlag(DEFERRED));
+ sym => !sym.hasFlag(DEFERRED))
bcs = bcs.tail
}
sym
@@ -661,22 +661,22 @@ trait Symbols requires SymbolTable {
/** The getter of this value definition in class `base', or NoSymbol if none exists */
final def getter(base: Symbol): Symbol =
- base.info.decl(nme.getterName(name)) filter (.hasFlag(ACCESSOR));
+ base.info.decl(nme.getterName(name)) filter (.hasFlag(ACCESSOR))
/** The setter of this value definition, or NoSymbol if none exists */
final def setter(base: Symbol): Symbol =
- base.info.decl(nme.getterToSetter(nme.getterName(name))) filter (.hasFlag(ACCESSOR));
+ base.info.decl(nme.getterToSetter(nme.getterName(name))) filter (.hasFlag(ACCESSOR))
/** If this symbol is a skolem, its corresponding type parameter, otherwise this */
- def deSkolemize: Symbol = this;
+ def deSkolemize: Symbol = this
/** Remove private modifier from symbol `sym's definition. If `sym' is a
* term symbol rename it by expanding its name to avoid name clashes
*/
final def makeNotPrivate(base: Symbol): unit =
if (isTerm && (this hasFlag PRIVATE)) {
- setFlag(notPRIVATE);
- if (!hasFlag(DEFERRED)) setFlag(lateFINAL);
+ setFlag(notPRIVATE)
+ if (!hasFlag(DEFERRED)) setFlag(lateFINAL)
expandName(base)
}
@@ -685,12 +685,12 @@ trait Symbols requires SymbolTable {
*/
def expandName(base: Symbol): unit =
if (this != NoSymbol && !hasFlag(EXPANDEDNAME)) {
- setFlag(EXPANDEDNAME);
+ setFlag(EXPANDEDNAME)
if (hasFlag(ACCESSOR)) {
- accessed.expandName(base);
+ accessed.expandName(base)
} else if (hasGetter) {
- getter(owner).expandName(base);
- setter(owner).expandName(base);
+ getter(owner).expandName(base)
+ setter(owner).expandName(base)
}
name = base.expandedName(name)
}
@@ -699,7 +699,7 @@ trait Symbols requires SymbolTable {
newTermName(fullNameString('$') + nme.EXPAND_SEPARATOR_STRING + name)
def sourceFile: AbstractFile =
- (if (isModule) moduleClass else toplevelClass).sourceFile;
+ (if (isModule) moduleClass else toplevelClass).sourceFile
def sourceFile_=(f: AbstractFile): unit =
throw new Error("sourceFile_= inapplicable for "+this)
@@ -707,10 +707,10 @@ trait Symbols requires SymbolTable {
// ToString -------------------------------------------------------------------
/** A tag which (in the ideal case) uniquely identifies class symbols */
- final def tag: int = fullNameString.hashCode();
+ final def tag: int = fullNameString.hashCode()
/** The simple name of this Symbol (this is always a term name) */
- final def simpleName: Name = name;
+ final def simpleName: Name = name
/** String representation of symbol's definition key word */
final def keyString: String =
@@ -723,7 +723,7 @@ trait Symbols requires SymbolTable {
else if (isModule) "object"
else if (isMethod) "def"
else if (isTerm && (!hasFlag(PARAM) || hasFlag(PARAMACCESSOR))) "val"
- else "";
+ else ""
/** String representation of symbol's kind */
final def kindString: String =
@@ -741,7 +741,7 @@ trait Symbols requires SymbolTable {
else if (isClassConstructor) "constructor"
else if (isSourceMethod) "method"
else if (isTerm) "value"
- else "";
+ else ""
/** String representation of symbol's simple name.
* If !settings.debug translates expansions of operators back to operator symbol.
@@ -749,7 +749,7 @@ trait Symbols requires SymbolTable {
* If settings.uniquId adds id.
*/
def nameString: String =
- simpleName.decode + idString;
+ simpleName.decode + idString
/** String representation of symbol's full name with `separator'
* between class names.
@@ -760,29 +760,29 @@ trait Symbols requires SymbolTable {
assert(owner != NoSymbol, this)
var str =
if (owner.isRoot || owner.isEmptyPackageClass) simpleName.toString()
- else owner.fullNameString(separator) + separator + simpleName;
+ else owner.fullNameString(separator) + separator + simpleName
if (str.charAt(str.length - 1) == ' ') str = str.substring(0, str.length - 1)
str
}
- final def fullNameString: String = fullNameString('.');
+ final def fullNameString: String = fullNameString('.')
/** If settings.uniqid is set, the symbol's id, else "" */
final def idString: String =
- if (settings.uniqid.value) "#" + id else "";
+ if (settings.uniqid.value) "#" + id else ""
/** String representation, including symbol's kind
* e.g., "class Foo", "method Bar".
*/
override def toString(): String =
- compose(List(kindString, if (isClassConstructor) owner.nameString else nameString));
+ compose(List(kindString, if (isClassConstructor) owner.nameString else nameString))
/** String representation of location. */
final def locationString: String =
if (owner.isClass &&
(!owner.isAnonymousClass && !owner.isRefinementClass || settings.debug.value))
" in " + (if (owner.isModuleClass) "object " + owner.nameString else owner)
- else "";
+ else ""
/** String representation of symbol's definition following its name */
final def infoString(tp: Type): String = {
@@ -802,7 +802,7 @@ trait Symbols requires SymbolTable {
((if (lo.symbol == AllClass) "" else " >: " + lo) +
(if (hi.symbol == AnyClass) "" else " <: " + hi))
case _ =>
- "<: " + tp;
+ "<: " + tp
}
else if (isModule)
moduleClass.infoString(tp)
@@ -817,57 +817,57 @@ trait Symbols requires SymbolTable {
}
}
- def infosString = infos.toString();
+ def infosString = infos.toString()
/** String representation of symbol's variance */
private def varianceString: String =
if (variance == 1) "+"
else if (variance == -1) "-"
- else "";
+ else ""
/** String representation of symbol's definition */
final def defString: String =
compose(List(flagsToString(if (settings.debug.value) flags else flags & ExplicitFlags),
keyString,
- varianceString + nameString + infoString(rawInfo)));
+ varianceString + nameString + infoString(rawInfo)))
/** Concatenate strings separated by spaces */
private def compose(ss: List[String]): String =
- ss.filter("" !=).mkString("", " ", "");
+ ss.filter("" !=).mkString("", " ", "")
}
/** A class for term symbols */
class TermSymbol(initOwner: Symbol, initPos: int, initName: Name) extends Symbol(initOwner, initPos, initName) {
- override def isTerm = true;
+ override def isTerm = true
- privateWithin = NoSymbol;
+ privateWithin = NoSymbol
- protected var referenced: Symbol = NoSymbol;
+ protected var referenced: Symbol = NoSymbol
def cloneSymbolImpl(owner: Symbol): Symbol = {
- val clone = new TermSymbol(owner, pos, name);
- clone.referenced = referenced;
+ val clone = new TermSymbol(owner, pos, name)
+ clone.referenced = referenced
clone
}
override def alias: Symbol =
- if (hasFlag(SUPERACCESSOR | PARAMACCESSOR | MIXEDIN)) initialize.referenced else NoSymbol;
+ if (hasFlag(SUPERACCESSOR | PARAMACCESSOR | MIXEDIN)) initialize.referenced else NoSymbol
def setAlias(alias: Symbol): TermSymbol = {
- assert(alias != NoSymbol, this);
+ assert(alias != NoSymbol, this)
assert(!(alias hasFlag OVERLOADED), alias)
- assert(hasFlag(SUPERACCESSOR | PARAMACCESSOR | MIXEDIN), this);
- referenced = alias;
+ assert(hasFlag(SUPERACCESSOR | PARAMACCESSOR | MIXEDIN), this)
+ referenced = alias
this
}
override def moduleClass: Symbol =
- if (hasFlag(MODULE)) referenced else NoSymbol;
+ if (hasFlag(MODULE)) referenced else NoSymbol
def setModuleClass(clazz: Symbol): TermSymbol = {
- assert(hasFlag(MODULE));
- referenced = clazz;
+ assert(hasFlag(MODULE))
+ referenced = clazz
this
}
}
@@ -875,59 +875,59 @@ trait Symbols requires SymbolTable {
/** A class for module symbols */
class ModuleSymbol(initOwner: Symbol, initPos: int, initName: Name) extends TermSymbol(initOwner, initPos, initName) {
- private var flatname = nme.EMPTY;
+ private var flatname = nme.EMPTY
override def owner: Symbol =
if (phase.flatClasses && !hasFlag(METHOD) &&
rawowner != NoSymbol && !rawowner.isPackageClass) rawowner.owner
- else rawowner;
+ else rawowner
override def name: Name =
if (phase.flatClasses && !hasFlag(METHOD) &&
rawowner != NoSymbol && !rawowner.isPackageClass) {
if (flatname == nme.EMPTY) {
- assert(rawowner.isClass);
- flatname = newTermName(rawowner.name.toString() + "$" + rawname);
+ assert(rawowner.isClass)
+ flatname = newTermName(rawowner.name.toString() + "$" + rawname)
}
flatname
- } else rawname;
+ } else rawname
override def cloneSymbolImpl(owner: Symbol): Symbol = {
- val clone = new ModuleSymbol(owner, pos, name);
- clone.referenced = referenced;
+ val clone = new ModuleSymbol(owner, pos, name)
+ clone.referenced = referenced
clone
}
}
/** A class for type parameters viewed from inside their scopes */
class ThisSkolem(initOwner: Symbol, initPos: int, initName: Name, clazz: Symbol) extends TermSymbol(initOwner, initPos, initName) {
- override def deSkolemize = clazz;
+ override def deSkolemize = clazz
override def cloneSymbolImpl(owner: Symbol): Symbol = {
- throw new Error("should not clone a this skolem");
+ throw new Error("should not clone a this skolem")
}
- override def nameString: String = clazz.name.toString() + ".this";
+ override def nameString: String = clazz.name.toString() + ".this"
}
/** A class of type symbols. Alias and abstract types are direct instances
* of this class. Classes are instances of a subclass.
*/
class TypeSymbol(initOwner: Symbol, initPos: int, initName: Name) extends Symbol(initOwner, initPos, initName) {
- override def isType = true;
- privateWithin = NoSymbol;
- private var tyconCache: Type = null;
- private var tyconRun: RunId = null;
- private var tpeCache: Type = _;
- private var tpePhase: Phase = null;
+ override def isType = true
+ privateWithin = NoSymbol
+ private var tyconCache: Type = null
+ private var tyconRunId = NoRunId
+ private var tpeCache: Type = _
+ private var tpePeriod = NoPeriod
override def tpe: Type = {
- if (tpeCache eq NoType) throw CyclicReference(this, typeConstructor);
- if (tpePhase != phase) {
- if (isValid(tpePhase)) {
- tpePhase = phase
+ if (tpeCache eq NoType) throw CyclicReference(this, typeConstructor)
+ if (tpePeriod != currentPeriod) {
+ if (isValid(tpePeriod)) {
+ tpePeriod = currentPeriod
} else {
- if (isInitialized) tpePhase = phase;
- tpeCache = NoType;
+ if (isInitialized) tpePeriod = currentPeriod
+ tpeCache = NoType
val targs = if (phase.erasedTypes && this != ArrayClass) List()
- else unsafeTypeParams map (.tpe);
+ else unsafeTypeParams map (.tpe)
tpeCache = typeRef(if (isTypeParameterOrSkolem) NoPrefix else owner.thisType, this, targs)
}
}
@@ -936,98 +936,98 @@ trait Symbols requires SymbolTable {
}
override def typeConstructor: Type = {
- if (tyconCache == null || tyconRun != currentRunId) {
- tyconCache = typeRef(if (isTypeParameter) NoPrefix else owner.thisType, this, List());
- tyconRun = currentRunId;
+ if (tyconCache == null || tyconRunId != currentRunId) {
+ tyconCache = typeRef(if (isTypeParameter) NoPrefix else owner.thisType, this, List())
+ tyconRunId = currentRunId
}
- assert(tyconCache != null);
+ assert(tyconCache != null)
tyconCache
}
override def setInfo(tp: Type): this.type = {
- tpePhase = null;
- tyconCache = null;
+ tpePeriod = NoPeriod
+ tyconCache = null
tp match { //debug
case TypeRef(_, sym, _) =>
- assert(sym != this, this);
+ assert(sym != this, this)
case ClassInfoType(parents, _, _) =>
for(val p <- parents) assert(p.symbol != this, owner)
case _ =>
}
- super.setInfo(tp);
+ super.setInfo(tp)
this
}
override def reset(completer: Type): unit = {
- super.reset(completer);
- tpePhase = null;
- tyconCache = null;
+ super.reset(completer)
+ tpePeriod = NoPeriod
+ tyconRunId = NoRunId
}
def cloneSymbolImpl(owner: Symbol): Symbol =
- new TypeSymbol(owner, pos, name);
+ new TypeSymbol(owner, pos, name)
- if (util.Statistics.enabled) typeSymbolCount = typeSymbolCount + 1;
+ if (util.Statistics.enabled) typeSymbolCount = typeSymbolCount + 1
}
/** A class for type parameters viewed from inside their scopes */
class TypeSkolem(initOwner: Symbol, initPos: int, initName: Name, typeParam: Symbol) extends TypeSymbol(initOwner, initPos, initName) {
- override def deSkolemize = typeParam;
+ override def deSkolemize = typeParam
override def cloneSymbolImpl(owner: Symbol): Symbol = {
- throw new Error("should not clone a type skolem");
+ throw new Error("should not clone a type skolem")
}
override def nameString: String =
if (settings.debug.value) (super.nameString + "&")
- else super.nameString;
+ else super.nameString
}
/** A class for class symbols */
class ClassSymbol(initOwner: Symbol, initPos: int, initName: Name) extends TypeSymbol(initOwner, initPos, initName) {
- private var source: AbstractFile = null;
- override def sourceFile = if (owner.isPackageClass) source else super.sourceFile;
+ private var source: AbstractFile = null
+ override def sourceFile = if (owner.isPackageClass) source else super.sourceFile
override def sourceFile_=(f: AbstractFile): unit = {
//System.err.println("set source file of " + this + ": " + f);
source = f
}
- private var thissym: Symbol = this;
- override def isClass: boolean = true;
+ private var thissym: Symbol = this
+ override def isClass: boolean = true
override def reset(completer: Type): unit = {
- super.reset(completer);
- thissym = this;
+ super.reset(completer)
+ thissym = this
}
- private var flatname = nme.EMPTY;
+ private var flatname = nme.EMPTY
override def owner: Symbol =
if (phase.flatClasses && rawowner != NoSymbol && !rawowner.isPackageClass) rawowner.owner
- else rawowner;
+ else rawowner
override def name: Name =
if (phase.flatClasses && rawowner != NoSymbol && !rawowner.isPackageClass) {
if (flatname == nme.EMPTY) {
- assert(rawowner.isClass);
- flatname = newTypeName(rawowner.name.toString() + "$" + rawname);
+ assert(rawowner.isClass)
+ flatname = newTypeName(rawowner.name.toString() + "$" + rawname)
}
flatname
- } else rawname;
+ } else rawname
- private var thisTypeCache: Type = _;
- private var thisTypePhase: Phase = null;
+ private var thisTypeCache: Type = _
+ private var thisTypePeriod = NoPeriod
/** the type this.type in this class */
override def thisType: Type = {
- val p = thisTypePhase;
- if (p != phase) {
- thisTypePhase = phase;
- if (!isValid(p)) thisTypeCache = ThisType(this)
+ val period = thisTypePeriod
+ if (period != currentPeriod) {
+ thisTypePeriod = currentPeriod
+ if (!isValid(period)) thisTypeCache = ThisType(this)
}
thisTypeCache
}
/** A symbol carrying the self type of the class as its type */
- override def thisSym: Symbol = thissym;
+ override def thisSym: Symbol = thissym
override def typeOfThis: Type =
if (getFlag(MODULE | IMPLCLASS) == MODULE && owner != NoSymbol)
@@ -1036,70 +1036,70 @@ trait Symbols requires SymbolTable {
/** Sets the self type of the class */
override def typeOfThis_=(tp: Type): unit =
- thissym = newThisSym(pos).setInfo(tp);
+ thissym = newThisSym(pos).setInfo(tp)
override def cloneSymbolImpl(owner: Symbol): Symbol = {
- assert(!isModuleClass);
- val clone = new ClassSymbol(owner, pos, name);
- if (thisSym != this) clone.typeOfThis = typeOfThis;
+ assert(!isModuleClass)
+ val clone = new ClassSymbol(owner, pos, name)
+ if (thisSym != this) clone.typeOfThis = typeOfThis
clone
}
- override def sourceModule = if (isModuleClass) linkedModule else NoSymbol;
+ override def sourceModule = if (isModuleClass) linkedModule else NoSymbol
- if (util.Statistics.enabled) classSymbolCount = classSymbolCount + 1;
+ if (util.Statistics.enabled) classSymbolCount = classSymbolCount + 1
}
/** A class for module class symbols
* Note: Not all module classes are of this type; when unpickled, we get plain class symbols!
*/
class ModuleClassSymbol(owner: Symbol, pos: int, name: Name) extends ClassSymbol(owner, pos, name) {
- private var module: Symbol = null;
+ private var module: Symbol = null
def this(module: TermSymbol) = {
- this(module.owner, module.pos, module.name.toTypeName);
- setFlag(module.getFlag(ModuleToClassFlags) | MODULE | FINAL);
- setSourceModule(module);
+ this(module.owner, module.pos, module.name.toTypeName)
+ setFlag(module.getFlag(ModuleToClassFlags) | MODULE | FINAL)
+ setSourceModule(module)
}
- override def sourceModule = module;
+ override def sourceModule = module
def setSourceModule(module: Symbol): unit = this.module = module
}
/** An object repreesenting a missing symbol */
object NoSymbol extends Symbol(null, Position.NOPOS, nme.NOSYMBOL) {
- setInfo(NoType);
- privateWithin = this;
+ setInfo(NoType)
+ privateWithin = this
override def setInfo(info: Type): this.type = { assert(info eq NoType); super.setInfo(info) }
- override def enclClass: Symbol = this;
- override def toplevelClass: Symbol = this;
- override def enclMethod: Symbol = this;
- override def owner: Symbol = throw new Error();
- override def sourceFile: AbstractFile = null;
- override def ownerChain: List[Symbol] = List();
- override def alternatives: List[Symbol] = List();
+ override def enclClass: Symbol = this
+ override def toplevelClass: Symbol = this
+ override def enclMethod: Symbol = this
+ override def owner: Symbol = throw new Error()
+ override def sourceFile: AbstractFile = null
+ override def ownerChain: List[Symbol] = List()
+ override def alternatives: List[Symbol] = List()
override def reset(completer: Type): unit = {}
- def cloneSymbolImpl(owner: Symbol): Symbol = throw new Error();
+ def cloneSymbolImpl(owner: Symbol): Symbol = throw new Error()
}
def cloneSymbols(syms: List[Symbol]): List[Symbol] = {
- val syms1 = syms map (.cloneSymbol);
- for (val sym1 <- syms1) sym1.setInfo(sym1.info.substSym(syms, syms1));
+ val syms1 = syms map (.cloneSymbol)
+ for (val sym1 <- syms1) sym1.setInfo(sym1.info.substSym(syms, syms1))
syms1
}
def cloneSymbols(syms: List[Symbol], owner: Symbol): List[Symbol] = {
- val syms1 = syms map (.cloneSymbol(owner));
- for (val sym1 <- syms1) sym1.setInfo(sym1.info.substSym(syms, syms1));
+ val syms1 = syms map (.cloneSymbol(owner))
+ for (val sym1 <- syms1) sym1.setInfo(sym1.info.substSym(syms, syms1))
syms1
}
/** An exception for cyclic references of symbol definitions */
- case class CyclicReference(sym: Symbol, info: Type) extends TypeError("illegal cyclic reference involving " + sym);
+ 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#Id, info: Type, prev: TypeHistory) {
- assert(prev == null || start > prev.start, this);
- assert(start != 0);
- override def toString() = "TypeHistory(" + phaseWithId(start) + "," + info + "," + prev + ")";
+ assert(prev == null || start > prev.start, this)
+ assert(start != 0)
+ override def toString() = "TypeHistory(" + phaseWithId(start) + "," + info + "," + prev + ")"
}
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index da6c41a754..f5f6fdc8f3 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -549,12 +549,12 @@ trait Types requires SymbolTable {
// override def isNullable = supertype.isNullable
// override def isNonNull = supertype.isNonNull
private var singleDerefCache: Type = _
- private var singleDerefPhase: Phase = null
+ private var singleDerefPeriod = NoPeriod
override def singleDeref: Type = {
- val p = singleDerefPhase
- if (p != phase) {
- singleDerefPhase = phase;
- if (!isValid(p)) {
+ val period = singleDerefPeriod
+ if (period != currentPeriod) {
+ singleDerefPeriod = currentPeriod
+ if (!isValid(period)) {
singleDerefCache = pre.memberType(sym).resultType;
}
}
@@ -609,9 +609,9 @@ trait Types requires SymbolTable {
abstract class CompoundType extends Type {
private var closureCache: Array[Type] = _
- private var closurePhase: Phase = null
+ private var closurePeriod = NoPeriod
private var baseClassesCache: List[Symbol] = _
- private var baseClassesPhase: Phase = null
+ private var baseClassesPeriod = NoPeriod
override def closure: Array[Type] = {
def computeClosure: Array[Type] =
@@ -679,10 +679,10 @@ trait Types requires SymbolTable {
"the type intersection " + this + " is malformed" +
"\n --- because ---\n" + ex.getMessage())
}
- val p = closurePhase;
- if (p != phase) {
- closurePhase = phase;
- if (!isValidForBaseClasses(p)) {
+ val period = closurePeriod;
+ if (period != currentPeriod) {
+ closurePeriod = currentPeriod;
+ if (!isValidForBaseClasses(period)) {
closureCache = null;
closureCache = computeClosure
}
@@ -720,10 +720,10 @@ trait Types requires SymbolTable {
}
symbol :: bcs
}
- val p = baseClassesPhase;
- if (p != phase) {
- baseClassesPhase = phase;
- if (!isValidForBaseClasses(p)) {
+ val period = baseClassesPeriod;
+ if (period != currentPeriod) {
+ baseClassesPeriod = currentPeriod;
+ if (!isValidForBaseClasses(period)) {
baseClassesCache = null;
baseClassesCache = computeBaseClasses;
}
@@ -797,9 +797,9 @@ trait Types requires SymbolTable {
assert(!sym.isTypeParameterOrSkolem || pre == NoPrefix, this);
private var parentsCache: List[Type] = _
- private var parentsPhase: Phase = null
+ private var parentsPeriod = NoPeriod
private var closureCache: Array[Type] = _
- private var closurePhase: Phase = null
+ private var closurePeriod = NoPeriod
override val isTrivial: boolean =
pre.isTrivial && !sym.isTypeParameter && args.forall(.isTrivial)
@@ -821,10 +821,10 @@ trait Types requires SymbolTable {
else super.bounds;
override def parents: List[Type] = {
- val p = parentsPhase;
- if (p != phase) {
- parentsPhase = phase;
- if (!isValidForBaseClasses(p)) {
+ val period = parentsPeriod;
+ if (period != currentPeriod) {
+ parentsPeriod = currentPeriod;
+ if (!isValidForBaseClasses(period)) {
parentsCache = sym.info.parents map transform
}
}
@@ -857,10 +857,10 @@ trait Types requires SymbolTable {
else pre.memberInfo(sym).baseType(clazz);
override def closure: Array[Type] = {
- val p = closurePhase;
- if (p != phase) {
- closurePhase = phase;
- if (!isValidForBaseClasses(p)) {
+ val period = closurePeriod;
+ if (period != currentPeriod) {
+ closurePeriod = currentPeriod;
+ if (!isValidForBaseClasses(period)) {
if (util.Statistics.enabled) typerefClosureCount = typerefClosureCount + 1;
closureCache =
if (sym.isAbstractType) addClosure(this, transform(bounds.hi).closure)
@@ -1492,20 +1492,22 @@ trait Types requires SymbolTable {
// Helper Methods -------------------------------------------------------------
- final def isValid(p: Phase): boolean =
- 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 isValid(period: Period): boolean =
+ period != 0 && runId(period) == currentRunId && {
+ val pid = phaseId(period)
+ if (phase.id > pid) infoTransformers.nextFrom(pid).pid >= phase.id
+ else infoTransformers.nextFrom(phase.id).pid >= pid
}
- final def isValidForBaseClasses(p: Phase): boolean = {
+ final def isValidForBaseClasses(period: Period): boolean = {
def noChangeInBaseClasses(it: InfoTransformer, limit: Phase#Id): boolean = (
it.pid >= limit ||
!it.changesBaseClasses && noChangeInBaseClasses(it.next, limit)
);
- 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)
+ period != 0 && runId(period) == currentRunId && {
+ val pid = phaseId(period)
+ if (phase.id > pid) noChangeInBaseClasses(infoTransformers.nextFrom(pid), phase.id)
+ else noChangeInBaseClasses(infoTransformers.nextFrom(phase.id), pid)
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index a6ac327971..64a0c72416 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -5,7 +5,6 @@
// $Id$
package scala.tools.nsc.typechecker;
-import symtab.RunId
import symtab.Flags._
import scala.tools.nsc.util.Position
@@ -278,7 +277,7 @@ trait Contexts requires Analyzer {
}
private var implicitsCache: List[List[ImplicitInfo]] = null
- private var implicitsRunId: RunId = NoRunId
+ private var implicitsRunId = NoRunId
private def collectImplicits(syms: List[Symbol], pre: Type): List[ImplicitInfo] =
for (val sym <- syms; sym.hasFlag(IMPLICIT) && isAccessible(sym, pre, false))