summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2005-09-01 12:52:14 +0000
committerMartin Odersky <odersky@gmail.com>2005-09-01 12:52:14 +0000
commit611894900ffdc31b1938777178fc43335150a45f (patch)
treeba45d43065175b81f6d7c0057681d13921c01032
parentae5a9701ae8e5db9ba02fb6c95f72ce059e78b53 (diff)
downloadscala-611894900ffdc31b1938777178fc43335150a45f.tar.gz
scala-611894900ffdc31b1938777178fc43335150a45f.tar.bz2
scala-611894900ffdc31b1938777178fc43335150a45f.zip
*** empty log message ***
-rw-r--r--sources/scala/Iterator.scala1
-rw-r--r--sources/scala/List.scala6
-rw-r--r--sources/scala/collection/immutable/Queue.scala2
-rw-r--r--sources/scala/concurrent/pilib.scala4
-rwxr-xr-xsources/scala/tools/nsc/Global.scala8
-rwxr-xr-xsources/scala/tools/nsc/symtab/Names.scala24
-rwxr-xr-xsources/scala/tools/nsc/symtab/Symbols.scala90
-rwxr-xr-xsources/scala/tools/nsc/symtab/classfile/Pickler.scala15
-rwxr-xr-xsources/scala/tools/nsc/symtab/classfile/UnPickler.scala19
-rwxr-xr-xsources/scala/tools/nsc/transform/AddInterfaces.scala2
-rwxr-xr-xsources/scala/tools/nsc/transform/Flatten.scala7
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Infer.scala7
-rwxr-xr-xsources/scala/tools/nsc/typechecker/RefChecks.scala37
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Typers.scala39
-rw-r--r--sources/scala/util/automata/Inclusion.scala1
-rw-r--r--sources/scala/xml/dtd/ElementValidator.scala2
-rw-r--r--sources/scala/xml/parsing/ExternalSources.scala2
-rw-r--r--sources/scala/xml/parsing/MarkupParser.scala2
18 files changed, 163 insertions, 105 deletions
diff --git a/sources/scala/Iterator.scala b/sources/scala/Iterator.scala
index 205ca354e9..3f907c857e 100644
--- a/sources/scala/Iterator.scala
+++ b/sources/scala/Iterator.scala
@@ -53,7 +53,6 @@ object Iterator {
private val cmax = n.caseArity;
def hasNext = c < cmax;
def next = { val a = n caseElement c; c = c + 1; a }
-
}
/** Create an iterator with elements
diff --git a/sources/scala/List.scala b/sources/scala/List.scala
index 5128d93c30..66442b42b2 100644
--- a/sources/scala/List.scala
+++ b/sources/scala/List.scala
@@ -422,20 +422,18 @@ sealed trait List[+a] extends Seq[a] { // todo make sealed once we figure out ho
*
* @param n the number of elements to take.
* @return the <code>n</code> first elements of this list.
- * @throws <code>java.lang.RuntimeException</code> if the list is too short.
*/
override def take(n: Int): List[a] =
- if (n == 0) Nil
+ if (n == 0 || isEmpty) Nil
else head :: (tail take (n-1));
/** Returns the list without its <code>n</code> first elements.
*
* @param n the number of elements to drop.
* @return the list without its <code>n</code> first elements.
- * @throws <code>java.lang.RuntimeException</code> if the list is too short.
*/
override def drop(n: Int): List[a] =
- if (n == 0) this
+ if (n == 0 || isEmpty) this
else (tail drop (n-1));
/** Returns the rightmost <code>n</code> elements from this list.
diff --git a/sources/scala/collection/immutable/Queue.scala b/sources/scala/collection/immutable/Queue.scala
index 4621b129d7..74b9a45cd2 100644
--- a/sources/scala/collection/immutable/Queue.scala
+++ b/sources/scala/collection/immutable/Queue.scala
@@ -170,6 +170,4 @@ class Queue[+A](elem: A*) extends Seq[A] {
val q: Pair[A,Queue[A]] = dequeue;
q._1.hashCode() + q._2.hashCode();
}
-
}
-
diff --git a/sources/scala/concurrent/pilib.scala b/sources/scala/concurrent/pilib.scala
index 9fb9d3a6ef..9ecc231690 100644
--- a/sources/scala/concurrent/pilib.scala
+++ b/sources/scala/concurrent/pilib.scala
@@ -66,6 +66,8 @@ object pilib {
*/
class Chan[a] extends UChan with Function1[a, Product[a]] {
+ var defaultValue: a = _;
+
/** Creates an input guarded process. */
def input[b](c: a => b) =
new GP(this, true, (), x => c(x.asInstanceOf[a]));
@@ -76,7 +78,7 @@ object pilib {
/** Blocking read. */
def read = {
- var res: a = _;
+ var res: a = defaultValue;
choice ( input(x => res = x) );
res
}
diff --git a/sources/scala/tools/nsc/Global.scala b/sources/scala/tools/nsc/Global.scala
index 90cbe876af..55c265d29f 100755
--- a/sources/scala/tools/nsc/Global.scala
+++ b/sources/scala/tools/nsc/Global.scala
@@ -60,9 +60,6 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
/** A map from symbols to their attributes */
val attributes = new HashMap[Symbol, List[AttrInfo]];
- /** A map from parameter accessor symbols to their aliases */
- val aliases = new HashMap[Symbol, Symbol];
-
// reporting -------------------------------------------------------
def error(msg: String) = reporter.error(null, msg);
@@ -205,6 +202,10 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
val global: Global.this.type = Global.this;
}
+ object constructors extends Constructors {
+ val global: Global.this.type = Global.this;
+ }
+
object sampleTransform extends SampleTransform {
val global: Global.this.type = Global.this;
}
@@ -230,6 +231,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
erasure,
lambdaLift,
flatten,
+ constructors,
if (settings.Xshowicode.value) genicode
else sampleTransform);
diff --git a/sources/scala/tools/nsc/symtab/Names.scala b/sources/scala/tools/nsc/symtab/Names.scala
index 180c23a1d9..d123fd2a31 100755
--- a/sources/scala/tools/nsc/symtab/Names.scala
+++ b/sources/scala/tools/nsc/symtab/Names.scala
@@ -170,19 +170,35 @@ class Names {
*/
final def apply(i: int): char = chrs(index + i);
- /** return the index of first occurrence of char c in this name, length if not found
- */
+ /** return the index of first occurrence of char c in this name, length if not found */
final def pos(c: char): int = pos(c, 0);
+ /** return the index of first occurrence of char c in this name, length if not found */
+ final def pos(s: String): int = pos(s, 0);
+
/** return the index of first occurrence of char c in this name from `start',
- * length if not found
- */
+ * length if not found */
final def pos(c: char, start: int): int = {
var i = start;
while (i < len && chrs(index + i) != c) i = i + 1;
i
}
+ /** return the index of first occurrence of nonempty string s in this name from `start',
+ * length if not found */
+ final def pos(s: String, start: int): int = {
+ var i = pos(s.charAt(0), start);
+ while (i + s.length() <= len) {
+ var j = 1;
+ while (s.charAt(j) == chrs(index + i + j)) {
+ j = j + 1;
+ if (j == s.length()) return i;
+ }
+ i = pos(s.charAt(0), i + 1)
+ }
+ len
+ }
+
/** return the index of last occurrence of char c in this name, -1 if not found.
*/
final def lastPos(c: char): int = lastPos(c, len - 1);
diff --git a/sources/scala/tools/nsc/symtab/Symbols.scala b/sources/scala/tools/nsc/symtab/Symbols.scala
index ea62d09721..c45646cb26 100755
--- a/sources/scala/tools/nsc/symtab/Symbols.scala
+++ b/sources/scala/tools/nsc/symtab/Symbols.scala
@@ -43,13 +43,14 @@ abstract class Symbols: SymbolTable {
final def newConstructor(pos: int) =
newMethod(pos, nme.CONSTRUCTOR);
final def newModule(pos: int, name: Name, clazz: ClassSymbol) =
- new ModuleSymbol(this, pos, name, clazz);
- final def newModule(pos: int, name: Name) =
- new ModuleSymbol(this, pos, name, null);
+ new TermSymbol(this, pos, name).setFlag(MODULE | FINAL).setModuleClass(clazz);
+ final def newModule(pos: int, name: Name) = {
+ val m = new TermSymbol(this, pos, name).setFlag(MODULE | FINAL);
+ m.setModuleClass(new ModuleClassSymbol(m))
+ }
final def newPackage(pos: int, name: Name) = {
assert(isPackageClass);
- val m = newModule(pos, name);
- m.setFlag(JAVA | PACKAGE);
+ val m = newModule(pos, name).setFlag(JAVA | PACKAGE);
m.moduleClass.setFlag(JAVA | PACKAGE);
m
}
@@ -95,8 +96,8 @@ abstract class Symbols: SymbolTable {
final def isValue = isTerm && !(isModule && hasFlag(PACKAGE | JAVA));
final def isVariable = isTerm && hasFlag(MUTABLE);
- final def isGetter = isTerm && hasFlag(ACCESSOR) && !name.endsWith(nme._EQ);
- final def isSetter = isTerm && hasFlag(ACCESSOR) && name.endsWith(nme._EQ);
+ final def isGetter = isTerm && hasFlag(ACCESSOR) && !originalName.endsWith(nme._EQ);
+ final def isSetter = isTerm && hasFlag(ACCESSOR) && originalName.endsWith(nme._EQ);
final def isValueParameter = isTerm && hasFlag(PARAM);
final def isLocalDummy = isTerm && (name startsWith nme.LOCAL_PREFIX);
final def isMethod = isTerm && hasFlag(METHOD);
@@ -448,18 +449,39 @@ abstract class Symbols: SymbolTable {
final def constrParamAccessors: List[Symbol] =
info.decls.toList filter (sym => !sym.isMethod && sym.hasFlag(PARAMACCESSOR));
+ final def originalName: Name = name.subName(0, name.pos("$$"));
+
/** The symbol accessed by this accessor function.
*/
final def accessed: Symbol = {
assert(hasFlag(ACCESSOR));
- val name1 = if (name.endsWith(nme._EQ)) name.subName(0, name.length - nme._EQ.length)
- else name;
+ var name1 = originalName;
+ if (name1.endsWith(nme._EQ)) name1 = name1.subName(0, name1.length - nme._EQ.length);
owner.info.decl(nme.LOCAL_NAME(name1))
}
- /** The getter for this symbol */
- final def getter: Symbol =
- if (nme.isLocalName(name)) owner.info.decl(nme.GETTER_NAME(name)) else NoSymbol;
+ private def findAccessor(p: Symbol => boolean): Symbol = {
+ val accs = owner.info.decls.toList filter (acc => p(acc) && acc.accessed == this);
+ if (accs.isEmpty) NoSymbol
+ else {
+ assert(accs.tail.isEmpty);
+ accs.head
+ }
+ }
+
+ final def getter: Symbol = {
+ val sym = owner.info.decl(nme.GETTER_NAME(name)) filter (.hasFlag(ACCESSOR));
+ if (sym != NoSymbol) sym else findAccessor(.isGetter)
+ }
+
+ final def setter: Symbol = {
+ val sym = owner.info.decl(nme.SETTER_NAME(name)) filter (.hasFlag(ACCESSOR));
+ if (sym != NoSymbol) sym else findAccessor(.isSetter)
+ }
+
+ /** For a paramaccessor: a superclass paramaccessor for which this symbol is
+ * an alias, NoSymbol for all others */
+ def aliasSym: Symbol = NoSymbol;
/** The class with the same name in the same package as this module or
* case class factory
@@ -522,7 +544,13 @@ abstract class Symbols: SymbolTable {
}
sym
}
+/*
+ def referenced: Symbol =
+ throw new Error("referenced inapplicable for " + this);
+ def setReferenced(sym: Symbol): Symbol =
+ throw new Error("setReferenced inapplicable for " + this);
+*/
// ToString -------------------------------------------------------------------
/** A tag which (in the ideal case) uniquely identifies class symbols */
@@ -653,18 +681,32 @@ abstract class Symbols: SymbolTable {
/** A class for term symbols */
class TermSymbol(initOwner: Symbol, initPos: int, initName: Name) extends Symbol(initOwner, initPos, initName) {
override def isTerm = true;
- def cloneSymbolImpl(owner: Symbol): Symbol =
- new TermSymbol(owner, pos, name);
- }
- /** A class for module symbols */
- class ModuleSymbol(initOwner: Symbol, initPos: int, initName: Name, mclazz: ClassSymbol) extends TermSymbol(initOwner, initPos, initName) {
- setFlag(MODULE | FINAL);
- private val clazz: ClassSymbol =
- if (mclazz != null) mclazz else new ModuleClassSymbol(this);
- override def moduleClass: ClassSymbol = clazz;
- override def cloneSymbolImpl(owner: Symbol): Symbol =
- new ModuleSymbol(owner, pos, name, clazz);
+ private var referenced: Symbol = NoSymbol;
+
+ def cloneSymbolImpl(owner: Symbol): Symbol = {
+ val clone = new TermSymbol(owner, pos, name);
+ clone.referenced = referenced;
+ clone
+ }
+
+ override def aliasSym: Symbol =
+ if (hasFlag(PARAMACCESSOR)) referenced else NoSymbol;
+
+ def setAlias(alias: Symbol): TermSymbol = {
+ assert(hasFlag(PARAMACCESSOR));
+ referenced = alias;
+ this
+ }
+
+ override def moduleClass: Symbol =
+ if (hasFlag(MODULE)) referenced else NoSymbol;
+
+ def setModuleClass(clazz: Symbol): TermSymbol = {
+ assert(hasFlag(MODULE));
+ referenced = clazz;
+ this
+ }
}
/** A class of type symbols. Alias and abstract types are direct instances
@@ -773,7 +815,7 @@ abstract class Symbols: SymbolTable {
/** A class for module class symbols
* Note: Not all module classes are of this type; when unpickled, we get plain class symbols!
*/
- class ModuleClassSymbol(module: ModuleSymbol) extends ClassSymbol(module.owner, module.pos, module.name.toTypeName) {
+ class ModuleClassSymbol(module: TermSymbol) extends ClassSymbol(module.owner, module.pos, module.name.toTypeName) {
setFlag(module.getFlag(ModuleToClassFlags) | MODULE | FINAL);
override def sourceModule = module;
}
diff --git a/sources/scala/tools/nsc/symtab/classfile/Pickler.scala b/sources/scala/tools/nsc/symtab/classfile/Pickler.scala
index 1c221462c2..22b726453e 100755
--- a/sources/scala/tools/nsc/symtab/classfile/Pickler.scala
+++ b/sources/scala/tools/nsc/symtab/classfile/Pickler.scala
@@ -85,10 +85,7 @@ abstract class Pickler extends SubComponent {
putType(sym.info);
if (sym.thisSym != sym)
putType(sym.typeOfThis);
- aliases.get(sym) match {
- case Some(alias) => putSymbol(alias);
- case None =>
- }
+ putSymbol(sym.aliasSym);
} else if (sym != NoSymbol) {
putEntry(if (sym.isModuleClass) sym.name.toTermName else sym.name);
if (!sym.owner.isRoot) putSymbol(sym.owner);
@@ -176,14 +173,8 @@ abstract class Pickler extends SubComponent {
if (sym.isAbstractType) TYPEsym else ALIASsym
case sym: TermSymbol =>
writeSymInfo(sym);
- if (sym.isModule) MODULEsym
- else {
- aliases.get(sym) match {
- case Some(alias) => writeRef(alias);
- case None =>
- }
- VALsym
- }
+ if (sym.aliasSym != NoSymbol) writeRef(sym.aliasSym);
+ if (sym.isModule) MODULEsym else VALsym
case NoType =>
NOtpe
case NoPrefix =>
diff --git a/sources/scala/tools/nsc/symtab/classfile/UnPickler.scala b/sources/scala/tools/nsc/symtab/classfile/UnPickler.scala
index 3429ba88d7..7969768c46 100755
--- a/sources/scala/tools/nsc/symtab/classfile/UnPickler.scala
+++ b/sources/scala/tools/nsc/symtab/classfile/UnPickler.scala
@@ -120,8 +120,10 @@ abstract class UnPickler {
errorBadSignature("bad symbol tag: " + tag);
}
sym.setFlag(flags);
- val aliasIndex = if ((sym hasFlag PARAMACCESSOR) && readIndex != end) readNat() else 0;
- sym.setInfo(new LazyTypeRef(inforef, aliasIndex));
+ if (readIndex != end) assert(sym hasFlag (ACCESSOR | PARAMACCESSOR));
+ sym.setInfo(
+ if (readIndex != end) new LazyTypeRefAndAlias(inforef, readNat())
+ else new LazyTypeRef(inforef));
if (sym.owner.isClass && sym != classRoot && sym != moduleRoot &&
!sym.isModuleClass && !sym.isRefinementClass && !sym.isTypeParameter)
symScope(sym.owner) enter sym;
@@ -197,13 +199,16 @@ abstract class UnPickler {
private def errorBadSignature(msg: String) =
throw new RuntimeException("malformed Scala signature of " + classRoot.name + " at " + readIndex + "; " + msg);
- private class LazyTypeRef(i: int, aliasIndex: int) extends LazyType {
- def this(i: int) = this(i, 0);
+ private class LazyTypeRef(i: int) extends LazyType {
+ override def complete(sym: Symbol): unit = sym setInfo at(i, readType);
+ override def load(sym: Symbol): unit = complete(sym)
+ }
+
+ private class LazyTypeRefAndAlias(i: int, j: int) extends LazyTypeRef(i) {
override def complete(sym: Symbol): unit = {
- sym setInfo at(i, readType);
- if (aliasIndex != 0) aliases(sym) = at(aliasIndex, readSymbol);
+ super.complete(sym);
+ sym.asInstanceOf[TermSymbol].setAlias(at(j, readSymbol));
}
- override def load(sym: Symbol): unit = complete(sym)
}
}
}
diff --git a/sources/scala/tools/nsc/transform/AddInterfaces.scala b/sources/scala/tools/nsc/transform/AddInterfaces.scala
index 79bdada436..1688585893 100755
--- a/sources/scala/tools/nsc/transform/AddInterfaces.scala
+++ b/sources/scala/tools/nsc/transform/AddInterfaces.scala
@@ -116,7 +116,7 @@ abstract class AddInterfaces extends InfoTransform {
}
val decls1 = addImplClasses(
if (clazz hasFlag INTERFACE) new Scope(decls.toList filter isInterfaceMember)
- else new Scope(decls));
+ else new Scope(decls.toList));
ClassInfoType(parents1, decls1, clazz)
case _ =>
tp
diff --git a/sources/scala/tools/nsc/transform/Flatten.scala b/sources/scala/tools/nsc/transform/Flatten.scala
index 7f4122c279..2b1dcdee78 100755
--- a/sources/scala/tools/nsc/transform/Flatten.scala
+++ b/sources/scala/tools/nsc/transform/Flatten.scala
@@ -33,10 +33,9 @@ abstract class Flatten extends InfoTransform {
def transformInfo(sym: Symbol, tp: Type): Type = flattened(tp);
- protected def newTransformer(unit: CompilationUnit): Transformer =
- new Flattener(unit);
+ protected def newTransformer(unit: CompilationUnit): Transformer = new Flattener;
- class Flattener(unit: CompilationUnit) extends Transformer {
+ class Flattener extends Transformer {
/** Buffers for lifted out classes */
private val liftedDefs = new HashMap[Symbol, ListBuffer[Tree]];
@@ -69,7 +68,7 @@ abstract class Flatten extends InfoTransform {
if (sym != null && sym.isNestedClass && !(sym hasFlag FLATTENED)) {
sym setFlag FLATTENED;
atPhase(phase.next) {
- System.out.println("re-enter " + sym + " in " + sym.owner);//debug
+ if (settings.debug.value) log("re-enter " + sym + " in " + sym.owner);
val scope = sym.owner.info.decls;
val old = scope lookup sym.name;
if (old != NoSymbol) scope unlink old;
diff --git a/sources/scala/tools/nsc/typechecker/Infer.scala b/sources/scala/tools/nsc/typechecker/Infer.scala
index fb40563938..5b1473918d 100755
--- a/sources/scala/tools/nsc/typechecker/Infer.scala
+++ b/sources/scala/tools/nsc/typechecker/Infer.scala
@@ -207,13 +207,14 @@ abstract class Infer: Analyzer {
tree setSymbol sym setType ErrorType
} else if (sym.owner.hasFlag(INCONSTRUCTOR) &&
!sym.isTypeParameter && !sym.isConstructor &&
- site.isInstanceOf[This]) {
+ site.isInstanceOf[This] && !phase.erasedTypes) {
errorTree(tree, "" + sym + " cannot be accessed from constructor");
} else {
val sym1 = sym filter (alt => context.isAccessible(alt, pre, site.isInstanceOf[Super]));
if (sym1 == NoSymbol) {
- if (settings.debug.value) System.out.println(context);
- System.out.println(tree);
+ if (settings.debug.value) System.out.println(context);//debug
+ System.out.println(tree);//debug
+ System.out.println("" + pre + " " + sym.owner.thisType + (pre =:= sym.owner.thisType));//debug
errorTree(tree, sym.toString() + " cannot be accessed in " + pre.widen)
} else {
var owntype = pre.memberType(sym1);
diff --git a/sources/scala/tools/nsc/typechecker/RefChecks.scala b/sources/scala/tools/nsc/typechecker/RefChecks.scala
index b12ea3d008..a9ac4d1f24 100755
--- a/sources/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/sources/scala/tools/nsc/typechecker/RefChecks.scala
@@ -30,6 +30,8 @@ import transform.InfoTransform;
* unless they are defined in the class or a baseclass
* different from java.lang.Object
* - Calls to case factory methods are replaced by new's.
+ * - References to parameter accessors with aliases are replaced by super references to
+ * these aliases.
*/
abstract class RefChecks extends InfoTransform {
@@ -502,20 +504,29 @@ abstract class RefChecks extends InfoTransform {
case Select(qual, name) =>
if (sym.isSourceMethod && sym.hasFlag(CASE))
result = toConstructor
- else {
- if (sym hasFlag DEFERRED) {
- qual match {
- case Super(qualifier, mixin) =>
- val base = currentOwner.enclClass;
- val member = sym.overridingSymbol(base);
- if (mixin != nme.EMPTY.toTypeName || member == NoSymbol ||
- !((member hasFlag ABSOVERRIDE) && member.isIncompleteIn(base)))
- unit.error(tree.pos, "symbol accessed from super may not be abstract");
- case _ =>
- }
+ else if (sym hasFlag DEFERRED) {
+ qual match {
+ case Super(qualifier, mixin) =>
+ val base = currentOwner.enclClass;
+ val member = sym.overridingSymbol(base);
+ if (mixin != nme.EMPTY.toTypeName || member == NoSymbol ||
+ !((member hasFlag ABSOVERRIDE) && member.isIncompleteIn(base)))
+ unit.error(tree.pos, "symbol accessed from super may not be abstract");
+ case _ =>
}
- }
-
+ } else if (sym.aliasSym != NoSymbol) {
+ qual match {
+ case This(_) =>
+ result = typed {
+ Select(
+ Super(qual.symbol, qual.symbol.info.parents.head.symbol.name) setPos qual.pos,
+ sym.aliasSym) setPos tree.pos
+ }
+ if (settings.debug.value)
+ System.out.println("alias replacement: " + tree + " ==> " + result);//debug
+ case _ =>
+ }
+ }
case _ =>
}
super.transform(result)
diff --git a/sources/scala/tools/nsc/typechecker/Typers.scala b/sources/scala/tools/nsc/typechecker/Typers.scala
index 68c092b8c0..2d8cbd18c8 100755
--- a/sources/scala/tools/nsc/typechecker/Typers.scala
+++ b/sources/scala/tools/nsc/typechecker/Typers.scala
@@ -455,26 +455,26 @@ abstract class Typers: Analyzer {
def addGetterSetter(stat: Tree): List[Tree] = stat match {
case ValDef(mods, name, tpe, rhs) if (mods & LOCAL) == 0 =>
val vdef = copy.ValDef(stat, mods | PRIVATE | LOCAL, nme.LOCAL_NAME(name), tpe, rhs);
- val getter: DefDef = {
- val sym = vdef.symbol;
- val getter = sym.owner.info.decl(name).suchThat(.hasFlag(ACCESSOR));
+ val value = vdef.symbol;
+ val getterDef: DefDef = {
+ val getter = if ((mods & DEFERRED) != 0) value else value.getter;
+ assert(getter != NoSymbol, value);
val result = atPos(vdef.pos)(
DefDef(getter, vparamss =>
if ((mods & DEFERRED) != 0) EmptyTree
- else typed(Select(This(sym.owner), sym), EXPRmode, sym.tpe)));
- checkNoEscaping.privates(result.symbol, result.tpt);
+ else typed(Select(This(value.owner), value), EXPRmode, value.tpe)));
+ checkNoEscaping.privates(getter, result.tpt);
result
}
- def setter: DefDef = {
- val sym = vdef.symbol;
- val setter = sym.owner.info.decl(nme.SETTER_NAME(name)).suchThat(.hasFlag(ACCESSOR));
+ def setterDef: DefDef = {
+ val setter = value.setter;
atPos(vdef.pos)(
DefDef(setter, vparamss =>
if ((mods & DEFERRED) != 0) EmptyTree
- else typed(Assign(Select(This(sym.owner), getter.symbol),
+ else typed(Assign(Select(This(value.owner), getterDef.symbol),
Ident(vparamss.head.head)))))
}
- val gs = if ((mods & MUTABLE) != 0) List(getter, setter) else List(getter);
+ val gs = if ((mods & MUTABLE) != 0) List(getterDef, setterDef) else List(getterDef);
if ((mods & DEFERRED) != 0) gs else vdef :: gs
case DocDef(comment, defn) =>
addGetterSetter(defn) map (stat => DocDef(comment, stat))
@@ -544,21 +544,16 @@ abstract class Typers: Analyzer {
superArg match {
case Ident(name) =>
if (vparamss.exists(.exists(vp => vp.symbol == superArg.symbol))) {
- val alias = aliases.get(superAcc.initialize) match {
- case Some(getter) =>
- getter
- case None =>
- val getter = superAcc.getter;
- if (getter != NoSymbol &&
- superClazz.info.nonPrivateMember(getter.name) == getter) getter
- else NoSymbol
- }
+ var alias = superAcc.initialize.aliasSym;
+ if (alias == NoSymbol) alias = superAcc.getter;
+ if (alias != NoSymbol &&
+ superClazz.info.nonPrivateMember(alias.name) != alias)
+ alias = NoSymbol;
if (alias != NoSymbol) {
var ownAcc = clazz.info.decl(name);
if (ownAcc hasFlag ACCESSOR) ownAcc = ownAcc.accessed;
- assert(ownAcc hasFlag PARAMACCESSOR, clazz.toString() + " " + name);
System.out.println("" + ownAcc + " has alias " + alias + alias.locationString);//debug
- aliases(ownAcc) = alias
+ ownAcc.asInstanceOf[TermSymbol].setAlias(alias)
}
}
case _ =>
@@ -1099,7 +1094,7 @@ abstract class Typers: Analyzer {
Select(qual, nme.SETTER_NAME(name)) setPos lhs.pos,
List(rhs)) setPos tree.pos, mode, pt)
}
- } else if (varsym != null && varsym.isVariable) {
+ } else if (varsym != null && (varsym.isVariable || varsym.isValue && phase.erasedTypes)) {
val rhs1 = typed(rhs, lhs1.tpe);
copy.Assign(tree, lhs1, rhs1) setType UnitClass.tpe;
} else {
diff --git a/sources/scala/util/automata/Inclusion.scala b/sources/scala/util/automata/Inclusion.scala
index 329e56b5bc..4b155c7f06 100644
--- a/sources/scala/util/automata/Inclusion.scala
+++ b/sources/scala/util/automata/Inclusion.scala
@@ -51,5 +51,4 @@ trait Inclusion[A <: AnyRef] {
}
result
}
-
}
diff --git a/sources/scala/xml/dtd/ElementValidator.scala b/sources/scala/xml/dtd/ElementValidator.scala
index e625595182..1304ff4123 100644
--- a/sources/scala/xml/dtd/ElementValidator.scala
+++ b/sources/scala/xml/dtd/ElementValidator.scala
@@ -58,7 +58,7 @@ class ElementValidator() extends Function1[Node,Boolean] {
var j = 0;
var ok = new scala.collection.mutable.BitSet(adecls.length);
def find(Key:String): AttrDecl = {
- var attr: AttrDecl = _;
+ var attr: AttrDecl = null;
val jt = adecls.elements; while(j < adecls.length) {
jt.next match {
case a @ AttrDecl(Key, _, _) => attr = a; ok.set(j); j = adecls.length;
diff --git a/sources/scala/xml/parsing/ExternalSources.scala b/sources/scala/xml/parsing/ExternalSources.scala
index edffbf5556..d4a1511e99 100644
--- a/sources/scala/xml/parsing/ExternalSources.scala
+++ b/sources/scala/xml/parsing/ExternalSources.scala
@@ -25,7 +25,7 @@ trait ExternalSources : (ExternalSources with MarkupParser with MarkupHandler)
//@todo: replace this hack with proper Source implementation
val str = new StringBuffer();
- var inputLine:String = _;
+ var inputLine:String = null;
//while (inputLine = in.readLine()) != null) {
while ({inputLine = in.readLine(); inputLine} != null) {
diff --git a/sources/scala/xml/parsing/MarkupParser.scala b/sources/scala/xml/parsing/MarkupParser.scala
index d3387018c8..e1cfe86e77 100644
--- a/sources/scala/xml/parsing/MarkupParser.scala
+++ b/sources/scala/xml/parsing/MarkupParser.scala
@@ -190,7 +190,7 @@ abstract class MarkupParser: (MarkupParser with MarkupHandler) extends AnyRef wi
}
val children = content(TopScope); // DTD handled as side effect
var elemCount = 0;
- var theNode: Node = _;
+ var theNode: Node = null;
for (val c <- children) c match {
case _:ProcInstr => ;
case _:Comment => ;