diff --git a/src/actors/scala/actors/remote/NetKernel.scala b/src/actors/scala/actors/remote/NetKernel.scala index c335f5cc5..c6b2d8b8c 100644 --- a/src/actors/scala/actors/remote/NetKernel.scala +++ b/src/actors/scala/actors/remote/NetKernel.scala @@ -10,7 +10,7 @@ package scala.actors package remote -import scala.collection.mutable.{HashMap, HashSet} +import scala.collection.mutable case class NamedSend(senderLoc: Locator, receiverLoc: Locator, data: Array[Byte], session: Symbol) @@ -39,8 +39,8 @@ private[remote] class NetKernel(service: Service) { sendToNode(receiverLoc.node, NamedSend(senderLoc, receiverLoc, bytes, session)) } - private val actors = new HashMap[Symbol, OutputChannel[Any]] - private val names = new HashMap[OutputChannel[Any], Symbol] + private val actors = new mutable.HashMap[Symbol, OutputChannel[Any]] + private val names = new mutable.HashMap[OutputChannel[Any], Symbol] def register(name: Symbol, a: OutputChannel[Any]): Unit = synchronized { actors += Pair(name, a) @@ -83,7 +83,7 @@ private[remote] class NetKernel(service: Service) { p } - val proxies = new HashMap[(Node, Symbol), Proxy] + val proxies = new mutable.HashMap[(Node, Symbol), Proxy] def getOrCreateProxy(senderNode: Node, senderName: Symbol): Proxy = proxies.synchronized { diff --git a/src/actors/scala/actors/remote/Proxy.scala b/src/actors/scala/actors/remote/Proxy.scala index 3d1b4401b..5feec3a63 100644 --- a/src/actors/scala/actors/remote/Proxy.scala +++ b/src/actors/scala/actors/remote/Proxy.scala @@ -10,7 +10,7 @@ package scala.actors package remote -import scala.collection.mutable.HashMap +import scala.collection.mutable /** * @author Philipp Haller @@ -113,8 +113,8 @@ private[remote] case class Apply0(rfun: Function2[AbstractActor, Proxy, Unit]) * @author Philipp Haller */ private[remote] class DelegateActor(creator: Proxy, node: Node, name: Symbol, kernel: NetKernel) extends Actor { - var channelMap = new HashMap[Symbol, OutputChannel[Any]] - var sessionMap = new HashMap[OutputChannel[Any], Symbol] + var channelMap = new mutable.HashMap[Symbol, OutputChannel[Any]] + var sessionMap = new mutable.HashMap[OutputChannel[Any], Symbol] def act() { Actor.loop { diff --git a/src/actors/scala/actors/remote/TcpService.scala b/src/actors/scala/actors/remote/TcpService.scala index d156443fc..be34e93cd 100644 --- a/src/actors/scala/actors/remote/TcpService.scala +++ b/src/actors/scala/actors/remote/TcpService.scala @@ -16,7 +16,7 @@ import java.io.{DataInputStream, DataOutputStream, IOException} import java.lang.{Thread, SecurityException} import java.net.{InetAddress, ServerSocket, Socket, UnknownHostException} -import scala.collection.mutable.HashMap +import scala.collection.mutable import scala.util.Random /* Object TcpService. @@ -26,7 +26,7 @@ import scala.util.Random */ object TcpService { private val random = new Random - private val ports = new HashMap[Int, TcpService] + private val ports = new mutable.HashMap[Int, TcpService] def apply(port: Int, cl: ClassLoader): TcpService = ports.get(port) match { @@ -73,7 +73,7 @@ class TcpService(port: Int, cl: ClassLoader) extends Thread with Service { private val internalNode = new Node(InetAddress.getLocalHost().getHostAddress(), port) def node: Node = internalNode - private val pendingSends = new HashMap[Node, List[Array[Byte]]] + private val pendingSends = new mutable.HashMap[Node, List[Array[Byte]]] /** * Sends a byte array to another node on the network. @@ -161,7 +161,7 @@ class TcpService(port: Int, cl: ClassLoader) extends Thread with Service { // connection management private val connections = - new scala.collection.mutable.HashMap[Node, TcpServiceWorker] + new mutable.HashMap[Node, TcpServiceWorker] private[actors] def addConnection(node: Node, worker: TcpServiceWorker) = synchronized { connections += Pair(node, worker) diff --git a/src/actors/scala/actors/scheduler/ActorGC.scala b/src/actors/scala/actors/scheduler/ActorGC.scala index 473fba1a1..41ec401db 100644 --- a/src/actors/scala/actors/scheduler/ActorGC.scala +++ b/src/actors/scala/actors/scheduler/ActorGC.scala @@ -11,8 +11,7 @@ package scala.actors package scheduler import java.lang.ref.{Reference, WeakReference, ReferenceQueue} - -import scala.collection.mutable.HashSet +import scala.collection.mutable /** * ActorGC keeps track of the number of live actors being managed by a @@ -35,7 +34,7 @@ trait ActorGC extends TerminationMonitor { * this ActorGC. It is maintained so that the WeakReferences will not be GC'd * before the actors to which they point. */ - private val refSet = new HashSet[Reference[t] forSome { type t <: TrackedReactor }] + private val refSet = new mutable.HashSet[Reference[t] forSome { type t <: TrackedReactor }] /** newActor is invoked whenever a new actor is started. */ override def newActor(a: TrackedReactor) = synchronized { diff --git a/src/actors/scala/actors/scheduler/SingleThreadedScheduler.scala b/src/actors/scala/actors/scheduler/SingleThreadedScheduler.scala index 021c70681..70554ec65 100644 --- a/src/actors/scala/actors/scheduler/SingleThreadedScheduler.scala +++ b/src/actors/scala/actors/scheduler/SingleThreadedScheduler.scala @@ -10,7 +10,7 @@ package scala.actors package scheduler -import scala.collection.mutable.Queue +import scala.collection.mutable /** * This scheduler executes actor tasks on the current thread. @@ -19,7 +19,7 @@ import scala.collection.mutable.Queue */ class SingleThreadedScheduler extends IScheduler { - private val tasks = new Queue[Runnable] + private val tasks = new mutable.Queue[Runnable] /** The maximum number of nested tasks that are run * without unwinding the call stack. diff --git a/src/actors/scala/actors/scheduler/TerminationMonitor.scala b/src/actors/scala/actors/scheduler/TerminationMonitor.scala index 9b2e1a12f..c03a48ee9 100644 --- a/src/actors/scala/actors/scheduler/TerminationMonitor.scala +++ b/src/actors/scala/actors/scheduler/TerminationMonitor.scala @@ -6,17 +6,16 @@ ** |/ ** \* */ - package scala.actors package scheduler -import scala.collection.mutable.HashMap +import scala.collection.mutable private[scheduler] trait TerminationMonitor { _: IScheduler => protected var activeActors = 0 - protected val terminationHandlers = new HashMap[TrackedReactor, () => Unit] + protected val terminationHandlers = new mutable.HashMap[TrackedReactor, () => Unit] private var started = false /** newActor is invoked whenever a new actor is started. */ diff --git a/src/attic/scala/tools/nsc/models/Models.scala b/src/attic/scala/tools/nsc/models/Models.scala deleted file mode 100644 index 0cd6a63eb..000000000 --- a/src/attic/scala/tools/nsc/models/Models.scala +++ /dev/null @@ -1,419 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL - * @author Martin Odersky - */ - -package scala.tools.nsc -package models - -import scala.tools.nsc.Global - -/** This abstract class ... - * - * @author Sean McDirmid - * @version 1.0 - */ -abstract class Models { - val global: Global - import global._ - - def acceptPrivate = true - - object Kinds extends Enumeration { - type Kind = Value - val CONSTRUCTOR = Value("Constructor") - val OBJECT = Value("Object") - val CLASS = Value("Class") - val TRAIT = Value("Trait") - val DEF = Value("Def") - val VAL = Value("Val") - val VAR = Value("Var") - val ARG = Value("Arg") - val TPARAM = Value("Type") - } - import Kinds._ - - def KINDS = List(CLASS, TRAIT, OBJECT, CONSTRUCTOR, TPARAM, VAL, VAR, DEF) - - def labelFor(kind: Kind): String = kind.toString - - def stringsFor(mods: Modifiers) = { - var modString: List[String] = Nil - if (mods.isPrivate ) modString = "private" :: modString - if (mods.isProtected) modString = "protected" :: modString - if (mods.isOverride ) modString = "override" :: modString - if (mods.isAbstract ) modString = "abstract" :: modString - if (mods.isDeferred ) modString = "abstract" :: modString - if (mods.isCase ) modString = "case" :: modString - if (mods.isSealed ) modString = "sealed" :: modString - if (mods.isFinal ) modString = "final" :: modString - if (mods.isImplicit ) modString = "implicit" :: modString - modString - } - - def codeFor(kind: Kind): String = kind match { - case CONSTRUCTOR => codeFor(DEF) - case _ => labelFor(kind).toLowerCase() - } - - def pluralFor(kind: Kind): String = kind match { - case CLASS => "Classes" - case _ => labelFor(kind) + "s" - } - - def kindOf(tree: Tree) = { - val term0 = tree.symbol; - if (term0 != NoSymbol) { - if (term0.isVariable) VAR - else if (term0.isValueParameter) ARG - else if (term0.isMethod) { - if (term0.nameString.equals("this")) CONSTRUCTOR - else DEF - } - else if (term0.isClass) { - if (tree.asInstanceOf[MemberDef].mods.isTrait) TRAIT - else CLASS - } - else if (term0.isModule) OBJECT - else if (term0.isValue) VAL - else if (term0.isTypeParameter) TPARAM - else if (term0.isType) TPARAM - else { - // Console.err.println("UNRECOGNIZED SYMBOL: " + term0 + " " + name); - null - } - } else { - val ddef = tree.asInstanceOf[ValOrDefDef]; - if (ddef.mods.isMutable) VAR; - else VAL; - } - } - - abstract class Model - - // def textFor(tp : AbsTypeDef) : String = tp.toString() - - /** - * @param tree ... - * @return ... - */ - def textFor(tree: Tree): String = { - var ret = "" - if (tree.symbol != NoSymbol) tree.symbol.name.toString() - if (ret.equals("")) ret = "this" - tree match { - case cdef: ClassDef => - ret = ret + "[" + - (for (tparam <- cdef.tparams) yield textFor(tparam)) + "]"; - cdef.mods - case vdef: ValOrDefDef => - vdef match { - case ddef: DefDef => - ret = ret + "[" + - (for (tparam <- ddef.tparams) yield textFor(tparam)) + "]"; - for (vparams <- ddef.vparamss) { - ret = ret + "(" + - (for (vparam <- vparams) yield textFor(vparam)) + ")"; - } - case _ => - } - ret = ret + " : " + textFor(vdef.tpt) -/* Martin to Sean: Please check whether this can be dropped or does it need to be adapted? - case atd: AbsTypeDef => - ret = ret + "[" + (for (tparam <- atd.tparams) yield textFor(tparam)) + "]" + - ((if(atd.hi ne null) " <: " + textFor(atd.hi) else "") + - (if(atd.lo ne null) " >: " + textFor(atd.lo) else "")); -*/ - case _ => - ret = ret + tree.toString() - } - ret - } - - def mods1(tree: Tree) = tree match { - case mdef: MemberDef => mdef.mods - case _ => NoMods - } - - abstract class HasTree(val parent: Composite) extends Model with Ordered[HasTree] { - var tree : Tree = _ - def update(tree0: Tree): Boolean = { - tree = tree0 - false - } - def replacedBy(tree0: Tree): Boolean = true - def text: String = textFor(tree) - var mods0 = NoMods - - def mods = if (mods0 != NoMods) mods0 else mods1(tree) - - override def toString(): String = tree.toString() - - def compare(that: HasTree): Int = { - val idx = KINDS.indexOf(kind) - val jdx = KINDS.indexOf(that.kind) - if (idx != jdx) return idx - jdx - val result = tree.symbol.nameString.compare(that.tree.symbol.nameString) - if (result != 0) result - else toString().compare(that.toString()) - } - def compare [b >: HasTree <% Ordered[b]](that: b): Int = { - if (that.isInstanceOf[HasTree]) - compare(that.asInstanceOf[HasTree]) - else -1 - } - - def kind = kindOf(tree) - - //override def add(from: Composite, model: HasTree): Unit = { parent.add(from, model) } - //override def remove(from: Composite, model: HasTree): Unit = { parent.remove(from, model) } - } - - class ImportMod(parent0: Composite) extends HasTree(parent0) { - def treex = tree.asInstanceOf[Import] - - override def replacedBy(tree0: Tree): Boolean = - if (super.replacedBy(tree0) && tree0.isInstanceOf[Import]) { - val tree1 = tree0.asInstanceOf[Import] - tree1.tpe == treex.tpe - } else - false - } - - class PackageMod(parent0: Composite) extends HasTree(parent0) { - def treex = tree.asInstanceOf[PackageDef] - } - - trait Composite extends Model { - import scala.collection.mutable._ - - class Members extends HashSet[HasTree] - // val members = new Members - object members extends Members - - def isMember(tree: Tree): Boolean = tree.isInstanceOf[Import] // imports welcome anywhere. - - def member(tree: Tree, members: List[Tree]): Tree = tree - - def update0(members1: List[Tree]): Boolean = { - // Console.err.println("update0 " + this + " " + members1) - // Martin: This is rather ugly code. We should use pattern matching here! - if (members1.length == 1 && members1.head.isInstanceOf[PackageDef]) - return update0(members1.head.asInstanceOf[PackageDef].stats) - val marked = new HashSet[HasTree] - var updated = false - for (mmbr1 <- members1) if (mmbr1.isInstanceOf[PackageDef]) { - Console.err.println("PACKAGE: " + mmbr1.symbol + " " + members1.length) - } else if (isMember(mmbr1)) { - val mmbr2 = member(mmbr1, members1) - if (mmbr2 ne null) { - var found = false - for (mmbr <- members) if (!found && mmbr.replacedBy(mmbr2)) { - //Console.err.println("REPLACE: " + mmbr + " with " + mmbr2) - mmbr.mods0 = mods1(mmbr1) - found = true - updated = mmbr.update(mmbr2) || updated - marked += mmbr - } - if (!found) { - updated = true - val add = modelFor(mmbr2, this) - add.update(mmbr2) - add.mods0 = mods1(mmbr1) & - ~symtab.Flags.ACCESSOR & ~symtab.Flags.SYNTHETIC - val sz = members.size - members += (add) - assert(members.size == sz + 1) - marked += add - } - } - // Console.err.println("update1 " + this + " " + members + " " + marked) - } - val sz = members.size - members.intersect(marked) - updated = updated || sz < members.size - // check if anything was removed! - updated - } - } - abstract class MemberMod(parent0: Composite) extends HasTree(parent0) { - def treex = tree.asInstanceOf[MemberDef] - - def name: Name = treex.name - - override def replacedBy(tree0: Tree): Boolean = - if (super.replacedBy(tree0) && tree0.isInstanceOf[MemberDef]) { - val tree1 = tree0.asInstanceOf[MemberDef] - treex.toString().equals(tree1.toString()) - } else false - - override def update(tree0: Tree): Boolean = { - val updated = (tree eq null) || (treex.mods != tree0.asInstanceOf[MemberDef].mods) - super.update(tree0) || updated; - } - } - - abstract class MemberComposite(parent0: Composite) extends MemberMod(parent0) with Composite - - trait HasClassObjects extends Composite { - override def isMember(tree: Tree): Boolean = - super.isMember(tree) || tree.isInstanceOf[ImplDef] - } - - abstract class ValOrDefMod(parent0: Composite) extends MemberComposite(parent0) with HasClassObjects { - override def replacedBy(tree0: Tree): Boolean = - super.replacedBy(tree0) && tree0.isInstanceOf[ValOrDefDef] - - override def update(tree0: Tree): Boolean = { - val tree1 = tree0.asInstanceOf[ValOrDefDef] - val updated = (tree eq null) || treex.tpe != tree1.tpe - update0(flatten(tree1.rhs, (tree2: Tree) => isMember(tree2))) - super.update(tree0) || updated - } - } - - class ValMod(parent0: Composite) extends ValOrDefMod(parent0) { - def treez = tree.asInstanceOf[ValDef] - override def replacedBy(tree0: Tree): Boolean = - super.replacedBy(tree0) && tree0.isInstanceOf[ValDef] - } - - class DefMod(parent0: Composite) extends ValOrDefMod(parent0) { - def treez = tree.asInstanceOf[DefDef] - - override def replacedBy(tree0: Tree) : Boolean = - if (super.replacedBy(tree0) && tree0.isInstanceOf[DefDef]) { - val tree1 = tree0.asInstanceOf[DefDef] - if (tree1.vparamss.length == treez.vparamss.length) { - val tpz = for (vd <- treez.vparamss) yield for (xd <- vd) yield xd.tpe; - val tp1 = for (vd <- tree1.vparamss) yield for (xd <- vd) yield xd.tpe; - tpz == tp1 - } else false - } else false - } - - abstract class ImplMod(parent0: Composite) - extends MemberComposite(parent0) with HasClassObjects { - override def replacedBy(tree0: Tree): Boolean = - super.replacedBy(tree0) && tree0.isInstanceOf[ImplDef] - override def isMember(tree: Tree): Boolean = (super.isMember(tree) || - (tree.isInstanceOf[ValOrDefDef] && - (acceptPrivate || !tree.asInstanceOf[ValOrDefDef].mods.isPrivate) - /* && !tree.asInstanceOf[ValOrDefDef].mods.isPrivate */ - /* && !tree.asInstanceOf[ValOrDefDef].mods.isAccessor */) || - treeInfo.isAliasTypeDef(tree)) - - override def member(tree: Tree, members: List[Tree]): Tree = { - val tree0 = if (tree.isInstanceOf[DefDef]) { - val ddef = tree.asInstanceOf[DefDef] - ddef.mods - if (ddef.mods.isAccessor && (ddef.symbol ne null)) { - val sym0 = ddef.symbol; - if (sym0.isSetter) return null; - assert(sym0.isGetter); - val sym = sym0.accessed - val ret = if (sym == NoSymbol) { - val sym = analyzer.underlying(sym0) - //val name = nme.getterToSetter(sym0.name) - //val setter = sym0.owner.info.decl(name); - val isVar = sym.isVariable; - val mods = (ddef.mods | - (if (isVar) symtab.Flags.MUTABLE else 0) | symtab.Flags.DEFERRED) & - ~symtab.Flags.ACCESSOR & ~symtab.Flags.SYNTHETIC - val tree = - ValDef(mods, ddef.name, ddef.tpt, ddef.rhs).setPos(ddef.pos).setSymbol(sym); - tree :: Nil; - } else for (member <- members if member.symbol == sym) yield member - if (ret.isEmpty) null - else ret.head - } else tree - } else super.member(tree, members) - - def sym = tree0.symbol - if ((tree0 eq null) || tree0.pos == NoPosition) null - else if (!acceptPrivate && - tree0.isInstanceOf[ValOrDefDef] && - tree.asInstanceOf[ValOrDefDef].mods.isPrivate) null - else tree0 - } - - def children(tree0: Tree): List[Tree] = - tree0.asInstanceOf[ImplDef].impl.body - - override def update(tree0: Tree): Boolean = { - var updated = update0(children(tree0)) - super.update(tree0) || updated - } - } - - class ClassMod(parent0: Composite) extends ImplMod(parent0) { - def treez = tree.asInstanceOf[ClassDef] - override def replacedBy(tree0: Tree): Boolean = - super.replacedBy(tree0) && tree0.isInstanceOf[ClassDef] - } - - class ObjectMod(parent0: Composite) extends ImplMod(parent0) { - def treez = tree.asInstanceOf[ModuleDef] - override def replacedBy(tree0: Tree): Boolean = - super.replacedBy(tree0) && tree0.isInstanceOf[ModuleDef] - } - class TypeMod(parent0: Composite) extends MemberMod(parent0) { - override def replacedBy(tree0 : Tree) : Boolean = (super.replacedBy(tree0) && tree0.isInstanceOf[TypeDef]); - } - def SourceMod(original: CompilationUnit) = new SourceMod(original) - - class SourceMod(val original: CompilationUnit) extends Composite with HasClassObjects { - update(original) - //var listener : Listener = null; - def update(unit: CompilationUnit) = unit.body match { - case pdef: PackageDef => try { - update0(pdef.stats) - } catch { - case e: Error => members.clear; update0(pdef.stats) - } - case _ => - } - - override def isMember(tree: Tree): Boolean = - super.isMember(tree) || tree.isInstanceOf[Import] - } - - def flatten0(exprs: List[Tree], filter: (Tree) => Boolean): List[Tree] = - for (expr <- exprs; t: Tree <- flatten(expr,filter)) yield t - - def flatten(expr: Tree, filter: (Tree) => Boolean): List[Tree] = - if (filter(expr)) expr :: Nil; else expr match { - case Block(stats, last) => - flatten0(stats, filter) ::: flatten(last, filter) - case If(cond, thenp, elsep) => - flatten(cond,filter) ::: flatten(thenp,filter) ::: flatten(elsep,filter); - case Assign(lhs, rhs) => - flatten(rhs, filter) - case CaseDef(pat, guard, body) => - flatten(body, filter) - case Return(expr0) => - flatten(expr0, filter) - case Throw(expr0) => - flatten(expr0,filter) - case Try(block, catches, finalizer) => - flatten(block, filter) ::: flatten(finalizer, filter) ::: flatten0(catches, filter) - case Match(selector, cases) => - flatten(selector, filter) ::: flatten0(cases, filter) - case Apply(fun, args) => - flatten(fun, filter) ::: flatten0(args, filter) - case TypeApply(fun, args) => - flatten(fun, filter) ::: flatten0(args, filter) - case _ => - Nil - } - - def modelFor(tree: Tree, parent: Composite): HasTree = tree match { - case _: ValDef => new ValMod(parent) - case _: DefDef => new DefMod(parent) - case _: ClassDef => new ClassMod(parent) - case _: ModuleDef => new ObjectMod(parent) - case _: TypeDef => new TypeMod(parent) - case _: Import => new ImportMod(parent) - } - -} diff --git a/src/attic/scala/tools/nsc/symtab/SymbolWalker.scala b/src/attic/scala/tools/nsc/symtab/SymbolWalker.scala index 044a6ddef..6a5cd8919 100644 --- a/src/attic/scala/tools/nsc/symtab/SymbolWalker.scala +++ b/src/attic/scala/tools/nsc/symtab/SymbolWalker.scala @@ -11,7 +11,6 @@ trait SymbolWalker { def apply(pos : Position) : Symbol def putDef(sym : Symbol, pos : Position) : Unit = () } - import scala.collection.mutable.Map /* implicit def map2use(map : Map[Position,Symbol]) = new Visitor { def update(pos : Position, sym : Symbol) : Unit = map.update(pos, sym) diff --git a/src/compiler/scala/reflect/internal/BaseTypeSeqs.scala b/src/compiler/scala/reflect/internal/BaseTypeSeqs.scala index fe137a749..74ce0d53a 100644 --- a/src/compiler/scala/reflect/internal/BaseTypeSeqs.scala +++ b/src/compiler/scala/reflect/internal/BaseTypeSeqs.scala @@ -6,7 +6,7 @@ package scala.reflect package internal // todo implement in terms of BitSet -import scala.collection.mutable.{ListBuffer, BitSet} +import scala.collection.{ mutable, immutable } import math.max import util.Statistics._ @@ -41,7 +41,7 @@ trait BaseTypeSeqs { // (while NoType is in there to indicate a cycle in this BTS, during the execution of // the mergePrefixAndArgs below, the elems get copied without the pending map, // so that NoType's are seen instead of the original type --> spurious compile error) - val pending = new BitSet(length) + val pending = new mutable.BitSet(length) /** The type at i'th position in this sequence; lazy types are returned evaluated. */ def apply(i: Int): Type = @@ -187,7 +187,7 @@ trait BaseTypeSeqs { val tsym = tp.typeSymbol val parents = tp.parents // Console.println("computing baseTypeSeq of " + tsym.tpe + " " + parents)//DEBUG - val buf = new ListBuffer[Type] + val buf = new mutable.ListBuffer[Type] buf += tsym.tpe var btsSize = 1 if (parents.nonEmpty) { diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala index 0a807443b..ccd8e6b17 100644 --- a/src/compiler/scala/reflect/internal/Definitions.scala +++ b/src/compiler/scala/reflect/internal/Definitions.scala @@ -7,7 +7,6 @@ package scala.reflect package internal import scala.collection.{ mutable, immutable } -import scala.collection.mutable.{ HashMap } import Flags._ import PartialFunction._ @@ -503,7 +502,7 @@ trait Definitions extends reflect.api.StandardDefinitions { var Delegate_scalaCallers: List[Symbol] = List() // Symbol -> (Symbol, Type): scalaCaller -> (scalaMethodSym, DelegateType) // var Delegate_scalaCallerInfos: HashMap[Symbol, (Symbol, Type)] = _ - lazy val Delegate_scalaCallerTargets: HashMap[Symbol, Symbol] = new HashMap() + lazy val Delegate_scalaCallerTargets: mutable.HashMap[Symbol, Symbol] = mutable.HashMap() def isCorrespondingDelegate(delegateType: Type, functionType: Type): Boolean = { isSubType(delegateType, DelegateClass.tpe) && diff --git a/src/compiler/scala/reflect/internal/SymbolTable.scala b/src/compiler/scala/reflect/internal/SymbolTable.scala index 99264541f..fc1617f9f 100644 --- a/src/compiler/scala/reflect/internal/SymbolTable.scala +++ b/src/compiler/scala/reflect/internal/SymbolTable.scala @@ -116,6 +116,9 @@ abstract class SymbolTable extends api.Universe object perRunCaches { import java.lang.ref.WeakReference + import scala.tools.util.Signallable + import scala.runtime.ScalaRunTime.stringOf + // We can allow ourselves a structural type, these methods // amount to a few calls per run at most. This does suggest @@ -127,7 +130,26 @@ abstract class SymbolTable extends api.Universe // Weak references so the garbage collector will take care of // letting us know when a cache is really out of commission. private val caches = mutable.HashSet[WeakReference[Clearable]]() + + private def dumpCaches() { + println(caches.size + " structures are in perRunCaches.") + caches.zipWithIndex foreach { case (ref, index) => + val cache = ref.get() + println("(" + index + ")" + ( + if (cache == null) " has been collected." + else " has " + cache.size + " entries:\n" + stringOf(cache) + )) + } + } + if (settings.debug.value) { + println(Signallable("dump compiler caches")(dumpCaches())) + } + def recordCache[T <: Clearable](cache: T): T = { + caches += new WeakReference(cache) + cache + } + def clearAll() = { if (settings.debug.value) { val size = caches flatMap (ref => Option(ref.get)) map (_.size) sum; @@ -142,8 +164,9 @@ abstract class SymbolTable extends api.Universe } } - def newMap[K, V]() = { val m = mutable.HashMap[K, V]() ; caches += new WeakReference(m) ; m } - def newSet[K]() = { val s = mutable.HashSet[K]() ; caches += new WeakReference(s) ; s } + def newWeakMap[K, V]() = recordCache(mutable.WeakHashMap[K, V]()) + def newMap[K, V]() = recordCache(mutable.HashMap[K, V]()) + def newSet[K]() = recordCache(mutable.HashSet[K]()) } /** Break into repl debugger if assertion is true. */ diff --git a/src/compiler/scala/reflect/internal/TreeInfo.scala b/src/compiler/scala/reflect/internal/TreeInfo.scala index 32c0e5c73..0944e7e73 100644 --- a/src/compiler/scala/reflect/internal/TreeInfo.scala +++ b/src/compiler/scala/reflect/internal/TreeInfo.scala @@ -7,7 +7,6 @@ package scala.reflect package internal import Flags._ -import util.HashSet /** This class ... * diff --git a/src/compiler/scala/reflect/internal/Trees.scala b/src/compiler/scala/reflect/internal/Trees.scala index 9150f69bf..24286f13d 100644 --- a/src/compiler/scala/reflect/internal/Trees.scala +++ b/src/compiler/scala/reflect/internal/Trees.scala @@ -6,13 +6,10 @@ package scala.reflect package internal -import java.io.{PrintWriter, StringWriter} -import scala.collection.mutable.ListBuffer +import java.io.{ PrintWriter, StringWriter } import Flags._ import api.Modifier -//import scala.tools.nsc.util.{ FreshNameCreator, HashSet, SourceFile } - trait Trees extends api.Trees { self: SymbolTable => // --- modifiers implementation --------------------------------------- diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index aadcca9fc..9bc7a5895 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -9,8 +9,6 @@ package internal import scala.collection.{ mutable, immutable } import scala.ref.WeakReference import mutable.ListBuffer -//import ast.TreeGen -//import util.{ Position, NoPosition } import Flags._ import scala.util.control.ControlThrowable import scala.annotation.tailrec @@ -104,6 +102,9 @@ trait Types extends api.Types { self: SymbolTable => object undoLog { private type UndoLog = List[(TypeVar, TypeConstraint)] private[scala] var log: UndoLog = List() + + // register with the auto-clearing cache manager + perRunCaches.recordCache(this) /** Undo all changes to constraints to type variables upto `limit`. */ private def undoTo(limit: UndoLog) { @@ -123,6 +124,7 @@ trait Types extends api.Types { self: SymbolTable => log = Nil } + def size = log.size // `block` should not affect constraints on typevars def undo[T](block: => T): T = { @@ -149,7 +151,7 @@ trait Types extends api.Types { self: SymbolTable => * It makes use of the fact that these two operations depend only on the parents, * not on the refinement. */ - val intersectionWitness = new mutable.WeakHashMap[List[Type], WeakReference[Type]] + val intersectionWitness = perRunCaches.newWeakMap[List[Type], WeakReference[Type]]() //private object gen extends { // val global : Types.this.type = Types.this diff --git a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala index 3c40c5155..3293d9974 100644 --- a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala @@ -13,7 +13,8 @@ import java.lang.Double.longBitsToDouble import Flags._ import PickleFormat._ -import collection.mutable.{HashMap, ListBuffer} +import scala.collection.{ mutable, immutable } +import collection.mutable.ListBuffer import annotation.switch /** @author Martin Odersky @@ -57,7 +58,7 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ { private val entries = new Array[AnyRef](index.length) /** A map from symbols to their associated `decls` scopes */ - private val symScopes = new HashMap[Symbol, Scope] + private val symScopes = mutable.HashMap[Symbol, Scope]() //println("unpickled " + classRoot + ":" + classRoot.rawInfo + ", " + moduleRoot + ":" + moduleRoot.rawInfo);//debug diff --git a/src/compiler/scala/reflect/runtime/JavaConversions.scala b/src/compiler/scala/reflect/runtime/JavaConversions.scala index 0c7662c51..539e8486c 100644 --- a/src/compiler/scala/reflect/runtime/JavaConversions.scala +++ b/src/compiler/scala/reflect/runtime/JavaConversions.scala @@ -8,7 +8,7 @@ import java.lang.reflect.{ import internal.ByteCodecs import internal.ClassfileConstants._ import internal.pickling.UnPickler -import collection.mutable.HashMap +import scala.collection.{ mutable, immutable } trait JavaConversions { self: Universe => @@ -17,8 +17,8 @@ trait JavaConversions { self: Universe => } class TwoWayCache[J, S] { - val toScalaMap = new HashMap[J, S] - val toJavaMap = new HashMap[S, J] + val toScalaMap = mutable.HashMap[J, S]() + val toJavaMap = mutable.HashMap[S, J]() def toScala(key: J)(body: => S) = toScalaMap.getOrElseUpdate(key, body) def toJava(key: S)(body: => J) = toJavaMap.getOrElseUpdate(key, body) diff --git a/src/compiler/scala/tools/ant/ScalaBazaar.scala b/src/compiler/scala/tools/ant/ScalaBazaar.scala index a9c6e31c1..beb03ac87 100644 --- a/src/compiler/scala/tools/ant/ScalaBazaar.scala +++ b/src/compiler/scala/tools/ant/ScalaBazaar.scala @@ -11,7 +11,7 @@ package scala.tools.ant { import scala.collection.DefaultMap - import scala.collection.mutable.HashMap + import scala.collection.{ mutable, immutable } import java.io.{File, FileInputStream, FileOutputStream, FileWriter, StringReader} import java.net.URL @@ -78,7 +78,7 @@ package scala.tools.ant { /** The sets of files to include in the package */ private object fileSetsMap extends DefaultMap[String, List[FileSet]] { - private var content = new HashMap[String, List[FileSet]]() + private var content = new mutable.HashMap[String, List[FileSet]]() def get(key: String): Option[List[FileSet]] = content.get(key) override def size: Int = content.size def update(key: String, value: FileSet) { diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala index 1bad20e62..9bfb5aa87 100644 --- a/src/compiler/scala/tools/nsc/CompilationUnits.scala +++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala @@ -6,7 +6,8 @@ package scala.tools.nsc import util.{ FreshNameCreator,Position,NoPosition,SourceFile } -import scala.collection.mutable.{ LinkedHashSet, HashSet, HashMap, ListBuffer } +import scala.collection.mutable +import scala.collection.mutable.{ LinkedHashSet, ListBuffer } trait CompilationUnits { self: Global => @@ -37,15 +38,15 @@ trait CompilationUnits { self: Global => /** Note: depends now contains toplevel classes. * To get their sourcefiles, you need to dereference with .sourcefile */ - val depends = new HashSet[Symbol] + val depends = mutable.HashSet[Symbol]() /** so we can relink */ - val defined = new HashSet[Symbol] + val defined = mutable.HashSet[Symbol]() /** Synthetic definitions generated by namer, eliminated by typer. */ - val synthetics = new HashMap[Symbol, Tree] + val synthetics = mutable.HashMap[Symbol, Tree]() /** things to check at end of compilation unit */ val toCheck = new ListBuffer[() => Unit] @@ -92,8 +93,8 @@ trait CompilationUnits { self: Global => def clear() { fresh = null body = null - depends.clear - defined.clear + depends.clear() + defined.clear() } } } diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index 183c357ba..6c431836b 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -11,7 +11,7 @@ import reporters.Reporter import util.{Position, NoPosition} import util.DocStrings._ import scala.reflect.internal.Chars._ -import scala.collection.mutable.{HashMap, ListBuffer, StringBuilder} +import scala.collection.mutable /* * @author Martin Odersky @@ -22,7 +22,7 @@ trait DocComments { self: Global => def reporter: Reporter /** The raw doc comment map */ - val docComments = new HashMap[Symbol, DocComment] + val docComments = mutable.HashMap[Symbol, DocComment]() /** Associate comment with symbol `sym` at position `pos`. */ def docComment(sym: Symbol, docStr: String, pos: Position = NoPosition) = @@ -204,9 +204,7 @@ trait DocComments { self: Global => /** Maps symbols to the variable -> replacement maps that are defined * in their doc comments */ - private val defs = new HashMap[Symbol, Map[String, String]] { - override def default(key: Symbol) = Map() - } + private val defs = mutable.HashMap[Symbol, Map[String, String]]() withDefaultValue Map() /** Lookup definition of variable. * diff --git a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala index 2cfaf40f9..8878c82d8 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala @@ -8,7 +8,6 @@ package ast import reflect.internal.Flags._ import symtab._ -import util.HashSet /** This class ... * diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index fd4e0ca91..0ec2d40e9 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -14,8 +14,6 @@ import scala.reflect.internal.Flags.PARAMACCESSOR import scala.reflect.internal.Flags.PRESUPER import scala.reflect.internal.Flags.TRAIT -import util.HashSet - trait Trees extends reflect.internal.Trees { self: Global => // --- additional cases -------------------------------------------------------- @@ -267,7 +265,7 @@ trait Trees extends reflect.internal.Trees { self: Global => } private class ResetLocalAttrsTraverser extends ResetAttrsTraverser { - private val erasedSyms = HashSet[Symbol](8) + private val erasedSyms = util.HashSet[Symbol](8) override protected def isLocal(sym: Symbol) = erasedSyms(sym) override protected def resetDef(tree: Tree) { erasedSyms addEntry tree.symbol diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index 80aaded5d..1b86da5b7 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -7,7 +7,7 @@ package scala.tools.nsc package ast.parser import scala.collection.mutable -import mutable.{ Buffer, ArrayBuffer, ListBuffer, HashMap } +import mutable.{ Buffer, ArrayBuffer, ListBuffer } import scala.util.control.ControlThrowable import scala.tools.nsc.util.{SourceFile,CharArrayReader} import scala.xml.{ Text, TextBuffer } @@ -113,7 +113,7 @@ trait MarkupParsers { * | `{` scalablock `}` */ def xAttributes = { - val aMap = new HashMap[String, Tree]() + val aMap = mutable.HashMap[String, Tree]() while (isNameStart(ch)) { val start = curOffset diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index ecb25dd22..6e46427da 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -1796,7 +1796,7 @@ abstract class GenICode extends SubComponent { * to delay it any more: they will be used at some point. */ class DuplicateLabels(boundLabels: Set[Symbol]) extends Transformer { - val labels: mutable.Map[Symbol, Symbol] = new mutable.HashMap + val labels = perRunCaches.newMap[Symbol, Symbol]() var method: Symbol = _ var ctx: Context = _ @@ -1873,7 +1873,7 @@ abstract class GenICode extends SubComponent { var bb: BasicBlock = _ /** Map from label symbols to label objects. */ - var labels = mutable.HashMap[Symbol, Label]() + var labels = perRunCaches.newMap[Symbol, Label]() /** Current method definition. */ var defdef: DefDef = _ @@ -1977,7 +1977,7 @@ abstract class GenICode extends SubComponent { */ def enterMethod(m: IMethod, d: DefDef): Context = { val ctx1 = new Context(this) setMethod(m) - ctx1.labels = new mutable.HashMap() + ctx1.labels = mutable.HashMap() ctx1.method.code = new Code(m) ctx1.bb = ctx1.method.code.startBlock ctx1.defdef = d @@ -1991,7 +1991,7 @@ abstract class GenICode extends SubComponent { val block = method.code.newBlock handlers foreach (_ addCoveredBlock block) currentExceptionHandlers foreach (_ addBlock block) - block.varsInScope = new mutable.HashSet() ++= scope.varsInScope + block.varsInScope = mutable.HashSet() ++= scope.varsInScope new Context(this) setBasicBlock block } diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala index 6351694e1..96ad1d590 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala @@ -60,8 +60,8 @@ abstract class ICodeCheckers { var method: IMethod = _ var code: Code = _ - val in: mutable.Map[BasicBlock, TypeStack] = new mutable.HashMap() - val out: mutable.Map[BasicBlock, TypeStack] = new mutable.HashMap() + val in: mutable.Map[BasicBlock, TypeStack] = perRunCaches.newMap() + val out: mutable.Map[BasicBlock, TypeStack] = perRunCaches.newMap() val emptyStack = new TypeStack() { override def toString = "" } diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index 915fda559..a2fc27d7e 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -10,7 +10,6 @@ package icode import java.io.PrintWriter import scala.collection.{ mutable, immutable } -import mutable.{ HashMap, ListBuffer } import symtab.Flags.{ DEFERRED } trait ReferenceEquality { @@ -29,7 +28,7 @@ trait Members { self: ICodes => def this(method: IMethod) = this(method.symbol.simpleName.toString, method) /** The set of all blocks */ - val blocks: ListBuffer[BasicBlock] = new ListBuffer + val blocks = mutable.ListBuffer[BasicBlock]() /** The start block of the method */ var startBlock: BasicBlock = null diff --git a/src/compiler/scala/tools/nsc/backend/icode/Repository.scala b/src/compiler/scala/tools/nsc/backend/icode/Repository.scala index dd401c385..a7576785c 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Repository.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Repository.scala @@ -18,7 +18,7 @@ trait Repository { import global._ import icodes._ - val loaded: mutable.Map[Symbol, IClass] = new mutable.HashMap + val loaded: mutable.Map[Symbol, IClass] = perRunCaches.newMap() /** Is the given class available as icode? */ def available(sym: Symbol) = classes.contains(sym) || loaded.contains(sym) diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala index 11fab70a4..fc150ed80 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala @@ -3,11 +3,10 @@ * @author Martin Odersky */ - package scala.tools.nsc package backend.icode.analysis -import scala.collection.mutable.{ Map, HashMap } +import scala.collection.{ mutable, immutable } /** A modified copy-propagation like analysis. It * is augmented with a record-like value which is used @@ -30,7 +29,7 @@ abstract class CopyPropagation { abstract class Value { def isRecord = false } - case class Record(cls: Symbol, bindings: Map[Symbol, Value]) extends Value { + case class Record(cls: Symbol, bindings: mutable.Map[Symbol, Value]) extends Value { override def isRecord = true } /** The value of some location in memory. */ @@ -46,13 +45,13 @@ abstract class CopyPropagation { case object Unknown extends Value /** The bottom record. */ - object AllRecords extends Record(NoSymbol, new HashMap[Symbol, Value]) + object AllRecords extends Record(NoSymbol, mutable.HashMap[Symbol, Value]()) /** The lattice for this analysis. */ object copyLattice extends SemiLattice { - type Bindings = Map[Location, Value] + type Bindings = mutable.Map[Location, Value] - def emptyBinding = new HashMap[Location, Value]() + def emptyBinding = mutable.HashMap[Location, Value]() class State(val bindings: Bindings, var stack: List[Value]) { @@ -141,7 +140,7 @@ abstract class CopyPropagation { "\nBindings: " + bindings + "\nStack: " + stack; def dup: State = { - val b: Bindings = new HashMap() + val b: Bindings = mutable.HashMap() b ++= bindings new State(b, stack) } @@ -176,7 +175,7 @@ abstract class CopyPropagation { if (v1 == v2) v1 else Unknown } */ - val resBindings = new HashMap[Location, Value] + val resBindings = mutable.HashMap[Location, Value]() for ((k, v) <- a.bindings if b.bindings.isDefinedAt(k) && v == b.bindings(k)) resBindings += (k -> v); @@ -226,7 +225,7 @@ abstract class CopyPropagation { import opcodes._ - private def retain[A, B](map: Map[A, B])(p: (A, B) => Boolean) = { + private def retain[A, B](map: mutable.Map[A, B])(p: (A, B) => Boolean) = { for ((k, v) <- map ; if !p(k, v)) map -= k map } @@ -370,7 +369,7 @@ abstract class CopyPropagation { case NEW(kind) => val v1 = kind match { - case REFERENCE(cls) => Record(cls, new HashMap[Symbol, Value]) + case REFERENCE(cls) => Record(cls, mutable.HashMap[Symbol, Value]()) case _ => Unknown } out.stack = v1 :: out.stack @@ -525,10 +524,10 @@ abstract class CopyPropagation { * method has to find the correct mapping from fields to the order in which * they are passed on the stack. It works for primary constructors. */ - private def getBindingsForPrimaryCtor(in: copyLattice.State, ctor: Symbol): Map[Symbol, Value] = { + private def getBindingsForPrimaryCtor(in: copyLattice.State, ctor: Symbol): mutable.Map[Symbol, Value] = { val paramAccessors = ctor.owner.constrParamAccessors; var values = in.stack.take(1 + ctor.info.paramTypes.length).reverse.drop(1); - val bindings = new HashMap[Symbol, Value]; + val bindings = mutable.HashMap[Symbol, Value]() if (settings.debug.value) log("getBindings for: " + ctor + " acc: " + paramAccessors) diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala index 9ca414a57..549784695 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala @@ -37,8 +37,8 @@ abstract class Liveness { var method: IMethod = _ - val gen: mutable.Map[BasicBlock, Set[Local]] = new mutable.HashMap() - val kill: mutable.Map[BasicBlock, Set[Local]] = new mutable.HashMap() + val gen: mutable.Map[BasicBlock, Set[Local]] = perRunCaches.newMap() + val kill: mutable.Map[BasicBlock, Set[Local]] = perRunCaches.newMap() def init(m: IMethod) { this.method = m diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala index 9bbb59490..aa1a02d4a 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala @@ -3,12 +3,10 @@ * @author Iulian Dragos */ - package scala.tools.nsc package backend.jvm import scala.collection.{ mutable, immutable } - import ch.epfl.lamp.fjbg._ trait GenJVMUtil { @@ -34,16 +32,13 @@ trait GenJVMUtil { DOUBLE -> new JObjectType("java.lang.Double") ) - private val javaNameCache = { - val map = new mutable.WeakHashMap[Symbol, String]() - map ++= List( - NothingClass -> RuntimeNothingClass.fullName('/'), - RuntimeNothingClass -> RuntimeNothingClass.fullName('/'), - NullClass -> RuntimeNullClass.fullName('/'), - RuntimeNullClass -> RuntimeNullClass.fullName('/') - ) - map - } + // Don't put this in per run caches. + private val javaNameCache = new mutable.WeakHashMap[Symbol, String]() ++= List( + NothingClass -> RuntimeNothingClass.fullName('/'), + RuntimeNothingClass -> RuntimeNothingClass.fullName('/'), + NullClass -> RuntimeNullClass.fullName('/'), + RuntimeNullClass -> RuntimeNullClass.fullName('/') + ) /** This trait may be used by tools who need access to * utility methods like javaName and javaType. (for instance, diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index 2f1086208..0315b8221 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -9,8 +9,7 @@ package backend.msil import java.io.{File, IOException} import java.nio.{ByteBuffer, ByteOrder} - -import scala.collection.mutable.{Map, HashMap, HashSet, Stack, ListBuffer} +import scala.collection.{ mutable, immutable } import scala.tools.nsc.symtab._ import ch.epfl.lamp.compiler.msil.{Type => MsilType, _} @@ -132,7 +131,7 @@ abstract class GenMSIL extends SubComponent { // java instance methods that are mapped to static methods in .net // these will need to be called with OpCodes.Call (not Callvirt) - val dynToStatMapped: HashSet[Symbol] = new HashSet() + val dynToStatMapped = mutable.HashSet[Symbol]() initMappings() @@ -563,7 +562,7 @@ abstract class GenMSIL extends SubComponent { */ val msilLinearizer = new MSILLinearizer() - val labels: HashMap[BasicBlock, Label] = new HashMap() + val labels = mutable.HashMap[BasicBlock, Label]() /* when emitting .line, it's enough to include the full filename just once per method, thus reducing filesize. * this scheme relies on the fact that the entry block is emitted first. */ @@ -619,11 +618,11 @@ abstract class GenMSIL extends SubComponent { } // the try blocks starting at a certain BasicBlock - val beginExBlock = new HashMap[BasicBlock, List[ExceptionHandler]]() + val beginExBlock = mutable.HashMap[BasicBlock, List[ExceptionHandler]]() // the catch blocks starting / endling at a certain BasicBlock - val beginCatchBlock = new HashMap[BasicBlock, ExceptionHandler]() - val endExBlock = new HashMap[BasicBlock, List[ExceptionHandler]]() + val beginCatchBlock = mutable.HashMap[BasicBlock, ExceptionHandler]() + val endExBlock = mutable.HashMap[BasicBlock, List[ExceptionHandler]]() /** When emitting the code (genBlock), the number of currently active try / catch * blocks. When seeing a `RETURN` inside a try / catch, we need to @@ -631,7 +630,7 @@ abstract class GenMSIL extends SubComponent { * - emit `Leave handlerReturnLabel` instead of the Return * - emit code at the end: load the local and return its value */ - var currentHandlers = new Stack[ExceptionHandler] + var currentHandlers = new mutable.Stack[ExceptionHandler] // The IMethod the Local/Label/Kind below belong to var handlerReturnMethod: IMethod = _ // Stores the result when returning inside an exception block @@ -658,11 +657,11 @@ abstract class GenMSIL extends SubComponent { * So for every finalizer, we have a label which marks the place of the `endfinally`, * nested try/catch blocks will leave there. */ - val endFinallyLabels = new HashMap[ExceptionHandler, Label]() + val endFinallyLabels = mutable.HashMap[ExceptionHandler, Label]() /** Computes which blocks are the beginning / end of a try or catch block */ private def computeExceptionMaps(blocks: List[BasicBlock], m: IMethod): List[BasicBlock] = { - val visitedBlocks = new HashSet[BasicBlock]() + val visitedBlocks = new mutable.HashSet[BasicBlock]() // handlers which have not been introduced so far var openHandlers = m.exh @@ -689,11 +688,11 @@ abstract class GenMSIL extends SubComponent { // Stack of nested try blocks. Each bloc has a List of ExceptionHandler (multiple // catch statements). Example *1*: Stack(List(h2, h3), List(h1)) - val currentTryHandlers = new Stack[List[ExceptionHandler]]() + val currentTryHandlers = new mutable.Stack[List[ExceptionHandler]]() // Stack of nested catch blocks. The head of the list is the current catch block. The // tail is all following catch blocks. Example *2*: Stack(List(h3), List(h4, h5)) - val currentCatchHandlers = new Stack[List[ExceptionHandler]]() + val currentCatchHandlers = new mutable.Stack[List[ExceptionHandler]]() for (b <- blocks) { @@ -752,7 +751,7 @@ abstract class GenMSIL extends SubComponent { // (checked by the assertions below) val sizes = newHandlersBySize.keys.toList.sortWith(_ > _) - val beginHandlers = new ListBuffer[ExceptionHandler] + val beginHandlers = new mutable.ListBuffer[ExceptionHandler] for (s <- sizes) { val sHandlers = newHandlersBySize(s) for (h <- sHandlers) { @@ -1724,13 +1723,13 @@ abstract class GenMSIL extends SubComponent { var entryPoint: Symbol = _ - val notInitializedModules: HashSet[Symbol] = new HashSet() + val notInitializedModules = mutable.HashSet[Symbol]() // TODO: create fields also in def createType, and not in genClass, // add a getField method (it only works as it is because fields never // accessed from outside a class) - val localBuilders: HashMap[Local, LocalBuilder] = new HashMap() + val localBuilders = mutable.HashMap[Local, LocalBuilder]() private[GenMSIL] def findEntryPoint(cls: IClass) { diff --git a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala index 256941396..b7c6c2d41 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala @@ -3,11 +3,9 @@ * @author Iulian Dragos */ - package scala.tools.nsc package backend.opt -import scala.collection.mutable.{Map, HashMap} import scala.tools.nsc.backend.icode.analysis.LubException import scala.tools.nsc.symtab._ diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala index 19657e498..4bae9fb9b 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala @@ -59,7 +59,7 @@ abstract class DeadCodeElimination extends SubComponent { val worklist: mutable.Set[(BasicBlock, Int)] = new mutable.LinkedHashSet /** what instructions have been marked as useful? */ - val useful: mutable.Map[BasicBlock, mutable.BitSet] = new mutable.HashMap + val useful: mutable.Map[BasicBlock, mutable.BitSet] = perRunCaches.newMap() /** what local variables have been accessed at least once? */ var accessedLocals: List[Local] = Nil @@ -68,7 +68,7 @@ abstract class DeadCodeElimination extends SubComponent { var method: IMethod = _ /** Map instructions who have a drop on some control path, to that DROP instruction. */ - val dropOf: mutable.Map[(BasicBlock, Int), (BasicBlock, Int)] = new mutable.HashMap() + val dropOf: mutable.Map[(BasicBlock, Int), (BasicBlock, Int)] = perRunCaches.newMap() def dieCodeDie(m: IMethod) { if (m.code ne null) { diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index d4cf2ccdb..7640dd99c 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -78,12 +78,12 @@ abstract class Inliners extends SubComponent { val Private, Protected, Public = Value /** Cache whether a method calls private members. */ - val usesNonPublics: mutable.Map[IMethod, Value] = new mutable.HashMap + val usesNonPublics: mutable.Map[IMethod, Value] = perRunCaches.newMap() } import NonPublicRefs._ /* fresh name counter */ - val fresh = new mutable.HashMap[String, Int] withDefaultValue 0 + val fresh = perRunCaches.newMap[String, Int]() withDefaultValue 0 def freshName(s: String) = { fresh(s) += 1 s + fresh(s) @@ -108,9 +108,7 @@ abstract class Inliners extends SubComponent { tfa.stat = global.opt.printStats // how many times have we already inlined this method here? - private val inlinedMethodCount: mutable.Map[Symbol, Int] = new mutable.HashMap[Symbol, Int] { - override def default(k: Symbol) = 0 - } + private val inlinedMethodCount = perRunCaches.newMap[Symbol, Int]() withDefaultValue 0 def analyzeMethod(m: IMethod): Unit = { var sizeBeforeInlining = if (m.code ne null) m.code.blockCount else 0 @@ -367,7 +365,7 @@ abstract class Inliners extends SubComponent { case x => newLocal("$retVal", x) } - val inlinedLocals: mutable.Map[Local, Local] = new mutable.HashMap + val inlinedLocals = perRunCaches.newMap[Local, Local]() /** Add a new block in the current context. */ def newBlock() = { diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index de110e40c..8f6e277e8 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -6,10 +6,9 @@ package scala.tools.nsc package interactive import java.io.{ PrintWriter, StringWriter, FileReader, FileWriter } -import collection.mutable.{ArrayBuffer, ListBuffer, SynchronizedBuffer, HashMap} - import scala.collection.mutable -import mutable.{LinkedHashMap, SynchronizedMap,LinkedHashSet, SynchronizedSet} +import collection.mutable.{ ArrayBuffer, ListBuffer, SynchronizedBuffer } +import mutable.{LinkedHashMap, SynchronizedMap, SynchronizedSet} import scala.concurrent.SyncVar import scala.util.control.ControlThrowable import scala.tools.nsc.io.{ AbstractFile, LogReplay, Logger, NullLogger, Replayer } diff --git a/src/compiler/scala/tools/nsc/interpreter/Phased.scala b/src/compiler/scala/tools/nsc/interpreter/Phased.scala index b85d0d5bf..b0c0bed3b 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Phased.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Phased.scala @@ -7,7 +7,6 @@ package scala.tools.nsc package interpreter import scala.collection.{ mutable, immutable } -import immutable.SortedMap /** Mix this into an object and use it as a phasing * swiss army knife. @@ -66,8 +65,7 @@ trait Phased { try parseInternal(str) catch { case _: Exception => NoPhaseName } - def apply[T](body: => T): SortedMap[PhaseName, T] = - SortedMap[PhaseName, T](atMap(PhaseName.all)(body): _*) + def apply[T](body: => T) = immutable.SortedMap[PhaseName, T](atMap(PhaseName.all)(body): _*) def atCurrent[T](body: => T): T = atPhase(get)(body) def multi[T](body: => T): Seq[T] = multi map (ph => at(ph)(body)) diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 47de1df0b..f5b889a77 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -8,12 +8,11 @@ package scala.tools.nsc package matching import PartialFunction._ -import scala.collection.{ mutable, immutable } +import scala.collection.{ mutable } import util.Position import transform.ExplicitOuter import symtab.Flags import mutable.ListBuffer -import immutable.IntMap import annotation.elidable trait ParallelMatching extends ast.TreeDSL @@ -43,7 +42,7 @@ trait ParallelMatching extends ast.TreeDSL lazy val (rows, targets) = expand(roots, cases).unzip lazy val expansion: Rep = make(roots, rows) - private val shortCuts = mutable.HashMap[Int, Symbol]() + private val shortCuts = perRunCaches.newMap[Int, Symbol]() final def createShortCut(theLabel: Symbol): Int = { val key = shortCuts.size + 1 diff --git a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala index c071956e9..a56b64b17 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala @@ -7,7 +7,6 @@ package scala.tools.nsc package matching import transform.ExplicitOuter -import collection.immutable.TreeMap import PartialFunction._ trait PatternBindings extends ast.TreeDSL diff --git a/src/compiler/scala/tools/nsc/matching/Patterns.scala b/src/compiler/scala/tools/nsc/matching/Patterns.scala index bc2534948..b4e1068f7 100644 --- a/src/compiler/scala/tools/nsc/matching/Patterns.scala +++ b/src/compiler/scala/tools/nsc/matching/Patterns.scala @@ -271,8 +271,7 @@ trait Patterns extends ast.TreeDSL { object Pattern { // a small tree -> pattern cache - private val cache = new collection.mutable.HashMap[Tree, Pattern] - def clear() = cache.clear() + private val cache = perRunCaches.newMap[Tree, Pattern]() def apply(tree: Tree): Pattern = { if (cache contains tree) diff --git a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala index 345368075..72a72b2ed 100644 --- a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package reporters -import scala.collection.mutable.HashMap +import scala.collection.mutable import scala.tools.nsc.Settings import scala.tools.nsc.util.Position @@ -18,7 +18,7 @@ abstract class AbstractReporter extends Reporter { def display(pos: Position, msg: String, severity: Severity): Unit def displayPrompt(): Unit - private val positions = new HashMap[Position, Severity] + private val positions = new mutable.HashMap[Position, Severity] override def reset() { super.reset diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index d3074509e..e3dcd3636 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -10,7 +10,7 @@ package settings import annotation.elidable import scala.tools.util.PathResolver.Defaults -import scala.collection.mutable.HashSet +import scala.collection.mutable trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings @@ -20,7 +20,7 @@ trait ScalaSettings extends AbsScalaSettings import Defaults.scalaUserClassPath /** Set of settings */ - protected lazy val allSettings = HashSet[Setting]() + protected lazy val allSettings = mutable.HashSet[Setting]() /** Disable a setting */ def disable(s: Setting) = allSettings -= s diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala index 58b2000f1..ed989fef1 100644 --- a/src/compiler/scala/tools/nsc/settings/Warnings.scala +++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala @@ -7,10 +7,6 @@ package scala.tools package nsc package settings -import annotation.elidable -import scala.tools.util.PathResolver.Defaults -import scala.collection.mutable.HashSet - /** Settings influencing the printing of warnings. */ trait Warnings { diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 9ec6904d1..3682b0bff 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -664,8 +664,8 @@ abstract class ICodeReader extends ClassfileParser { class LinearCode { var instrs: ListBuffer[(Int, Instruction)] = new ListBuffer - var jmpTargets: mutable.Set[Int] = new mutable.HashSet[Int] - var locals: mutable.Map[Int, List[(Local, TypeKind)]] = new mutable.HashMap() + var jmpTargets: mutable.Set[Int] = perRunCaches.newSet[Int]() + var locals: mutable.Map[Int, List[(Local, TypeKind)]] = perRunCaches.newMap() var containsDUPX = false var containsNEW = false diff --git a/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala b/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala index 366a892b4..c811f95f9 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala @@ -10,10 +10,8 @@ package clr import java.io.File import java.util.{Comparator, StringTokenizer} import scala.util.Sorting - import ch.epfl.lamp.compiler.msil._ - -import scala.collection.mutable.{ListBuffer, Map, HashMap, Set, HashSet} +import scala.collection.{ mutable, immutable } import scala.tools.nsc.util.{Position, NoPosition} /** @@ -56,13 +54,13 @@ abstract class CLRTypes { var DELEGATE_COMBINE: MethodInfo = _ var DELEGATE_REMOVE: MethodInfo = _ - val types: Map[Symbol,Type] = new HashMap - val constructors: Map[Symbol,ConstructorInfo] = new HashMap - val methods: Map[Symbol,MethodInfo] = new HashMap - val fields: Map[Symbol, FieldInfo] = new HashMap - val sym2type: Map[Type,Symbol] = new HashMap - val addressOfViews: HashSet[Symbol] = new HashSet[Symbol] - val mdgptrcls4clssym: Map[ /*cls*/ Symbol, /*cls*/ Symbol] = new HashMap + val types: mutable.Map[Symbol,Type] = new mutable.HashMap + val constructors: mutable.Map[Symbol,ConstructorInfo] = new mutable.HashMap + val methods: mutable.Map[Symbol,MethodInfo] = new mutable.HashMap + val fields: mutable.Map[Symbol, FieldInfo] = new mutable.HashMap + val sym2type: mutable.Map[Type,Symbol] = new mutable.HashMap + val addressOfViews = new mutable.HashSet[Symbol] + val mdgptrcls4clssym: mutable.Map[ /*cls*/ Symbol, /*cls*/ Symbol] = new mutable.HashMap def isAddressOf(msym : Symbol) = addressOfViews.contains(msym) diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala index 16991c54b..1a3fabdda 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala @@ -2,16 +2,13 @@ * Copyright 2004-2011 LAMP/EPFL */ - package scala.tools.nsc package symtab package clr import java.io.IOException - import ch.epfl.lamp.compiler.msil.{Type => MSILType, Attribute => MSILAttribute, _} - -import scala.collection.mutable.{HashMap, HashSet} +import scala.collection.{ mutable, immutable } import scala.reflect.internal.pickling.UnPickler import ch.epfl.lamp.compiler.msil.Type.TMVarUsage @@ -295,7 +292,7 @@ abstract class TypeParser { createMethod(constr); // initially also contains getters and setters of properties. - val methodsSet = new HashSet[MethodInfo](); + val methodsSet = new mutable.HashSet[MethodInfo](); methodsSet ++= typ.getMethods(); for (prop <- typ.getProperties) { diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index 2ca9fe884..673a3bc91 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -39,13 +39,13 @@ abstract class AddInterfaces extends InfoTransform { /** A lazily constructed map that associates every non-interface trait with * its implementation class. */ - private val implClassMap = new mutable.HashMap[Symbol, Symbol] + private val implClassMap = perRunCaches.newMap[Symbol, Symbol]() /** A lazily constructed map that associates every concrete method in a non-interface * trait that's currently compiled with its corresponding method in the trait's * implementation class. */ - private val implMethodMap = new mutable.HashMap[Symbol, Symbol] + private val implMethodMap = perRunCaches.newMap[Symbol, Symbol]() override def newPhase(prev: scala.tools.nsc.Phase): StdPhase = { implClassMap.clear() diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 4c9f0d551..8daed32d4 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -529,9 +529,5 @@ abstract class ExplicitOuter extends InfoTransform class Phase(prev: scala.tools.nsc.Phase) extends super.Phase(prev) { override val checkable = false - override def run() { - super.run - Pattern.clear() // clear the cache - } } } diff --git a/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala b/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala index f0a099b66..960884788 100644 --- a/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala +++ b/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package transform -import collection.mutable.HashMap +import scala.collection.mutable import symtab.Flags._ import util.HashSet import annotation.tailrec @@ -99,7 +99,7 @@ abstract class OverridingPairs { /** A map from baseclasses of to ints, with smaller ints meaning lower in * linearization order. */ - private val index = new HashMap[Symbol, Int] + private val index = new mutable.HashMap[Symbol, Int] // Note: overridingPairs can be called at odd instances by the Eclipse plugin // Soemtimes symbols are not yet defined and we get missing keys. diff --git a/src/compiler/scala/tools/nsc/transform/Reifiers.scala b/src/compiler/scala/tools/nsc/transform/Reifiers.scala index 966771427..87501baac 100644 --- a/src/compiler/scala/tools/nsc/transform/Reifiers.scala +++ b/src/compiler/scala/tools/nsc/transform/Reifiers.scala @@ -3,7 +3,7 @@ package transform import scala.tools.nsc.symtab.SymbolTable import scala.reflect -import collection.mutable.HashMap +import collection.mutable /** Functions to reify (and un-reify) symbols, types, and trees. * These can be used with only a symbol table; they do not @@ -184,8 +184,8 @@ trait Reifiers { case class FreeValue(tree: Tree) extends reflect.Tree - class ReifyEnvironment extends HashMap[Symbol, reflect.Symbol] { - var targets = new HashMap[String, Option[reflect.LabelSymbol]]() + class ReifyEnvironment extends mutable.HashMap[Symbol, reflect.Symbol] { + var targets = new mutable.HashMap[String, Option[reflect.LabelSymbol]]() def addTarget(name: String, target: reflect.LabelSymbol): Unit = targets.update(name, Some(target)) def getTarget(name: String): Option[reflect.LabelSymbol] = diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 1a9867688..7a0396ca2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -13,7 +13,7 @@ package typechecker import annotation.tailrec import scala.collection.{ mutable, immutable } -import mutable.{ HashMap, LinkedHashMap, ListBuffer } +import mutable.{ LinkedHashMap, ListBuffer } import scala.util.matching.Regex import symtab.Flags._ import util.Statistics._ @@ -83,7 +83,7 @@ trait Implicits { private type InfoMap = LinkedHashMap[Symbol, List[ImplicitInfo]] // A map from class symbols to their associated implicits private val implicitsCache = new LinkedHashMap[Type, Infoss] private val infoMapCache = new LinkedHashMap[Symbol, InfoMap] - private val improvesCache = new HashMap[(ImplicitInfo, ImplicitInfo), Boolean] + private val improvesCache = perRunCaches.newMap[(ImplicitInfo, ImplicitInfo), Boolean]() def resetImplicits() { implicitsCache.clear() @@ -175,7 +175,7 @@ trait Implicits { /** An extractor for types of the form ? { name: ? } */ object HasMember { - private val hasMemberCache = new mutable.HashMap[Name, Type] + private val hasMemberCache = perRunCaches.newMap[Name, Type]() def apply(name: Name): Type = hasMemberCache.getOrElseUpdate(name, memberWildcardType(name, WildcardType)) def unapply(pt: Type): Option[Name] = pt match { case RefinedType(List(WildcardType), decls) => diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 0e3951b8a..9c6f61d54 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -6,9 +6,8 @@ package scala.tools.nsc package typechecker -import scala.collection.mutable.{HashMap, WeakHashMap} +import scala.collection.mutable import scala.ref.WeakReference -import symtab.Flags import symtab.Flags._ import scala.tools.nsc.io.AbstractFile @@ -52,7 +51,7 @@ trait Namers { self: Analyzer => // is stored in this map. The map is cleared lazily, i.e. when the new symbol // is created with the same name, the old one (if present) is wiped out, or the // entry is deleted when it is used and no longer needed. - private val caseClassOfModuleClass = new WeakHashMap[Symbol, WeakReference[ClassDef]] + private val caseClassOfModuleClass = perRunCaches.newWeakMap[Symbol, WeakReference[ClassDef]]() // Default getters of constructors are added to the companion object in the // typeCompleter of the constructor (methodSig). To compute the signature, @@ -60,7 +59,7 @@ trait Namers { self: Analyzer => // object, we need the templateNamer of that module class. // This map is extended during naming of classes, the Namer is added in when // it's available, i.e. in the type completer (templateSig) of the module class. - private[typechecker] val classAndNamerOfModule = new HashMap[Symbol, (ClassDef, Namer)] + private[typechecker] val classAndNamerOfModule = perRunCaches.newMap[Symbol, (ClassDef, Namer)]() def resetNamer() { classAndNamerOfModule.clear @@ -548,7 +547,7 @@ trait Namers { self: Analyzer => // --- Lazy Type Assignment -------------------------------------------------- def typeCompleter(tree: Tree) = mkTypeCompleter(tree) { sym => - if (settings.debug.value) log("defining " + sym + Flags.flagsToString(sym.flags)+sym.locationString) + if (settings.debug.value) log("defining " + sym + flagsToString(sym.flags)+sym.locationString) val tp = typeSig(tree) tp match { case TypeBounds(lo, hi) => @@ -1323,10 +1322,10 @@ trait Namers { self: Analyzer => if (sym.hasFlag(flag1) && sym.hasFlag(flag2)) context.error(sym.pos, if (flag1 == DEFERRED) - "abstract member may not have " + Flags.flagsToString(flag2) + " modifier"; + "abstract member may not have " + flagsToString(flag2) + " modifier"; else "illegal combination of modifiers: " + - Flags.flagsToString(flag1) + " and " + Flags.flagsToString(flag2) + + flagsToString(flag1) + " and " + flagsToString(flag2) + " for: " + sym); } diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index d47a9dc68..050b9e402 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -7,9 +7,7 @@ package scala.tools.nsc package typechecker import symtab.Flags._ - -import scala.collection.mutable.{ListBuffer, WeakHashMap} -import scala.collection.immutable.Set +import scala.collection.mutable /** * @author Lukas Rytz @@ -20,9 +18,8 @@ trait NamesDefaults { self: Analyzer => import global._ import definitions._ - val defaultParametersOfMethod = new WeakHashMap[Symbol, Set[Symbol]] { - override def default(key: Symbol) = Set() - } + val defaultParametersOfMethod = + perRunCaches.newWeakMap[Symbol, Set[Symbol]]() withDefaultValue Set() case class NamedApplyInfo(qual: Option[Tree], targs: List[Tree], vargss: List[List[Tree]], blockTyper: Typer) @@ -45,7 +42,7 @@ trait NamesDefaults { self: Analyzer => /** @param pos maps indicies from new to old (!) */ def reorderArgsInv[T: ClassManifest](args: List[T], pos: Int => Int): List[T] = { val argsArray = args.toArray - val res = new ListBuffer[T] + val res = new mutable.ListBuffer[T] for (i <- 0 until argsArray.length) res += argsArray(pos(i)) res.toList diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 07faa2d8f..57e2af35c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -862,7 +862,7 @@ abstract class RefChecks extends InfoTransform { } private var currentLevel: LevelInfo = null - private val symIndex = new mutable.HashMap[Symbol, Int] + private val symIndex = perRunCaches.newMap[Symbol, Int]() private def pushLevel() { currentLevel = new LevelInfo(currentLevel) diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index 205bccd8a..6589b5600 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -8,7 +8,7 @@ package typechecker import scala.tools.nsc.symtab.Flags._ import scala.collection.mutable -import mutable.{ HashMap, HashSet, ListBuffer } +import mutable.ListBuffer import util.returning abstract class TreeCheckers extends Analyzer { @@ -33,12 +33,13 @@ abstract class TreeCheckers extends Analyzer { /** This is a work in progress, don't take it too seriously. */ object SymbolTracker extends Traverser { - type PhaseMap = HashMap[Symbol, List[Tree]] - val maps: ListBuffer[(Phase, PhaseMap)] = ListBuffer() + type PhaseMap = mutable.HashMap[Symbol, List[Tree]] + + val maps = ListBuffer[(Phase, PhaseMap)]() def prev = maps.init.last._2 def latest = maps.last._2 - val defSyms = new HashMap[Symbol, List[DefTree]] - val newSyms = new HashSet[Symbol] + val defSyms = mutable.HashMap[Symbol, List[DefTree]]() + val newSyms = mutable.HashSet[Symbol]() val movedMsgs = new ListBuffer[String] def sortedNewSyms = newSyms.toList.distinct sortBy (_.name.toString) @@ -110,7 +111,7 @@ abstract class TreeCheckers extends Analyzer { } } - lazy val tpeOfTree = new HashMap[Tree, Type] + lazy val tpeOfTree = mutable.HashMap[Tree, Type]() def posstr(p: Position) = try p.source.path + ":" + p.line diff --git a/src/compiler/scala/tools/nsc/util/DocStrings.scala b/src/compiler/scala/tools/nsc/util/DocStrings.scala index 36b0c3258..5b168a3dc 100755 --- a/src/compiler/scala/tools/nsc/util/DocStrings.scala +++ b/src/compiler/scala/tools/nsc/util/DocStrings.scala @@ -3,12 +3,10 @@ * @author Martin Odersky */ - package scala.tools.nsc package util import scala.reflect.internal.Chars._ -import scala.collection.mutable.{HashMap, ListBuffer, StringBuilder} /** Utilitity methods for doc comment strings */ diff --git a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala index d45f84b84..facde69b5 100644 --- a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala +++ b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package util -import scala.collection.mutable.HashMap +import scala.collection.mutable trait FreshNameCreator { /** Do not call before after type checking ends. @@ -24,7 +24,7 @@ trait FreshNameCreator { object FreshNameCreator { class Default extends FreshNameCreator { protected var counter = 0 - protected val counters = new HashMap[String, Int] withDefaultValue 0 + protected val counters = mutable.HashMap[String, Int]() withDefaultValue 0 /** * Create a fresh name with the given prefix. It is guaranteed diff --git a/src/compiler/scala/tools/nsc/util/MsilClassPath.scala b/src/compiler/scala/tools/nsc/util/MsilClassPath.scala index 5b692f22d..2d8cd727b 100644 --- a/src/compiler/scala/tools/nsc/util/MsilClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/MsilClassPath.scala @@ -13,9 +13,8 @@ import java.net.URL import java.util.StringTokenizer import scala.util.Sorting -import scala.collection.mutable.{ ListBuffer, HashSet => MutHashSet } +import scala.collection.mutable import scala.tools.nsc.io.AbstractFile - import ch.epfl.lamp.compiler.msil.{ Type => MSILType, Assembly } import ClassPath.{ ClassPathContext, isTraitImplementation } @@ -54,8 +53,8 @@ object MsilClassPath { private def assembleEntries(ext: String, user: String, source: String, context: MsilContext): List[ClassPath[MSILType]] = { import ClassPath._ - val etr = new ListBuffer[ClassPath[MSILType]] - val names = new MutHashSet[String] + val etr = new mutable.ListBuffer[ClassPath[MSILType]] + val names = new mutable.HashSet[String] // 1. Assemblies from -Xassem-extdirs for (dirName <- expandPath(ext, expandStar = false)) { @@ -127,7 +126,7 @@ class AssemblyClassPath(types: Array[MSILType], namespace: String, val context: } lazy val classes = { - val cls = new ListBuffer[ClassRep] + val cls = new mutable.ListBuffer[ClassRep] var i = first while (i < types.length && types(i).Namespace.startsWith(namespace)) { // CLRTypes used to exclude java.lang.Object and java.lang.String (no idea why..) @@ -139,7 +138,7 @@ class AssemblyClassPath(types: Array[MSILType], namespace: String, val context: } lazy val packages = { - val nsSet = new MutHashSet[String] + val nsSet = new mutable.HashSet[String] var i = first while (i < types.length && types(i).Namespace.startsWith(namespace)) { val subns = types(i).Namespace diff --git a/src/compiler/scala/tools/nsc/util/MultiHashMap.scala b/src/compiler/scala/tools/nsc/util/MultiHashMap.scala index 13902597f..47c48c14f 100644 --- a/src/compiler/scala/tools/nsc/util/MultiHashMap.scala +++ b/src/compiler/scala/tools/nsc/util/MultiHashMap.scala @@ -1,10 +1,9 @@ package scala.tools.nsc.util -import collection.mutable.HashMap -import collection.immutable +import scala.collection.{ mutable, immutable } /** A hashmap with set-valued values, and an empty set as default value */ -class MultiHashMap[K, V] extends HashMap[K, immutable.Set[V]] { +class MultiHashMap[K, V] extends mutable.HashMap[K, immutable.Set[V]] { override def default(key: K): immutable.Set[V] = Set() } diff --git a/src/compiler/scala/tools/nsc/util/WorkScheduler.scala b/src/compiler/scala/tools/nsc/util/WorkScheduler.scala index 0eb6de253..5099f3f16 100644 --- a/src/compiler/scala/tools/nsc/util/WorkScheduler.scala +++ b/src/compiler/scala/tools/nsc/util/WorkScheduler.scala @@ -1,15 +1,15 @@ package scala.tools.nsc package util -import scala.collection.mutable.Queue +import scala.collection.mutable class WorkScheduler { type Action = () => Unit - private var todo = new Queue[Action] - private var throwables = new Queue[Throwable] - private var interruptReqs = new Queue[InterruptReq] + private var todo = new mutable.Queue[Action] + private var throwables = new mutable.Queue[Throwable] + private var interruptReqs = new mutable.Queue[InterruptReq] /** Called from server: block until one of todo list, throwables or interruptReqs is nonempty */ def waitForMoreWork() = synchronized { diff --git a/src/compiler/scala/tools/util/AbstractTimer.scala b/src/compiler/scala/tools/util/AbstractTimer.scala index 219b5d212..210a1ee53 100644 --- a/src/compiler/scala/tools/util/AbstractTimer.scala +++ b/src/compiler/scala/tools/util/AbstractTimer.scala @@ -10,7 +10,7 @@ package scala.tools.util import compat.Platform.currentTime -import scala.collection.mutable.Stack +import scala.collection.mutable /** * This abstract class implements the collection of timings. How the @@ -25,7 +25,7 @@ abstract class AbstractTimer { // Private Fields /** A stack for maintaining start times */ - private val starts = new Stack[Long]() + private val starts = new mutable.Stack[Long]() //######################################################################## // Public Methods diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala index a805eee09..c339d2bd7 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala @@ -4,10 +4,6 @@ package scala.tools.selectivecps import scala.tools.nsc.Global -import scala.collection.mutable.{Map, HashMap} - -import java.io.{StringWriter, PrintWriter} - abstract class CPSAnnotationChecker extends CPSUtils { val global: Global import global._ diff --git a/src/detach/library/scala/runtime/remoting/RemoteGC.scala b/src/detach/library/scala/runtime/remoting/RemoteGC.scala index 30a9b6ba0..b6915b5e6 100644 --- a/src/detach/library/scala/runtime/remoting/RemoteGC.scala +++ b/src/detach/library/scala/runtime/remoting/RemoteGC.scala @@ -13,8 +13,7 @@ package scala.runtime.remoting import java.lang.ref.{Reference, WeakReference, ReferenceQueue} import java.rmi.{NoSuchObjectException, Remote} import java.rmi.server.UnicastRemoteObject - -import scala.collection.mutable.HashSet +import scala.collection.mutable /** * @@ -25,7 +24,7 @@ import scala.collection.mutable.HashSet private [runtime] class RemoteGC { private val refQueue = new ReferenceQueue[Remote] - private val refSet = new HashSet[Reference[T] forSome { type T <: Remote }] + private val refSet = new mutable.HashSet[Reference[T] forSome { type T <: Remote }] private var liveRefs = 0 diff --git a/src/detach/plugin/scala/tools/detach/Detach.scala b/src/detach/plugin/scala/tools/detach/Detach.scala index b0df38cdc..90d829c43 100644 --- a/src/detach/plugin/scala/tools/detach/Detach.scala +++ b/src/detach/plugin/scala/tools/detach/Detach.scala @@ -5,9 +5,8 @@ package scala.tools.detach -import scala.collection.immutable -import scala.collection.mutable.{HashMap, HashSet, ListBuffer} - +import scala.collection.{ mutable, immutable } +import scala.collection.mutable.ListBuffer import scala.tools.nsc._ import scala.tools.nsc.plugins.PluginComponent import scala.tools.nsc.symtab.Flags._ @@ -116,23 +115,23 @@ abstract class Detach extends PluginComponent private val remoteRefClass = immutable.HashMap(elems(""): _*) private val remoteRefImpl = immutable.HashMap(elems("Impl"): _*) - private val proxyInterfaceDefs = new HashMap[Symbol/*owner*/, ListBuffer[Tree]] - private val detachedClosureApply = new HashMap[Tree, Apply] + private val proxyInterfaceDefs = new mutable.HashMap[Symbol/*owner*/, ListBuffer[Tree]] + private val detachedClosureApply = new mutable.HashMap[Tree, Apply] - private type SymSet = HashSet[Symbol] - private val capturedObjects = new HashMap[Symbol/*clazz*/, SymSet] - private val capturedFuncs = new HashMap[Symbol/*clazz*/, SymSet] - private val capturedCallers = new HashMap[Symbol/*clazz*/, SymSet] - private val capturedThisClass = new HashMap[Symbol, Symbol] + private type SymSet = mutable.HashSet[Symbol] + private val capturedObjects = new mutable.HashMap[Symbol/*clazz*/, SymSet] + private val capturedFuncs = new mutable.HashMap[Symbol/*clazz*/, SymSet] + private val capturedCallers = new mutable.HashMap[Symbol/*clazz*/, SymSet] + private val capturedThisClass = new mutable.HashMap[Symbol, Symbol] - private val proxies = new HashMap[ + private val proxies = new mutable.HashMap[ Symbol, //clazz - (Symbol, Symbol, HashMap[Symbol, Symbol]) //iface, impl, accessor map + (Symbol, Symbol, mutable.HashMap[Symbol, Symbol]) //iface, impl, accessor map ] def toInterface(clazz: Symbol) = proxies(clazz)._1 - private val classdefs = new HashMap[Symbol/*clazz*/, ClassDef] + private val classdefs = new mutable.HashMap[Symbol/*clazz*/, ClassDef] // detachedClosure gathers class definitions containing a "detach" apply - private val detachedClosure = new HashMap[Symbol/*clazz*/, ClassDef] + private val detachedClosure = new mutable.HashMap[Symbol/*clazz*/, ClassDef] /**

* The method freeObjTraverser.traverse is invoked @@ -146,9 +145,9 @@ abstract class Detach extends PluginComponent *

*/ private val freeObjTraverser = new Traverser { - def symSet(f: HashMap[Symbol, SymSet], sym: Symbol): SymSet = f.get(sym) match { + def symSet(f: mutable.HashMap[Symbol, SymSet], sym: Symbol): SymSet = f.get(sym) match { case Some(ss) => ss - case None => val ss = new HashSet[Symbol]; f(sym) = ss; ss + case None => val ss = new mutable.HashSet[Symbol]; f(sym) = ss; ss } def getClosureApply(tree: Tree): Apply = tree match { case Block(_, expr) => getClosureApply(expr) @@ -255,7 +254,7 @@ abstract class Detach extends PluginComponent println("\nTreeOuterSubstituter:"+ "\n\tfrom="+from.mkString(",")+ "\n\tto="+to.mkString(",")) - val substMap = new HashMap[Symbol, Symbol] + val substMap = new mutable.HashMap[Symbol, Symbol] override def traverse(tree: Tree) { def subst(from: List[Symbol], to: List[Symbol]) { if (!from.isEmpty) @@ -328,7 +327,7 @@ abstract class Detach extends PluginComponent } subst(sym.tpe) } - val map = new HashMap[Symbol, Symbol] + val map = new mutable.HashMap[Symbol, Symbol] override def traverse(tree: Tree) { if (tree.hasSymbol && tree.symbol != NoSymbol) { val sym = tree.symbol @@ -751,7 +750,7 @@ abstract class Detach extends PluginComponent //val cparents = List(ObjectClass.tpe, iface.tpe, // UnreferencedClass.tpe, ScalaObjectClass.tpe) iclaz setInfo ClassInfoType(cparents, new Scope, iclaz) - val proxy = (iface, iclaz, new HashMap[Symbol, Symbol]) + val proxy = (iface, iclaz, new mutable.HashMap[Symbol, Symbol]) proxies(clazz) = proxy proxy } diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala index 2682d8ac1..c008bfe53 100644 --- a/src/library/scala/Enumeration.scala +++ b/src/library/scala/Enumeration.scala @@ -8,8 +8,7 @@ package scala -import scala.collection.SetLike -import scala.collection.{ mutable, immutable, generic } +import scala.collection.{ mutable, immutable, generic, SetLike } import java.lang.reflect.{ Modifier, Method => JMethod, Field => JField } /** @@ -242,7 +241,6 @@ abstract class Enumeration(initial: Int, names: String*) extends Serializable { /** A factory object for value sets */ object ValueSet { - import mutable.{ Builder, SetBuilder } import generic.CanBuildFrom /** The empty value set */ @@ -250,10 +248,10 @@ abstract class Enumeration(initial: Int, names: String*) extends Serializable { /** A value set consisting of given elements */ def apply(elems: Value*): ValueSet = empty ++ elems /** A builder object for value sets */ - def newBuilder: Builder[Value, ValueSet] = new SetBuilder(empty) + def newBuilder: mutable.Builder[Value, ValueSet] = new mutable.SetBuilder(empty) /** The implicit builder for value sets */ - implicit def canBuildFrom: CanBuildFrom[ValueSet, Value, ValueSet] = - new CanBuildFrom[ValueSet, Value, ValueSet] { + implicit def canBuildFrom: CanBuildFrom[ValueSet, Value, ValueSet] = + new CanBuildFrom[ValueSet, Value, ValueSet] { def apply(from: ValueSet) = newBuilder def apply() = newBuilder } diff --git a/src/library/scala/collection/mutable/SetLike.scala b/src/library/scala/collection/mutable/SetLike.scala index 95c09b723..47157e1e1 100644 --- a/src/library/scala/collection/mutable/SetLike.scala +++ b/src/library/scala/collection/mutable/SetLike.scala @@ -6,14 +6,12 @@ ** |/ ** \* */ - - package scala.collection package mutable import generic._ import script._ -import annotation.{migration, bridge} +import annotation.{ migration, bridge } import parallel.mutable.ParSet /** A template trait for mutable sets of type `mutable.Set[A]`. diff --git a/src/library/scala/collection/parallel/immutable/ParHashSet.scala b/src/library/scala/collection/parallel/immutable/ParHashSet.scala index 920311241..cc6079bf8 100644 --- a/src/library/scala/collection/parallel/immutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/immutable/ParHashSet.scala @@ -108,11 +108,9 @@ self => i < sz } def remaining = sz - i - } - + } } - /** $factoryInfo * @define Coll immutable.ParHashSet * @define coll immutable parallel hash set @@ -126,7 +124,6 @@ object ParHashSet extends ParSetFactory[ParHashSet] { def fromTrie[T](t: HashSet[T]) = new ParHashSet(t) } - private[immutable] abstract class HashSetCombiner[T] extends collection.parallel.BucketCombiner[T, ParHashSet[T], Any, HashSetCombiner[T]](HashSetCombiner.rootsize) { //self: EnvironmentPassingCombiner[T, ParHashSet[T]] => @@ -207,56 +204,12 @@ extends collection.parallel.BucketCombiner[T, ParHashSet[T], Any, HashSetCombine List(new CreateTrie(bucks, root, offset, fp), new CreateTrie(bucks, root, offset + fp, howmany - fp)) } def shouldSplitFurther = howmany > collection.parallel.thresholdFromSize(root.length, parallelismLevel) - } - + } } - object HashSetCombiner { def apply[T] = new HashSetCombiner[T] {} // was: with EnvironmentPassingCombiner[T, ParHashSet[T]] {} private[immutable] val rootbits = 5 private[immutable] val rootsize = 1 << 5 } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/library/scala/collection/parallel/immutable/ParMap.scala b/src/library/scala/collection/parallel/immutable/ParMap.scala index 409e58aca..44e96d33c 100644 --- a/src/library/scala/collection/parallel/immutable/ParMap.scala +++ b/src/library/scala/collection/parallel/immutable/ParMap.scala @@ -6,15 +6,9 @@ ** |/ ** \* */ - package scala.collection package parallel.immutable - - - - -import scala.collection.immutable.Map import scala.collection.generic.ParMapFactory import scala.collection.generic.GenericParMapTemplate import scala.collection.generic.GenericParMapCompanion @@ -23,10 +17,6 @@ import scala.collection.parallel.ParMapLike import scala.collection.parallel.Combiner import scala.collection.GenMapLike - - - - /** A template trait for immutable parallel maps. * * $sideeffects @@ -42,7 +32,7 @@ extends collection/*.immutable*/.GenMap[K, V] with GenericParMapTemplate[K, V, ParMap] with parallel.ParMap[K, V] with ParIterable[(K, V)] - with ParMapLike[K, V, ParMap[K, V], Map[K, V]] + with ParMapLike[K, V, ParMap[K, V], collection.immutable.Map[K, V]] { self => @@ -65,22 +55,3 @@ object ParMap extends ParMapFactory[ParMap] { implicit def canBuildFrom[K, V]: CanCombineFrom[Coll, (K, V), ParMap[K, V]] = new CanCombineFromMap[K, V] } - - - - - - - - - - - - - - - - - - - diff --git a/src/library/scala/collection/parallel/immutable/ParSet.scala b/src/library/scala/collection/parallel/immutable/ParSet.scala index e028ec779..de9d9acec 100644 --- a/src/library/scala/collection/parallel/immutable/ParSet.scala +++ b/src/library/scala/collection/parallel/immutable/ParSet.scala @@ -6,24 +6,14 @@ ** |/ ** \* */ - package scala.collection package parallel.immutable - - - - - import scala.collection.GenSet -import scala.collection.immutable.Set import scala.collection.generic._ import scala.collection.parallel.ParSetLike import scala.collection.parallel.Combiner - - - /** An immutable variant of `ParSet`. * * @define Coll mutable.ParSet @@ -34,7 +24,7 @@ extends collection/*.immutable*/.GenSet[T] with GenericParTemplate[T, ParSet] with parallel.ParSet[T] with ParIterable[T] - with ParSetLike[T, ParSet[T], Set[T]] + with ParSetLike[T, ParSet[T], collection.immutable.Set[T]] { self => override def empty: ParSet[T] = ParHashSet[T]() @@ -47,8 +37,6 @@ self => override def toSet[U >: T]: ParSet[U] = this.asInstanceOf[ParSet[U]] } - - /** $factoryInfo * @define Coll mutable.ParSet * @define coll mutable parallel set @@ -58,17 +46,3 @@ object ParSet extends ParSetFactory[ParSet] { implicit def canBuildFrom[T]: CanCombineFrom[Coll, T, ParSet[T]] = new GenericCanCombineFrom[T] } - - - - - - - - - - - - - - diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala index 4d6554059..90947d15b 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala @@ -9,7 +9,6 @@ package scala.collection.parallel.mutable import collection.generic._ -import collection.mutable.HashSet import collection.mutable.FlatHashTable import collection.parallel.Combiner import collection.mutable.UnrolledBuffer @@ -51,7 +50,7 @@ extends ParSet[T] def clear() = clearTable() - override def seq = new HashSet(hashTableContents) + override def seq = new collection.mutable.HashSet(hashTableContents) def +=(elem: T) = { addEntry(elem) diff --git a/src/library/scala/io/BytePickle.scala b/src/library/scala/io/BytePickle.scala index 087f03026..e0c0433b6 100644 --- a/src/library/scala/io/BytePickle.scala +++ b/src/library/scala/io/BytePickle.scala @@ -6,11 +6,9 @@ ** |/ ** \* */ - - package scala.io -import scala.collection.mutable.{HashMap, ArrayBuffer} +import scala.collection.mutable /** * Pickler combinators. @@ -44,12 +42,12 @@ object BytePickle { def uunpickle[T](p: PU[T], stream: Array[Byte]): T = p.appU(stream)._1 - class PicklerEnv extends HashMap[Any, Int] { + class PicklerEnv extends mutable.HashMap[Any, Int] { private var cnt: Int = 64 def nextLoc() = { cnt += 1; cnt } } - class UnPicklerEnv extends HashMap[Int, Any] { + class UnPicklerEnv extends mutable.HashMap[Int, Any] { private var cnt: Int = 64 def nextLoc() = { cnt += 1; cnt } } @@ -231,7 +229,7 @@ object BytePickle { Array.concat(a, Array(b.toByte)) def nat2Bytes(x: Int): Array[Byte] = { - val buf = new ArrayBuffer[Byte] + val buf = new mutable.ArrayBuffer[Byte] def writeNatPrefix(x: Int) { val y = x >>> 7; if (y != 0) writeNatPrefix(y); diff --git a/src/library/scala/reflect/generic/UnPickler.scala b/src/library/scala/reflect/generic/UnPickler.scala index 1222891ba..aa6b8d238 100755 --- a/src/library/scala/reflect/generic/UnPickler.scala +++ b/src/library/scala/reflect/generic/UnPickler.scala @@ -12,7 +12,8 @@ import java.lang.Double.longBitsToDouble import Flags._ import PickleFormat._ -import collection.mutable.{HashMap, ListBuffer} +import scala.collection.{ mutable, immutable } +import mutable.ListBuffer import annotation.switch /** @author Martin Odersky @@ -62,13 +63,13 @@ abstract class UnPickler { private val entries = new Array[AnyRef](index.length) /** A map from symbols to their associated `decls` scopes */ - private val symScopes = new HashMap[Symbol, Scope] + private val symScopes = new mutable.HashMap[Symbol, Scope] //println("unpickled " + classRoot + ":" + classRoot.rawInfo + ", " + moduleRoot + ":" + moduleRoot.rawInfo);//debug def run() { // read children last, fix for #3951 - val queue = new collection.mutable.ListBuffer[() => Unit]() + val queue = new ListBuffer[() => Unit]() def delay(i: Int, action: => Unit) { queue += (() => at(i, {() => action; null})) } diff --git a/src/library/scala/util/automata/NondetWordAutom.scala b/src/library/scala/util/automata/NondetWordAutom.scala index be2afe019..8763685cb 100644 --- a/src/library/scala/util/automata/NondetWordAutom.scala +++ b/src/library/scala/util/automata/NondetWordAutom.scala @@ -6,7 +6,6 @@ ** |/ ** \* */ - package scala.util.automata import scala.collection.{ immutable, mutable } @@ -18,14 +17,12 @@ import scala.collection.{ immutable, mutable } * All states are reachable. Accepting states are those for which * the partial function `finals` is defined. */ -abstract class NondetWordAutom[T <: AnyRef] { - import immutable.BitSet - +abstract class NondetWordAutom[T <: AnyRef] { val nstates: Int val labels: Seq[T] val finals: Array[Int] // 0 means not final - val delta: Array[mutable.Map[T, BitSet]] - val default: Array[BitSet] + val delta: Array[mutable.Map[T, immutable.BitSet]] + val default: Array[immutable.BitSet] /** @return true if the state is final */ final def isFinal(state: Int) = finals(state) > 0 @@ -34,20 +31,20 @@ abstract class NondetWordAutom[T <: AnyRef] { final def finalTag(state: Int) = finals(state) /** @return true if the set of states contains at least one final state */ - final def containsFinal(Q: BitSet): Boolean = Q exists isFinal + final def containsFinal(Q: immutable.BitSet): Boolean = Q exists isFinal /** @return true if there are no accepting states */ final def isEmpty = (0 until nstates) forall (x => !isFinal(x)) - /** @return a BitSet with the next states for given state and label */ - def next(q: Int, a: T): BitSet = delta(q).getOrElse(a, default(q)) + /** @return a immutable.BitSet with the next states for given state and label */ + def next(q: Int, a: T): immutable.BitSet = delta(q).getOrElse(a, default(q)) - /** @return a BitSet with the next states for given state and label */ - def next(Q: BitSet, a: T): BitSet = next(Q, next(_, a)) - def nextDefault(Q: BitSet): BitSet = next(Q, default) + /** @return a immutable.BitSet with the next states for given state and label */ + def next(Q: immutable.BitSet, a: T): immutable.BitSet = next(Q, next(_, a)) + def nextDefault(Q: immutable.BitSet): immutable.BitSet = next(Q, default) - private def next(Q: BitSet, f: (Int) => BitSet): BitSet = - (Q map f).foldLeft(BitSet.empty)(_ ++ _) + private def next(Q: immutable.BitSet, f: (Int) => immutable.BitSet): immutable.BitSet = + (Q map f).foldLeft(immutable.BitSet.empty)(_ ++ _) private def finalStates = 0 until nstates filter isFinal override def toString = { diff --git a/src/library/scala/util/automata/SubsetConstruction.scala b/src/library/scala/util/automata/SubsetConstruction.scala index 4cf1ee4b4..0db228783 100644 --- a/src/library/scala/util/automata/SubsetConstruction.scala +++ b/src/library/scala/util/automata/SubsetConstruction.scala @@ -12,34 +12,33 @@ import scala.collection.{ mutable, immutable } class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) { import nfa.labels - import immutable.BitSet - def selectTag(Q: BitSet, finals: Array[Int]) = + def selectTag(Q: immutable.BitSet, finals: Array[Int]) = Q map finals filter (_ > 0) min def determinize: DetWordAutom[T] = { // for assigning numbers to bitsets - var indexMap = collection.Map[BitSet, Int]() - var invIndexMap = collection.Map[Int, BitSet]() + var indexMap = collection.Map[immutable.BitSet, Int]() + var invIndexMap = collection.Map[Int, immutable.BitSet]() var ix = 0 // we compute the dfa with states = bitsets - val q0 = BitSet(0) // the set { 0 } - val sink = BitSet.empty // the set { } + val q0 = immutable.BitSet(0) // the set { 0 } + val sink = immutable.BitSet.empty // the set { } var states = Set(q0, sink) // initial set of sets - val delta = new mutable.HashMap[BitSet, mutable.HashMap[T, BitSet]] + val delta = new mutable.HashMap[immutable.BitSet, mutable.HashMap[T, immutable.BitSet]] var deftrans = mutable.Map(q0 -> sink, sink -> sink) // initial transitions - var finals: mutable.Map[BitSet, Int] = mutable.Map() - val rest = new mutable.Stack[BitSet] + var finals: mutable.Map[immutable.BitSet, Int] = mutable.Map() + val rest = new mutable.Stack[immutable.BitSet] rest.push(sink, q0) - def addFinal(q: BitSet) { + def addFinal(q: immutable.BitSet) { if (nfa containsFinal q) finals = finals.updated(q, selectTag(q, nfa.finals)) } - def add(Q: BitSet) { + def add(Q: immutable.BitSet) { if (!states(Q)) { states += Q rest push Q @@ -57,7 +56,7 @@ class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) { ix += 1 // make transition map - val Pdelta = new mutable.HashMap[T, BitSet] + val Pdelta = new mutable.HashMap[T, immutable.BitSet] delta.update(P, Pdelta) labels foreach { label => diff --git a/src/library/scala/util/automata/WordBerrySethi.scala b/src/library/scala/util/automata/WordBerrySethi.scala index 4e111aa1c..975523de5 100644 --- a/src/library/scala/util/automata/WordBerrySethi.scala +++ b/src/library/scala/util/automata/WordBerrySethi.scala @@ -6,12 +6,9 @@ ** |/ ** \* */ - - package scala.util.automata import scala.collection.{ immutable, mutable } -import mutable.{ HashSet, HashMap } import scala.util.regexp.WordExp /** This class turns a regular expression into a [[scala.util.automata.NondetWorkAutom]] @@ -25,12 +22,12 @@ abstract class WordBerrySethi extends BaseBerrySethi { import lang.{ Alt, Eps, Letter, Meta, RegExp, Sequ, Star, _labelT } - protected var labels: HashSet[_labelT] = _ + protected var labels: mutable.HashSet[_labelT] = _ // don't let this fool you, only labelAt is a real, surjective mapping - protected var labelAt: Map[Int, _labelT] = _ // new alphabet "gamma" - protected var deltaq: Array[HashMap[_labelT, List[Int]]] = _ // delta - protected var defaultq: Array[List[Int]] = _ // default transitions - protected var initials: Set[Int] = _ + protected var labelAt: Map[Int, _labelT] = _ // new alphabet "gamma" + protected var deltaq: Array[mutable.HashMap[_labelT, List[Int]]] = _ // delta + protected var defaultq: Array[List[Int]] = _ // default transitions + protected var initials: Set[Int] = _ /** Computes `first(r)` where the word regexp `r`. * @@ -97,8 +94,8 @@ abstract class WordBerrySethi extends BaseBerrySethi { protected def initialize(subexpr: Seq[RegExp]): Unit = { this.labelAt = immutable.Map() - this.follow = HashMap() - this.labels = HashSet() + this.follow = mutable.HashMap() + this.labels = mutable.HashSet() this.pos = 0 // determine "Sethi-length" of the regexp @@ -109,11 +106,11 @@ abstract class WordBerrySethi extends BaseBerrySethi { protected def initializeAutom() { finals = immutable.Map.empty[Int, Int] // final states - deltaq = new Array[HashMap[_labelT, List[Int]]](pos) // delta + deltaq = new Array[mutable.HashMap[_labelT, List[Int]]](pos) // delta defaultq = new Array[List[Int]](pos) // default transitions for (j <- 0 until pos) { - deltaq(j) = HashMap[_labelT, List[Int]]() + deltaq(j) = mutable.HashMap[_labelT, List[Int]]() defaultq(j) = Nil } } @@ -147,7 +144,7 @@ abstract class WordBerrySethi extends BaseBerrySethi { val deltaArr: Array[mutable.Map[_labelT, immutable.BitSet]] = (0 until pos map { x => - HashMap(delta1(x).toSeq map { case (k, v) => k -> immutable.BitSet(v: _*) } : _*) + mutable.HashMap(delta1(x).toSeq map { case (k, v) => k -> immutable.BitSet(v: _*) } : _*) }).toArray val defaultArr = 0 until pos map (k => immutable.BitSet(defaultq(k): _*)) toArray diff --git a/src/library/scala/util/parsing/ast/Binders.scala b/src/library/scala/util/parsing/ast/Binders.scala index e5c4a018f..511d52c00 100644 --- a/src/library/scala/util/parsing/ast/Binders.scala +++ b/src/library/scala/util/parsing/ast/Binders.scala @@ -8,7 +8,7 @@ package scala.util.parsing.ast -import scala.collection.mutable.Map +import scala.collection.mutable //DISCLAIMER: this code is highly experimental! @@ -84,8 +84,8 @@ trait Binders extends AbstractSyntax with Mappable { * (`id` is solely used for this textual representation.) */ class Scope[binderType <: NameElement] extends Iterable[binderType]{ - private val substitution: Map[binderType, Element] = - new scala.collection.mutable.LinkedHashMap[binderType, Element] // a LinkedHashMap is ordered by insertion order -- important! + private val substitution: mutable.Map[binderType, Element] = + new mutable.LinkedHashMap[binderType, Element] // a LinkedHashMap is ordered by insertion order -- important! /** Returns a unique number identifying this Scope (only used for representation purposes). */ val id: Int = _Binder.genId @@ -236,7 +236,7 @@ trait Binders extends AbstractSyntax with Mappable { }) }*/ - def cloneElementWithSubst(subst: scala.collection.immutable.Map[NameElement, NameElement]) = element.gmap(new Mapper { def apply[t <% Mappable[t]](x :t): t = x match{ + def cloneElementWithSubst(subst: Map[NameElement, NameElement]) = element.gmap(new Mapper { def apply[t <% Mappable[t]](x :t): t = x match{ case substable: NameElement if subst.contains(substable) => subst.get(substable).asInstanceOf[t] // TODO: wrong... substitution is not (necessarily) the identity function //Console.println("substed: "+substable+"-> "+subst.get(substable)+")"); case x => x // Console.println("subst: "+x+"(keys: "+subst.keys+")");x @@ -249,7 +249,7 @@ trait Binders extends AbstractSyntax with Mappable { }}) def extract: elementT = cloneElementNoBoundElements - def extract(subst: scala.collection.immutable.Map[NameElement, NameElement]): elementT = cloneElementWithSubst(subst) + def extract(subst: Map[NameElement, NameElement]): elementT = cloneElementWithSubst(subst) /** Get a string representation of element, normally we don't allow direct access to element, but just getting a string representation is ok. */ def elementToString: String = element.toString diff --git a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala index aacb7e6fa..7bd3f2ea3 100644 --- a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala +++ b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala @@ -14,7 +14,7 @@ package lexical import token._ import input.CharArrayReader.EofCh -import collection.mutable.HashSet +import scala.collection.mutable /** This component provides a standard lexical parser for a simple, Scala-like language. * It parses keywords and identifiers, numeric literals (integers), strings, and delimiters. @@ -62,10 +62,10 @@ class StdLexical extends Lexical with StdTokens { ) /** The set of reserved identifiers: these will be returned as `Keyword`s. */ - val reserved = new HashSet[String] + val reserved = new mutable.HashSet[String] /** The set of delimiters (ordering does not matter). */ - val delimiters = new HashSet[String] + val delimiters = new mutable.HashSet[String] protected def processIdent(name: String) = if (reserved contains name) Keyword(name) else Identifier(name) diff --git a/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala index 28e15af3a..654e218d7 100644 --- a/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala +++ b/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala @@ -13,7 +13,7 @@ package combinator package syntactical import token._ -import collection.mutable.HashMap +import scala.collection.mutable /** This component provides primitive parsers for the standard tokens defined in `StdTokens`. * @@ -23,7 +23,7 @@ trait StdTokenParsers extends TokenParsers { type Tokens <: StdTokens import lexical.{Keyword, NumericLit, StringLit, Identifier} - protected val keywordCache : HashMap[String, Parser[String]] = HashMap.empty + protected val keywordCache = mutable.HashMap[String, Parser[String]]() /** A parser which matches a single keyword token. * diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index f867690dd..1a92e5dd3 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -6,12 +6,9 @@ ** |/ ** \* */ - - package scala.xml -import collection.mutable -import mutable.{ Set, HashSet } +import scala.collection.mutable import parsing.XhtmlEntities /** @@ -20,8 +17,7 @@ import parsing.XhtmlEntities * * @author Burak Emir */ -object Utility extends AnyRef with parsing.TokenTests -{ +object Utility extends AnyRef with parsing.TokenTests { final val SU = '\u001A' implicit def implicitSbToString(sb: StringBuilder) = sb.toString() @@ -151,7 +147,7 @@ object Utility extends AnyRef with parsing.TokenTests * @return ... */ def collectNamespaces(nodes: Seq[Node]): mutable.Set[String] = - nodes.foldLeft(new HashSet[String]) { (set, x) => collectNamespaces(x, set) ; set } + nodes.foldLeft(new mutable.HashSet[String]) { (set, x) => collectNamespaces(x, set) ; set } /** * Adds all namespaces in node to set. diff --git a/src/library/scala/xml/dtd/DTD.scala b/src/library/scala/xml/dtd/DTD.scala index aa86e2fa2..118a9cec9 100644 --- a/src/library/scala/xml/dtd/DTD.scala +++ b/src/library/scala/xml/dtd/DTD.scala @@ -10,8 +10,7 @@ package scala.xml package dtd -import collection.mutable -import mutable.HashMap +import scala.collection.mutable /** A document type declaration. * @@ -23,9 +22,9 @@ abstract class DTD { def notations: Seq[NotationDecl] = Nil def unparsedEntities: Seq[EntityDecl] = Nil - var elem: mutable.Map[String, ElemDecl] = new HashMap[String, ElemDecl]() - var attr: mutable.Map[String, AttListDecl] = new HashMap[String, AttListDecl]() - var ent: mutable.Map[String, EntityDecl] = new HashMap[String, EntityDecl]() + var elem: mutable.Map[String, ElemDecl] = new mutable.HashMap[String, ElemDecl]() + var attr: mutable.Map[String, AttListDecl] = new mutable.HashMap[String, AttListDecl]() + var ent: mutable.Map[String, EntityDecl] = new mutable.HashMap[String, EntityDecl]() override def toString() = "DTD [\n%s%s]".format( diff --git a/src/library/scala/xml/dtd/ElementValidator.scala b/src/library/scala/xml/dtd/ElementValidator.scala index eaed84b21..dac6bff8d 100644 --- a/src/library/scala/xml/dtd/ElementValidator.scala +++ b/src/library/scala/xml/dtd/ElementValidator.scala @@ -14,9 +14,8 @@ package dtd import PartialFunction._ import ContentModel.ElemName import MakeValidationException._ // @todo other exceptions - import scala.util.automata._ -import scala.collection.mutable.BitSet +import scala.collection.mutable /** validate children and/or attributes of an element * exceptions are created but not thrown. @@ -62,7 +61,7 @@ class ElementValidator() extends Function1[Node,Boolean] { */ def check(md: MetaData): Boolean = { val len: Int = exc.length - var ok = new BitSet(adecls.length) + var ok = new mutable.BitSet(adecls.length) for (attr <- md) { def attrStr = attr.value.toString diff --git a/src/library/scala/xml/include/sax/XIncluder.scala b/src/library/scala/xml/include/sax/XIncluder.scala index b96207487..661130728 100644 --- a/src/library/scala/xml/include/sax/XIncluder.scala +++ b/src/library/scala/xml/include/sax/XIncluder.scala @@ -11,8 +11,7 @@ package scala.xml package include.sax import scala.xml.include._ -import collection.mutable.Stack - +import scala.collection.mutable import org.xml.sax.{ ContentHandler, XMLReader, Locator, Attributes } import org.xml.sax.ext.LexicalHandler import java.io.{ File, OutputStream, OutputStreamWriter, Writer, IOException } @@ -137,7 +136,7 @@ class XIncluder(outs: OutputStream, encoding: String) extends ContentHandler wit // LexicalHandler methods private var inDTD: Boolean = false - private val entities = new Stack[String]() + private val entities = new mutable.Stack[String]() def startDTD(name: String, publicID: String, systemID: String) { inDTD = true diff --git a/src/library/scala/xml/parsing/MarkupHandler.scala b/src/library/scala/xml/parsing/MarkupHandler.scala index 53a14e47e..87713574a 100644 --- a/src/library/scala/xml/parsing/MarkupHandler.scala +++ b/src/library/scala/xml/parsing/MarkupHandler.scala @@ -11,8 +11,7 @@ package scala.xml package parsing -import collection.mutable -import mutable.HashMap +import scala.collection.mutable import scala.io.Source import scala.util.logging.Logged import scala.xml.dtd._ @@ -32,7 +31,7 @@ abstract class MarkupHandler extends Logged val isValidating: Boolean = false var decls: List[Decl] = Nil - var ent: mutable.Map[String, EntityDecl] = new HashMap[String, EntityDecl]() + var ent: mutable.Map[String, EntityDecl] = new mutable.HashMap[String, EntityDecl]() def lookupElemDecl(Label: String): ElemDecl = { for (z @ ElemDecl(Label, _) <- decls) diff --git a/src/partest-alternative/scala/tools/partest/Statistics.scala b/src/partest-alternative/scala/tools/partest/Statistics.scala index 0d38cb1ed..913e37048 100644 --- a/src/partest-alternative/scala/tools/partest/Statistics.scala +++ b/src/partest-alternative/scala/tools/partest/Statistics.scala @@ -6,11 +6,11 @@ package scala.tools package partest -import scala.collection.mutable.HashMap +import scala.collection.mutable trait Statistics { /** Only collected when --stats is given. */ - lazy val testStatistics = new HashMap[String, Long] + lazy val testStatistics = new mutable.HashMap[String, Long] /** Given function and block of code, evaluates code block, * calls function with milliseconds elapsed, and returns block result. diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala index 70336daa1..5058a8b4f 100644 --- a/src/partest/scala/tools/partest/nest/FileManager.scala +++ b/src/partest/scala/tools/partest/nest/FileManager.scala @@ -13,8 +13,8 @@ import java.io.{File, FilenameFilter, IOException, StringWriter, FileReader, PrintWriter, FileWriter} import java.net.URI import scala.tools.nsc.io.{ Path, Directory, File => SFile } -import scala.collection.mutable.HashMap import sys.process._ +import scala.collection.mutable trait FileManager { /** @@ -56,7 +56,7 @@ trait FileManager { var oneTestTimeout = 60 * 60 * 1000 /** Only when --debug is given. */ - lazy val testTimings = new HashMap[String, Long] + lazy val testTimings = new mutable.HashMap[String, Long] def recordTestTiming(name: String, milliseconds: Long) = synchronized { testTimings(name) = milliseconds } def showTestTimings() { diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Memoisable.scala b/src/scalap/scala/tools/scalap/scalax/rules/Memoisable.scala index b61943277..ee59037c6 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/Memoisable.scala +++ b/src/scalap/scala/tools/scalap/scalax/rules/Memoisable.scala @@ -14,7 +14,7 @@ package scala.tools.scalap package scalax package rules -import scala.collection.mutable.HashMap +import scala.collection.mutable trait MemoisableRules extends Rules { def memo[In <: Memoisable, Out, A, X](key : AnyRef)(toRule : => In => Result[Out, A, X]) = { @@ -38,7 +38,7 @@ object DefaultMemoisable { } trait DefaultMemoisable extends Memoisable { - protected val map = new HashMap[AnyRef, Any] + protected val map = new mutable.HashMap[AnyRef, Any] def memo[A](key : AnyRef, a : => A) = { map.getOrElseUpdate(key, compute(key, a)).asInstanceOf[A] diff --git a/src/swing/scala/swing/ButtonGroup.scala b/src/swing/scala/swing/ButtonGroup.scala index f517ec2a6..a7db65a8a 100644 --- a/src/swing/scala/swing/ButtonGroup.scala +++ b/src/swing/scala/swing/ButtonGroup.scala @@ -6,14 +6,11 @@ ** |/ ** \* */ - - package scala.swing import event._ import javax.swing.{AbstractButton => JAbstractButton,Icon} -import scala.collection._ -import scala.collection.mutable.Buffer +import scala.collection.{ mutable, immutable } /** * A button mutex. At most one of its associated buttons is selected diff --git a/src/swing/scala/swing/LayoutContainer.scala b/src/swing/scala/swing/LayoutContainer.scala index 0fc9e77a3..f5c5a9c68 100644 --- a/src/swing/scala/swing/LayoutContainer.scala +++ b/src/swing/scala/swing/LayoutContainer.scala @@ -11,7 +11,7 @@ package scala.swing import javax.swing.JComponent -import scala.collection.mutable.Map +import scala.collection.mutable /**

* A container that associates layout constraints of member type @@ -57,7 +57,7 @@ trait LayoutContainer extends Container.Wrapper { * * also ensures that myComponent is properly added to this container. */ - def layout: Map[Component, Constraints] = new Map[Component, Constraints] { + def layout: mutable.Map[Component, Constraints] = new mutable.Map[Component, Constraints] { def -= (c: Component): this.type = { _contents -= c; this } def += (cl: (Component, Constraints)): this.type = { update(cl._1, cl._2); this } override def update (c: Component, l: Constraints) { diff --git a/src/swing/scala/swing/Publisher.scala b/src/swing/scala/swing/Publisher.scala index 39344c529..bde217a68 100644 --- a/src/swing/scala/swing/Publisher.scala +++ b/src/swing/scala/swing/Publisher.scala @@ -6,12 +6,10 @@ ** |/ ** \* */ - - package scala.swing -import scala.collection._ -import scala.collection.mutable.{Buffer, HashSet, Set} +import scala.collection.mutable +import mutable.Buffer import event.Event /**

@@ -33,7 +31,7 @@ trait Publisher extends Reactor { protected val listeners = new RefSet[Reaction] { import scala.ref._ - val underlying = new HashSet[Reference[Reaction]] + val underlying = new mutable.HashSet[Reference[Reaction]] protected def Ref(a: Reaction) = a match { case a: StronglyReferenced => new StrongReference[Reaction](a) with super.Ref[Reaction] case _ => new WeakReference[Reaction](a, referenceQueue) with super.Ref[Reaction] @@ -164,8 +162,8 @@ abstract class RefBuffer[A <: AnyRef] extends Buffer[A] with SingleRefCollection protected[this] def removeReference(ref: Reference[A]) { underlying -= ref } } -private[swing] abstract class RefSet[A <: AnyRef] extends Set[A] with SingleRefCollection[A] { self => - protected val underlying: Set[Reference[A]] +private[swing] abstract class RefSet[A <: AnyRef] extends mutable.Set[A] with SingleRefCollection[A] { self => + protected val underlying: mutable.Set[Reference[A]] def -=(el: A): this.type = { underlying -= Ref(el); purgeReferences(); this } def +=(el: A): this.type = { purgeReferences(); underlying += Ref(el); this } diff --git a/src/swing/scala/swing/UIElement.scala b/src/swing/scala/swing/UIElement.scala index 786b0cffa..2333d7e76 100644 --- a/src/swing/scala/swing/UIElement.scala +++ b/src/swing/scala/swing/UIElement.scala @@ -6,13 +6,10 @@ ** |/ ** \* */ - - package scala.swing import java.awt.Cursor import event._ -import scala.collection.mutable.HashMap import scala.ref._ import java.util.WeakHashMap