diff options
author | michelou <michelou@epfl.ch> | 2007-06-13 12:28:07 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2007-06-13 12:28:07 +0000 |
commit | 2a52c9f3ab7b05d4be2f3138a61f065c3e3ac3af (patch) | |
tree | e7ae489c9832557e90f9cff5f00622d3f8b5f630 | |
parent | 9934c835a73512776de69f1f6c45ccd017ee8e10 (diff) | |
download | scala-2a52c9f3ab7b05d4be2f3138a61f065c3e3ac3af.tar.gz scala-2a52c9f3ab7b05d4be2f3138a61f065c3e3ac3af.tar.bz2 scala-2a52c9f3ab7b05d4be2f3138a61f065c3e3ac3af.zip |
incremented MinorVersion, deprecated All/AllRef...
incremented MinorVersion, deprecated All/AllRef, remove many type
aliases
53 files changed, 777 insertions, 738 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala index e5db1c5966..2d5e97433f 100644 --- a/src/actors/scala/actors/Actor.scala +++ b/src/actors/scala/actors/Actor.scala @@ -50,7 +50,7 @@ object Actor { * This permits to re-use the current thread as an actor * even if its <code>ActorProxy</code> has died for some reason. */ - def resetProxy: unit = { + def resetProxy { val a = tl.get.asInstanceOf[Actor] if ((null ne a) && a.isInstanceOf[ActorProxy]) tl.set(new ActorProxy(currentThread)) @@ -91,7 +91,7 @@ object Actor { * @param f a partial function specifying patterns and actions * @return the result of processing the received message */ - def receive[a](f: PartialFunction[Any, a]): a = + def receive[A](f: PartialFunction[Any, A]): A = self.receive(f) /** @@ -133,7 +133,7 @@ object Actor { * @param f a partial function specifying patterns and actions * @return this function never returns */ - def reactWithin(msec: long)(f: PartialFunction[Any, Unit]): Nothing = + def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing = self.reactWithin(msec)(f) def eventloop(f: PartialFunction[Any, Unit]): Nothing = @@ -141,9 +141,9 @@ object Actor { private class RecursiveProxyHandler(a: Actor, f: PartialFunction[Any, Unit]) extends PartialFunction[Any, Unit] { - def isDefinedAt(m: Any): boolean = + def isDefinedAt(m: Any): Boolean = true // events are immediately removed from the mailbox - def apply(m: Any): Unit = { + def apply(m: Any) { if (f.isDefinedAt(m)) f(m) self.react(this) } @@ -237,7 +237,7 @@ object Actor { */ def exit(): Nothing = self.exit() - def continue: unit = self.kill() + def continue: Unit = self.kill() } /** @@ -271,7 +271,7 @@ trait Actor extends OutputChannel[Any] { private var received: Option[Any] = None private[actors] val waitingForNone = (m: Any) => false - private[actors] var waitingFor: Any => boolean = waitingForNone + private[actors] var waitingFor: Any => Boolean = waitingForNone private[actors] var isSuspended = false private val mailbox = new MessageQueue @@ -326,7 +326,7 @@ trait Actor extends OutputChannel[Any] { result } - def receiveWithin[R](msec: long)(f: PartialFunction[Any, R]): R = { + def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R = { assert(Actor.self == this, "receive from channel belonging to other actor") if (shouldExit) exit() // links this.synchronized { @@ -389,7 +389,7 @@ trait Actor extends OutputChannel[Any] { } } - def reactWithin(msec: long)(f: PartialFunction[Any, Unit]): Nothing = { + def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing = { assert(Actor.self == this, "react on channel belonging to other actor") if (shouldExit) exit() // links Scheduler.pendReaction @@ -424,7 +424,7 @@ trait Actor extends OutputChannel[Any] { /** * Sends <code>msg</code> to this actor (asynchronous). */ - def !(msg: Any): Unit = { + def !(msg: Any) { send(msg, Actor.self.getReplyChannel) } @@ -452,7 +452,7 @@ trait Actor extends OutputChannel[Any] { * Otherwise, returns <code>Some(value)</code> where * <code>value</code> is the reply value. */ - def !?(msec: long, msg: Any): Option[Any] = { + def !?(msec: Long, msg: Any): Option[Any] = { val replyChannel = Actor.self.freshReply() this ! msg replyChannel.receiveWithin(msec) { @@ -491,10 +491,10 @@ trait Actor extends OutputChannel[Any] { * <code>f</code>. This also allows to recover a more * precise type for the reply value. */ - def !![a](msg: Any, f: PartialFunction[Any, a]): Future[a] = { + def !![A](msg: Any, f: PartialFunction[Any, A]): Future[A] = { val ftch = new Channel[Any](Actor.self) send(msg, ftch) - new Future[a](ftch) { + new Future[A](ftch) { def apply() = if (isSet) value.get else ch.receive { @@ -576,7 +576,7 @@ trait Actor extends OutputChannel[Any] { if (shouldExit) exit() } - def suspendActorFor(msec: long) { + def suspendActorFor(msec: Long) { val ts = Platform.currentTime var waittime = msec var fromExc = false diff --git a/src/actors/scala/actors/Channel.scala b/src/actors/scala/actors/Channel.scala index 52386c9b70..a11545cd5d 100644 --- a/src/actors/scala/actors/Channel.scala +++ b/src/actors/scala/actors/Channel.scala @@ -88,7 +88,7 @@ class Channel[Msg] extends InputChannel[Msg] with OutputChannel[Msg] { * @param f a partial function with message patterns and actions * @return result of processing the received value */ - def receiveWithin[R](msec: long)(f: PartialFunction[Any, R]): R = { + def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R = { val C = this.asInstanceOf[Channel[Any]] receiver.receiveWithin(msec) { case C ! msg if (f.isDefinedAt(msg)) => f(msg) @@ -121,7 +121,7 @@ class Channel[Msg] extends InputChannel[Msg] with OutputChannel[Msg] { * @param msec the time span before timeout * @param f a partial function with message patterns and actions */ - def reactWithin(msec: long)(f: PartialFunction[Any, Unit]): Nothing = { + def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing = { val C = this.asInstanceOf[Channel[Any]] receiver.reactWithin(msec) { case C ! msg if (f.isDefinedAt(msg)) => f(msg) @@ -153,7 +153,7 @@ class Channel[Msg] extends InputChannel[Msg] with OutputChannel[Msg] { * @return <code>None</code> in case of timeout, otherwise * <code>Some(x)</code> where <code>x</code> is the reply */ - def !?(msec: long, msg: Msg): Option[Any] = { + def !?(msec: Long, msg: Msg): Option[Any] = { val replyChannel = Actor.self.freshReply() receiver ! scala.actors.!(this, msg) replyChannel.receiveWithin(msec) { diff --git a/src/actors/scala/actors/Debug.scala b/src/actors/scala/actors/Debug.scala index 89efe5db62..4b73019861 100644 --- a/src/actors/scala/actors/Debug.scala +++ b/src/actors/scala/actors/Debug.scala @@ -17,7 +17,7 @@ object Debug { private var lev = 2 def level = lev - def level_= (lev: int) = { this.lev = lev } + def level_= (lev: Int) = { this.lev = lev } def info(s: String) = if (lev > 2) System.out.println("Info: " + s) @@ -33,7 +33,7 @@ class Debug(tag: String) { private var lev = 2 def level = lev - def level_= (lev: int) = { this.lev = lev } + def level_= (lev: Int) = { this.lev = lev } def info(s: String) = if (lev > 2) System.out.println(tag + " (info): " + s) diff --git a/src/actors/scala/actors/FJTaskScheduler2.scala b/src/actors/scala/actors/FJTaskScheduler2.scala index d1dd6e1d56..22d3627333 100644 --- a/src/actors/scala/actors/FJTaskScheduler2.scala +++ b/src/actors/scala/actors/FJTaskScheduler2.scala @@ -44,19 +44,19 @@ class FJTaskScheduler2 extends Thread with IScheduler { private var pendingReactions = 0 - def pendReaction: unit = synchronized { - pendingReactions = pendingReactions + 1 + def pendReaction: Unit = synchronized { + pendingReactions += 1 } - def unPendReaction: unit = synchronized { - pendingReactions = pendingReactions - 1 + def unPendReaction: Unit = synchronized { + pendingReactions -= 1 } def getPendingCount = synchronized { pendingReactions } - def setPendingCount(cnt: int) = synchronized { + def setPendingCount(cnt: Int) = synchronized { pendingReactions = cnt } @@ -66,17 +66,17 @@ class FJTaskScheduler2 extends Thread with IScheduler { private val TICK_FREQ = 50 private val CHECK_FREQ = 100 - def onLockup(handler: () => unit) = + def onLockup(handler: () => Unit) = lockupHandler = handler - def onLockup(millis: int)(handler: () => unit) = { + def onLockup(millis: Int)(handler: () => Unit) = { //LOCKUP_CHECK_FREQ = millis / CHECK_FREQ lockupHandler = handler } - private var lockupHandler: () => unit = null + private var lockupHandler: () => Unit = null - override def run(): unit = { + override def run() { try { while (!terminating) { this.synchronized { @@ -153,7 +153,7 @@ class FJTaskScheduler2 extends Thread with IScheduler { /** Shuts down all idle worker threads. */ - def shutdown(): unit = synchronized { + def shutdown(): Unit = synchronized { terminating = true // terminate timer thread TimerThread.shutdown() diff --git a/src/actors/scala/actors/Future.scala b/src/actors/scala/actors/Future.scala index 9020c7e971..1247fa5972 100644 --- a/src/actors/scala/actors/Future.scala +++ b/src/actors/scala/actors/Future.scala @@ -26,7 +26,7 @@ package scala.actors */ abstract class Future[T](val ch: InputChannel[Any]) extends Function0[T] { protected var value: Option[T] = None - def isSet: boolean + def isSet: Boolean } /** @@ -47,7 +47,7 @@ object Futures { a !! (Eval, { case any => any.asInstanceOf[T] }) } - def alarm(t: long) = future { + def alarm(t: Long) = future { Actor.reactWithin(t) { case TIMEOUT => {} } @@ -70,27 +70,27 @@ object Futures { * Note that some of the futures might already have been awaited. * </p> */ - def awaitAll(timeout: long, fts: Future[Any]*): List[Option[Any]] = { + def awaitAll(timeout: Long, fts: Future[Any]*): List[Option[Any]] = { var resultsMap: collection.mutable.Map[Int, Option[Any]] = new collection.mutable.HashMap[Int, Option[Any]] var cnt = 0 val mappedFts = fts.map(ft => Pair({cnt+=1; cnt-1}, ft)) - val unsetFts = mappedFts.filter((p: Pair[int, Future[Any]]) => { + val unsetFts = mappedFts.filter((p: Pair[Int, Future[Any]]) => { if (p._2.isSet) { resultsMap(p._1) = Some(p._2()); false } else { resultsMap(p._1) = None; true } }) - val partFuns = unsetFts.map((p: Pair[int, Future[Any]]) => { + val partFuns = unsetFts.map((p: Pair[Int, Future[Any]]) => { val FutCh = p._2.ch - val singleCase: PartialFunction[Any, Pair[int, Any]] = { + val singleCase: PartialFunction[Any, Pair[Int, Any]] = { case FutCh ! any => Pair(p._1, any) } singleCase }) - def awaitWith(partFuns: Seq[PartialFunction[Any, Pair[int, Any]]]) { + def awaitWith(partFuns: Seq[PartialFunction[Any, Pair[Int, Any]]]) { val reaction: PartialFunction[Any, unit] = new PartialFunction[Any, unit] { def isDefinedAt(msg: Any) = msg match { case TIMEOUT => true diff --git a/src/actors/scala/actors/InputChannel.scala b/src/actors/scala/actors/InputChannel.scala index ab1841cb83..938a7986e5 100644 --- a/src/actors/scala/actors/InputChannel.scala +++ b/src/actors/scala/actors/InputChannel.scala @@ -19,7 +19,7 @@ package scala.actors */ trait InputChannel[+Msg] { def receive[R](f: PartialFunction[Msg, R]): R - def receiveWithin[R](msec: long)(f: PartialFunction[Any, R]): R + def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R def react(f: PartialFunction[Msg, Unit]): Nothing - def reactWithin(msec: long)(f: PartialFunction[Any, Unit]): Nothing + def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing } diff --git a/src/actors/scala/actors/MessageQueue.scala b/src/actors/scala/actors/MessageQueue.scala index 618e6f864e..51644f4471 100644 --- a/src/actors/scala/actors/MessageQueue.scala +++ b/src/actors/scala/actors/MessageQueue.scala @@ -45,7 +45,7 @@ class MessageQueue { } } - def extractFirst(p: Any => boolean): MessageQueueElement = { + def extractFirst(p: Any => Boolean): MessageQueueElement = { if (null eq last) null else { // test first element diff --git a/src/actors/scala/actors/Scheduler.scala b/src/actors/scala/actors/Scheduler.scala index 0eb97545b4..f5f42b6477 100644 --- a/src/actors/scala/actors/Scheduler.scala +++ b/src/actors/scala/actors/Scheduler.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -41,13 +41,13 @@ object Scheduler { var tasks: LinkedQueue = null var pendingCount = 0 - def snapshot(): unit = synchronized { + def snapshot(): Unit = synchronized { tasks = sched.snapshot() pendingCount = sched.asInstanceOf[FJTaskScheduler2].getPendingCount sched.shutdown() } - def restart(): unit = synchronized { + def restart(): Unit = synchronized { sched = { var s: IScheduler = new FJTaskScheduler2 s.asInstanceOf[FJTaskScheduler2].setPendingCount(pendingCount) @@ -76,13 +76,13 @@ object Scheduler { def tick(a: Actor) = sched.tick(a) def terminated(a: Actor) = sched.terminated(a) - def pendReaction: unit = sched.pendReaction - def unPendReaction: unit = sched.unPendReaction + def pendReaction: Unit = sched.pendReaction + def unPendReaction: Unit = sched.unPendReaction def shutdown() = sched.shutdown() - def onLockup(handler: () => unit) = sched.onLockup(handler) - def onLockup(millis: int)(handler: () => unit) = sched.onLockup(millis)(handler) + def onLockup(handler: () => Unit) = sched.onLockup(handler) + def onLockup(millis: int)(handler: () => Unit) = sched.onLockup(millis)(handler) def printActorDump = sched.printActorDump } @@ -95,27 +95,27 @@ object Scheduler { * @author Philipp Haller */ trait IScheduler { - def start(): unit + def start(): Unit - def start(task: Reaction): unit - def execute(task: Reaction): unit - def execute(task: FJTask): unit + def start(task: Reaction): Unit + def execute(task: Reaction): Unit + def execute(task: FJTask): Unit def getTask(worker: WorkerThread): Runnable - def tick(a: Actor): unit - def terminated(a: Actor): unit - def pendReaction: unit - def unPendReaction: unit + def tick(a: Actor): Unit + def terminated(a: Actor): Unit + def pendReaction: Unit + def unPendReaction: Unit def snapshot(): LinkedQueue - def shutdown(): unit + def shutdown(): Unit - def onLockup(handler: () => unit): unit - def onLockup(millis: int)(handler: () => unit): unit - def printActorDump: unit + def onLockup(handler: () => Unit): Unit + def onLockup(millis: int)(handler: () => Unit): Unit + def printActorDump: Unit val QUIT_TASK = new Reaction(null) { - override def run(): unit = {} + override def run(): Unit = {} override def toString() = "QUIT_TASK" } } @@ -147,17 +147,17 @@ class SingleThreadedScheduler extends IScheduler { } def getTask(worker: WorkerThread): Runnable = null - def tick(a: Actor): Unit = {} - def terminated(a: Actor): unit = {} - def pendReaction: unit = {} - def unPendReaction: unit = {} + def tick(a: Actor) {} + def terminated(a: Actor) {} + def pendReaction {} + def unPendReaction {} - def shutdown(): Unit = {} + def shutdown() {} def snapshot(): LinkedQueue = { null } - def onLockup(handler: () => unit): unit = {} - def onLockup(millis: int)(handler: () => unit): unit = {} - def printActorDump: unit = {} + def onLockup(handler: () => Unit) {} + def onLockup(millis: Int)(handler: () => Unit) {} + def printActorDump {} } @@ -237,7 +237,7 @@ class WorkerThread(sched: IScheduler) extends Thread { notify() } - override def run(): unit = + override def run(): Unit = try { while (running) { if (task ne null) { diff --git a/src/actors/scala/actors/TickedScheduler.scala b/src/actors/scala/actors/TickedScheduler.scala index 1cd756fbe4..737384c294 100644 --- a/src/actors/scala/actors/TickedScheduler.scala +++ b/src/actors/scala/actors/TickedScheduler.scala @@ -29,23 +29,23 @@ class TickedScheduler extends Thread with IScheduler { // Worker threads private val workers: Buffer[WorkerThread] = new ArrayBuffer[WorkerThread] private val idle = new Queue[WorkerThread] - private val ticks = new HashMap[WorkerThread, long] + private val ticks = new HashMap[WorkerThread, Long] private var terminating = false private var lastActivity = Platform.currentTime private var pendingReactions = 0 - def pendReaction: unit = synchronized { + def pendReaction: Unit = synchronized { pendingReactions += 1 } - def unPendReaction: unit = synchronized { + def unPendReaction: Unit = synchronized { pendingReactions -= 1 } def printActorDump {} - def start(task: Reaction): unit = synchronized { + def start(task: Reaction): Unit = synchronized { pendingReactions += 1 execute(task) } @@ -61,17 +61,18 @@ class TickedScheduler extends Thread with IScheduler { worker.start() } - def onLockup(handler: () => unit) = + def onLockup(handler: () => Unit) { lockupHandler = handler + } - def onLockup(millis: int)(handler: () => unit) = { + def onLockup(millis: Int)(handler: () => Unit) { //LOCKUP_CHECK_FREQ = millis / CHECK_FREQ lockupHandler = handler } - private var lockupHandler: () => unit = null + private var lockupHandler: () => Unit = null - override def run(): unit = { + override def run() { try { while (!terminating) { this.synchronized { @@ -123,7 +124,7 @@ class TickedScheduler extends Thread with IScheduler { /** * @param item the task to be executed. */ - def execute(item: Reaction): unit = synchronized { + def execute(item: Reaction): Unit = synchronized { if (!terminating) { if (idle.length > 0) { val wt = idle.dequeue @@ -164,7 +165,7 @@ class TickedScheduler extends Thread with IScheduler { /** Shuts down all idle worker threads. */ - def shutdown(): unit = synchronized { + def shutdown(): Unit = synchronized { terminating = true val idleThreads = idle.elements while (idleThreads.hasNext) { diff --git a/src/actors/scala/actors/TimerThread.scala b/src/actors/scala/actors/TimerThread.scala index 73bd9c6551..4252c40253 100644 --- a/src/actors/scala/actors/TimerThread.scala +++ b/src/actors/scala/actors/TimerThread.scala @@ -28,10 +28,10 @@ import scala.compat.Platform object TimerThread { - private case class WakedActor(actor: Actor, f: PartialFunction[Any, Unit], time: long) + private case class WakedActor(actor: Actor, f: PartialFunction[Any, Unit], time: Long) extends Ordered[WakedActor] { var valid = true - def compare(that: WakedActor): int = -(this.time compare that.time) + def compare(that: WakedActor): Int = -(this.time compare that.time) } private var queue = new PriorityQueue[WakedActor] @@ -84,7 +84,7 @@ object TimerThread { } def requestTimeout(a: Actor, f: PartialFunction[Any, Unit], - waitMillis: long): unit = timerThread.synchronized { + waitMillis: Long): Unit = timerThread.synchronized { val wakeTime = now + waitMillis if (waitMillis <= 0) { a ! TIMEOUT @@ -117,8 +117,8 @@ object TimerThread { } } - private def dequeueLateAndGetSleepTime: long = { - val FOREVER: long = 0 + private def dequeueLateAndGetSleepTime: Long = { + val FOREVER: Long = 0 var waitingList: List[WakedActor] = Nil while (!queue.isEmpty) { @@ -134,7 +134,7 @@ object TimerThread { // empty queue => sleep forever lateList = waitingList - return FOREVER + FOREVER } private def now = Platform.currentTime diff --git a/src/compiler/scala/tools/ant/ScalaBazaar.scala b/src/compiler/scala/tools/ant/ScalaBazaar.scala index b3783299fb..09e51866a1 100644 --- a/src/compiler/scala/tools/ant/ScalaBazaar.scala +++ b/src/compiler/scala/tools/ant/ScalaBazaar.scala @@ -299,7 +299,7 @@ package scala.tools.ant { log(file, Project.MSG_DEBUG) zip.putNextEntry(new ZipEntry(destFolder + "/" + file)) val input = new FileInputStream(nameToFile(srcFolder)(file)) - val buf = new Array[byte](10240) + val buf = new Array[Byte](10240) var n = input.read(buf, 0, buf.length) while (n >= 0) { zip.write (buf, 0, n) diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala index 0d237e2fd9..8b8609a38b 100644 --- a/src/compiler/scala/tools/nsc/CompileServer.scala +++ b/src/compiler/scala/tools/nsc/CompileServer.scala @@ -29,11 +29,11 @@ object CompileServer extends SocketServer { val MaxCharge = 0.8 - var shutDown: boolean = false + var shutDown: Boolean = false private var compiler: Global = null - private var inSession: boolean = false - private var progress: boolean = false + private var inSession: Boolean = false + private var progress: Boolean = false private def settingsAreCompatible(s1: Settings, s2: Settings) = s1.encoding.value == s2.encoding.value && @@ -43,13 +43,13 @@ object CompileServer extends SocketServer { s1.bootclasspath.value == s2.bootclasspath.value && s1.extdirs.value == s2.extdirs.value - private def exit(code: int): Nothing = { + private def exit(code: Int): Nothing = { System.err.close() System.out.close() Predef.exit(code) } - private def spawnWatchDog(): unit = spawn { + private def spawnWatchDog(): Unit = spawn { while (true) { Thread.sleep(10000) if (!CompileSocket.portFile(port).exists() && !inSession) { @@ -159,7 +159,7 @@ object CompileServer extends SocketServer { private val redirectDir = new File(CompileSocket.tmpDir, "output-redirects") redirectDir.mkdirs - private def redirect(setter: PrintStream => unit, filename: String) { + private def redirect(setter: PrintStream => Unit, filename: String) { setter( new PrintStream( new BufferedOutputStream( diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala index 82beda4188..ec63ed5be8 100644 --- a/src/compiler/scala/tools/nsc/CompileSocket.scala +++ b/src/compiler/scala/tools/nsc/CompileSocket.scala @@ -191,7 +191,7 @@ object CompileSocket { */ def getOrCreateSocket(vmArgs: String, create: Boolean): Socket = { val nAttempts = 49 // try for about 5 seconds - def getsock(attempts: int): Socket = + def getsock(attempts: Int): Socket = if (attempts == 0) { error("Unable to establish connection to compilation daemon") null @@ -240,7 +240,7 @@ object CompileSocket { } } - def getSocket(hostName: String, port: int): Socket = + def getSocket(hostName: String, port: Int): Socket = try { new Socket(hostName, port) } catch { @@ -249,7 +249,7 @@ object CompileSocket { hostName + ":" + port + "; exiting") } - def getPassword(port: int): String = { + def getPassword(port: Int): String = { val f = new BufferedReader(new FileReader(portFile(port))) val result = f.readLine() f.close() diff --git a/src/compiler/scala/tools/nsc/ConsoleWriter.scala b/src/compiler/scala/tools/nsc/ConsoleWriter.scala index 2faf9aecbf..d5ec1bd61a 100644 --- a/src/compiler/scala/tools/nsc/ConsoleWriter.scala +++ b/src/compiler/scala/tools/nsc/ConsoleWriter.scala @@ -1,15 +1,27 @@ +/* NSC -- new Scala compiler + * Copyright 2006-2007 LAMP/EPFL + * @author Martin Odersky + */ +// $Id$ + package scala.tools.nsc + import java.io.Writer -/** A Writer that writes onto the Scala Console */ +/** A Writer that writes onto the Scala Console. + * + * @author Lex Spoon + * @version 1.0 + */ class ConsoleWriter extends Writer { def close = flush def flush = Console.flush - def write(cbuf: Array[char], off: int, len: int): Unit = - if(len > 0) + def write(cbuf: Array[Char], off: Int, len: Int) { + if (len > 0) write(new String(cbuf.subArray(off, off+len-1))) + } - override def write(str: String): Unit = Console.print(str) + override def write(str: String) { Console.print(str) } } diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 0c7e18c2e9..09c78c33fe 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -237,9 +237,9 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable def apply(unit: CompilationUnit): Unit private val isErased = prev.name == "erasure" || prev.erasedTypes - override def erasedTypes: boolean = isErased + override def erasedTypes: Boolean = isErased private val isFlat = prev.name == "flatten" || prev.flatClasses - override def flatClasses: boolean = isFlat + override def flatClasses: Boolean = isFlat final def applyPhase(unit: CompilationUnit) { if (settings.debug.value) inform("[running phase " + name + " on " + unit + "]") val unit0 = currentRun.currentUnit @@ -441,8 +441,8 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable icodes.init /** Deprecation warnings occurred */ - var deprecationWarnings: boolean = false - var uncheckedWarnings: boolean = false + var deprecationWarnings: Boolean = false + var uncheckedWarnings: Boolean = false private var p: Phase = firstPhase @@ -456,12 +456,12 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable private var phasec: Int = 0 private var unitc: Int = 0 - def advancePhase: Unit = { + def advancePhase { unitc = 0 phasec += 1 refreshProgress } - def advanceUnit: Unit = { + def advanceUnit { unitc += 1 refreshProgress } @@ -506,7 +506,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable val symData = new HashMap[Symbol, PickleBuffer] /** does this run compile given class, module, or case factory? */ - def compiles(sym: Symbol): boolean = + def compiles(sym: Symbol): Boolean = if (sym == NoSymbol) false else if (symSource.isDefinedAt(sym)) true else if (!sym.owner.isPackageClass) compiles(sym.toplevelClass) @@ -615,8 +615,8 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable } } // class Run - def showDef(name: Name, module: boolean) { - def getSym(name: Name, module: boolean): Symbol = { + def showDef(name: Name, module: Boolean) { + def getSym(name: Name, module: Boolean): Symbol = { var i = name.length - 1 while (i != 0 && name(i) != '#' && name(i) != '.') i -= 1 if (i == 0) diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala index fd2fe4cc82..ced42db739 100644 --- a/src/compiler/scala/tools/nsc/Main.scala +++ b/src/compiler/scala/tools/nsc/Main.scala @@ -23,9 +23,10 @@ object Main extends AnyRef with EvalLoop { var reporter: ConsoleReporter = _ - def error(msg: String): unit = + def error(msg: String) { reporter.error(/*new Position */FakePos("scalac"), msg + "\n scalac -help gives more information") + } /* needed ?? */ //def errors() = reporter.errors diff --git a/src/compiler/scala/tools/nsc/MainTokenMetric.scala b/src/compiler/scala/tools/nsc/MainTokenMetric.scala index 37dfd4a39d..f555928a20 100644 --- a/src/compiler/scala/tools/nsc/MainTokenMetric.scala +++ b/src/compiler/scala/tools/nsc/MainTokenMetric.scala @@ -40,7 +40,7 @@ object MainTokenMetric { Console.println(totale.toString()+" total") } - def process(args: Array[String]): unit = { + def process(args: Array[String]) { val settings = new Settings(error) reporter = new ConsoleReporter(settings) val command = new CompilerCommand(List.fromArray(args), settings, error, false) diff --git a/src/compiler/scala/tools/nsc/Phase.scala b/src/compiler/scala/tools/nsc/Phase.scala index a66cdecfde..679c7c8823 100644 --- a/src/compiler/scala/tools/nsc/Phase.scala +++ b/src/compiler/scala/tools/nsc/Phase.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -10,14 +10,14 @@ import symtab.Flags abstract class Phase(val prev: Phase) { - type Id = int + type Id = Int val id: Id = if (prev eq null) 0 else prev.id + 1 - def newFlags: long = 0l - private var fmask: long = + def newFlags: Long = 0l + private var fmask: Long = if (prev eq null) Flags.InitialFlags else prev.flagMask | newFlags - def flagMask: long = fmask + def flagMask: Long = fmask private var nx: Phase = this if (prev ne null) prev.nx = this @@ -26,9 +26,9 @@ abstract class Phase(val prev: Phase) { def name: String def description: String = name - def erasedTypes: boolean = false - def flatClasses: boolean = false - def run: unit + def erasedTypes: Boolean = false + def flatClasses: Boolean = false + def run: Unit override def toString() = name } diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala index 7afc0f5b5c..435d178e4d 100644 --- a/src/compiler/scala/tools/nsc/ScriptRunner.scala +++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala @@ -73,7 +73,7 @@ object ScriptRunner { try { val jarFileStream = new FileOutputStream(jarFile) val jar = new JarOutputStream(jarFileStream) - val buf = new Array[byte](10240) + val buf = new Array[Byte](10240) def addFromDir(dir: File, prefix: String) { for (entry <- dir.listFiles) { diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index a6f6e6120b..dd404250fd 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -187,8 +187,8 @@ class Settings(error: String => Unit) { allsettings = allsettings filter (s !=) } - def checkDependencies: boolean = { - def hasValue(s: Setting, value: String): boolean = s match { + def checkDependencies: Boolean = { + def hasValue(s: Setting, value: String): Boolean = s match { case bs: BooleanSetting => bs.value case ss: StringSetting => ss.value == value case cs: ChoiceSetting => cs.value == value @@ -236,7 +236,7 @@ class Settings(error: String => Unit) { */ def hiddenToIDE: Boolean = false - protected var setByUser: boolean = false + protected var setByUser: Boolean = false def isDefault: Boolean = !setByUser protected[Settings] var dependency: Option[(Setting, String)] = None @@ -254,10 +254,10 @@ class Settings(error: String => Unit) { /** A setting represented by a boolean flag (false, unless set) */ case class BooleanSetting(name: String, descr: String) extends Setting(descr) { - protected var v: boolean = false + protected var v: Boolean = false - def value: boolean = this.v - def value_=(s: boolean) { setByUser = true; this.v = s } + def value: Boolean = this.v + def value_=(s: Boolean) { setByUser = true; this.v = s } def tryToSet(args: List[String]): List[String] = args match { case n :: rest if (n == name) => value = true; rest @@ -429,7 +429,7 @@ class Settings(error: String => Unit) { override def helpSyntax = name + ":<phase>" - def contains(phasename: String): boolean = + def contains(phasename: String): Boolean = value exists (str => phasename startsWith str) def unparse: List[String] = diff --git a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala index 7a847b148b..9e13ce4260 100644 --- a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala @@ -257,7 +257,7 @@ abstract class NodePrinters { if (p.productArity != 0) { println(p.productPrefix+"(") for (elem <- (0 until p.productArity) map p.productElement) { - def printElem(elem: Any, level: int): unit = elem match { + def printElem(elem: Any, level: Int): Unit = elem match { case t: Tree => traverse(t, level, false) case xs: List[_] => @@ -281,6 +281,7 @@ abstract class NodePrinters { buf.toString } } + def printUnit(unit: CompilationUnit) { print("// Scala source: " + unit.source + "\n") if (unit.body ne null) { @@ -290,6 +291,7 @@ abstract class NodePrinters { } println() } + def printAll() { print("[[syntax trees at end of " + phase + "]]") for (unit <- global.currentRun.units) printUnit(unit) diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 5b22fcaaf8..93b74099e7 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -20,7 +20,7 @@ trait Trees { var nodeCount = 0 - case class Modifiers(flags: long, privateWithin: Name, annotations: List[Annotation]) { + case class Modifiers(flags: Long, privateWithin: Name, annotations: List[Annotation]) { def isCovariant = hasFlag(COVARIANT ) def isContravariant = hasFlag(CONTRAVARIANT) def isPrivate = hasFlag(PRIVATE ) @@ -37,18 +37,18 @@ trait Trees { def isTrait = hasFlag(TRAIT ) def isImplicit = hasFlag(IMPLICIT ) def isPublic = !isPrivate && !isProtected - def hasFlag(flag: long) = (flag & flags) != 0 - def & (flag: long): Modifiers = { + def hasFlag(flag: Long) = (flag & flags) != 0 + def & (flag: Long): Modifiers = { val flags1 = flags & flag if (flags1 == flags) this else Modifiers(flags1, privateWithin, annotations) } - def &~ (flag: long): Modifiers = { + def &~ (flag: Long): Modifiers = { val flags1 = flags & (~flag) if (flags1 == flags) this else Modifiers(flags1, privateWithin, annotations) } - def | (flag: long): Modifiers = { + def | (flag: Long): Modifiers = { val flags1 = flags | flag if (flags1 == flags) this else Modifiers(flags1, privateWithin, annotations) @@ -58,8 +58,8 @@ trait Trees { else Modifiers(flags, privateWithin, annotations ::: annots) } - def Modifiers(flags: long, privateWithin: Name): Modifiers = Modifiers(flags, privateWithin, List()) - def Modifiers(flags: long): Modifiers = Modifiers(flags, nme.EMPTY.toTypeName) + def Modifiers(flags: Long, privateWithin: Name): Modifiers = Modifiers(flags, privateWithin, List()) + def Modifiers(flags: Long): Modifiers = Modifiers(flags, nme.EMPTY.toTypeName) val NoMods = Modifiers(0) @@ -224,7 +224,7 @@ trait Trees { case ValDef(mods, _, _, _) => if (mods.isVariable) "var" else "val" case _ => "" } - final def hasFlag(mask: long): boolean = (mods.flags & mask) != 0 + final def hasFlag(mask: Long): Boolean = (mods.flags & mask) != 0 } /** Package clause */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index a742956a48..c9be72308e 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -1,22 +1,22 @@ /* NSC -- new scala compiler - * Copyright 2005 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ -package scala.tools.nsc.backend.icode; +package scala.tools.nsc.backend.icode -import java.io.PrintWriter; +import java.io.PrintWriter -import scala.collection.mutable.HashMap; -import scala.collection.mutable.{Set, HashSet, ListBuffer}; -import scala.{Symbol => scala_Symbol}; +import scala.collection.mutable.HashMap +import scala.collection.mutable.{Set, HashSet, ListBuffer} +import scala.{Symbol => scala_Symbol} -import scala.tools.nsc.symtab.Flags; +import scala.tools.nsc.symtab.Flags trait Members { self: ICodes => - import global._; + import global._ /** * This class represents the intermediate code of a method or @@ -28,17 +28,17 @@ trait Members { self: ICodes => val blocks: ListBuffer[BasicBlock] = new ListBuffer /** The start block of the method */ - var startBlock: BasicBlock = null; + var startBlock: BasicBlock = null /** The stack produced by this method */ - var producedStack: TypeStack = null; + var producedStack: TypeStack = null - private var currentLabel: int = 0; + private var currentLabel: Int = 0 // Constructor code startBlock = newBlock; - def removeBlock(b: BasicBlock) = { + def removeBlock(b: BasicBlock) { if (settings.debug.value) { assert(blocks.forall(p => !(p.successors.contains(b))), "Removing block that is still referenced in method code " + b + "preds: " + b.predecessors); @@ -81,7 +81,7 @@ trait Members { self: ICodes => val visited : HashMap[BasicBlock, Boolean] = new HashMap; visited ++= blocks.elements.map(x => (x, false)); - var blockToVisit : List[BasicBlock] = startBlock::Nil; + var blockToVisit: List[BasicBlock] = List(startBlock) while (!blockToVisit.isEmpty) { blockToVisit match { @@ -118,9 +118,9 @@ trait Members { self: ICodes => /** Represent a class in ICode */ class IClass(val symbol: Symbol) { - var fields: List[IField] = Nil; - var methods: List[IMethod] = Nil; - var cunit: CompilationUnit = _; + var fields: List[IField] = Nil + var methods: List[IMethod] = Nil + var cunit: CompilationUnit = _ def addField(f: IField): this.type = { fields = f :: fields; @@ -219,7 +219,7 @@ trait Members { self: ICodes => def isStatic: Boolean = symbol.hasFlag(Flags.STATIC) || symbol.hasFlag(Flags.STATICMEMBER) || symbol.owner.isImplClass; - override def toString() = symbol.fullNameString; + override def toString() = symbol.fullNameString import opcodes._ def checkLocals: Unit = if (code ne null) { @@ -276,14 +276,14 @@ trait Members { self: ICodes => def dump = { val printer = new TextPrinter(new PrintWriter(Console.out, true), - new DumpLinearizer); - printer.printMethod(this); + new DumpLinearizer) + printer.printMethod(this) } } /** Represent local variables and parameters */ class Local(val sym: Symbol, val kind: TypeKind, val arg: Boolean) { - var index: Int = -1; + var index: Int = -1 /** Starting PC for this local's visbility range. */ var start: Int = _ @@ -299,6 +299,6 @@ trait Members { self: ICodes => other.asInstanceOf[Local].sym == this.sym ); - override def toString(): String = sym.toString(); + override def toString(): String = sym.toString() } } diff --git a/src/compiler/scala/tools/nsc/symtab/Constants.scala b/src/compiler/scala/tools/nsc/symtab/Constants.scala index 6926edf826..9c0628279c 100644 --- a/src/compiler/scala/tools/nsc/symtab/Constants.scala +++ b/src/compiler/scala/tools/nsc/symtab/Constants.scala @@ -32,20 +32,20 @@ trait Constants { final val EnumTag = ClassTag + 1 final val ArrayTag = EnumTag + 1 - def isNumeric(tag: int) = ByteTag <= tag && tag <= DoubleTag + def isNumeric(tag: Int) = ByteTag <= tag && tag <= DoubleTag case class Constant(value: Any) { - val tag: int = - if (value.isInstanceOf[unit]) UnitTag - else if (value.isInstanceOf[boolean]) BooleanTag - else if (value.isInstanceOf[byte]) ByteTag - else if (value.isInstanceOf[short]) ShortTag - else if (value.isInstanceOf[char]) CharTag - else if (value.isInstanceOf[int]) IntTag - else if (value.isInstanceOf[long]) LongTag - else if (value.isInstanceOf[float]) FloatTag - else if (value.isInstanceOf[double]) DoubleTag + val tag: Int = + if (value.isInstanceOf[Unit]) UnitTag + else if (value.isInstanceOf[Boolean]) BooleanTag + else if (value.isInstanceOf[Byte]) ByteTag + else if (value.isInstanceOf[Short]) ShortTag + else if (value.isInstanceOf[Char]) CharTag + else if (value.isInstanceOf[Int]) IntTag + else if (value.isInstanceOf[Long]) LongTag + else if (value.isInstanceOf[Float]) FloatTag + else if (value.isInstanceOf[Double]) DoubleTag else if (value.isInstanceOf[String]) StringTag else if (value.isInstanceOf[Type]) ClassTag else if (value.isInstanceOf[Symbol]) EnumTag @@ -74,90 +74,90 @@ trait Constants { * @param other ... * @return ... */ - override def equals(other: Any): boolean = other match { + override def equals(other: Any): Boolean = other match { case that: Constant => this.value == that.value && this.tag == that.tag case _ => false } - def booleanValue: boolean = - if (tag == BooleanTag) value.asInstanceOf[boolean] + def booleanValue: Boolean = + if (tag == BooleanTag) value.asInstanceOf[Boolean] else throw new Error("value " + value + " is not a boolean"); - def byteValue: byte = tag match { - case ByteTag => value.asInstanceOf[byte] - case ShortTag => value.asInstanceOf[short].asInstanceOf[byte] - case CharTag => value.asInstanceOf[char].asInstanceOf[byte] - case IntTag => value.asInstanceOf[int].asInstanceOf[byte] - case LongTag => value.asInstanceOf[long].asInstanceOf[byte] - case FloatTag => value.asInstanceOf[float].asInstanceOf[byte] - case DoubleTag => value.asInstanceOf[double].asInstanceOf[byte] - case _ => throw new Error("value " + value + " is not a byte") + def byteValue: Byte = tag match { + case ByteTag => value.asInstanceOf[Byte] + case ShortTag => value.asInstanceOf[Short].asInstanceOf[Byte] + case CharTag => value.asInstanceOf[Char].asInstanceOf[Byte] + case IntTag => value.asInstanceOf[Int].asInstanceOf[Byte] + case LongTag => value.asInstanceOf[Long].asInstanceOf[Byte] + case FloatTag => value.asInstanceOf[Float].asInstanceOf[Byte] + case DoubleTag => value.asInstanceOf[Double].asInstanceOf[Byte] + case _ => throw new Error("value " + value + " is not a Byte") } - def shortValue: short = tag match { - case ByteTag => value.asInstanceOf[byte].asInstanceOf[short] - case ShortTag => value.asInstanceOf[short] - case CharTag => value.asInstanceOf[char].asInstanceOf[short] - case IntTag => value.asInstanceOf[int].asInstanceOf[short] - case LongTag => value.asInstanceOf[long].asInstanceOf[short] - case FloatTag => value.asInstanceOf[float].asInstanceOf[short] - case DoubleTag => value.asInstanceOf[double].asInstanceOf[short] - case _ => throw new Error("value " + value + " is not a short") + def shortValue: Short = tag match { + case ByteTag => value.asInstanceOf[Byte].asInstanceOf[Short] + case ShortTag => value.asInstanceOf[Short] + case CharTag => value.asInstanceOf[Char].asInstanceOf[Short] + case IntTag => value.asInstanceOf[Int].asInstanceOf[Short] + case LongTag => value.asInstanceOf[Long].asInstanceOf[Short] + case FloatTag => value.asInstanceOf[Float].asInstanceOf[Short] + case DoubleTag => value.asInstanceOf[Double].asInstanceOf[Short] + case _ => throw new Error("value " + value + " is not a Short") } - def charValue: char = tag match { - case ByteTag => value.asInstanceOf[byte].asInstanceOf[char] - case ShortTag => value.asInstanceOf[short].asInstanceOf[char] - case CharTag => value.asInstanceOf[char] - case IntTag => value.asInstanceOf[int].asInstanceOf[char] - case LongTag => value.asInstanceOf[long].asInstanceOf[char] - case FloatTag => value.asInstanceOf[float].asInstanceOf[char] - case DoubleTag => value.asInstanceOf[double].asInstanceOf[char] - case _ => throw new Error("value " + value + " is not a char") + def charValue: Char = tag match { + case ByteTag => value.asInstanceOf[Byte].asInstanceOf[Char] + case ShortTag => value.asInstanceOf[Short].asInstanceOf[Char] + case CharTag => value.asInstanceOf[Char] + case IntTag => value.asInstanceOf[Int].asInstanceOf[Char] + case LongTag => value.asInstanceOf[Long].asInstanceOf[Char] + case FloatTag => value.asInstanceOf[Float].asInstanceOf[Char] + case DoubleTag => value.asInstanceOf[Double].asInstanceOf[Char] + case _ => throw new Error("value " + value + " is not a Char") } - def intValue: int = tag match { - case ByteTag => value.asInstanceOf[byte].asInstanceOf[int] - case ShortTag => value.asInstanceOf[short].asInstanceOf[int] - case CharTag => value.asInstanceOf[char].asInstanceOf[int] - case IntTag => value.asInstanceOf[int] - case LongTag => value.asInstanceOf[long].asInstanceOf[int] - case FloatTag => value.asInstanceOf[float].asInstanceOf[int] - case DoubleTag => value.asInstanceOf[double].asInstanceOf[int] - case _ => throw new Error("value " + value + " is not an int") + def intValue: Int = tag match { + case ByteTag => value.asInstanceOf[Byte].asInstanceOf[Int] + case ShortTag => value.asInstanceOf[Short].asInstanceOf[Int] + case CharTag => value.asInstanceOf[Char].asInstanceOf[Int] + case IntTag => value.asInstanceOf[Int] + case LongTag => value.asInstanceOf[Long].asInstanceOf[Int] + case FloatTag => value.asInstanceOf[Float].asInstanceOf[Int] + case DoubleTag => value.asInstanceOf[Double].asInstanceOf[Int] + case _ => throw new Error("value " + value + " is not an Int") } - def longValue: long = tag match { - case ByteTag => value.asInstanceOf[byte].asInstanceOf[long] - case ShortTag => value.asInstanceOf[short].asInstanceOf[long] - case CharTag => value.asInstanceOf[char].asInstanceOf[long] - case IntTag => value.asInstanceOf[int].asInstanceOf[long] - case LongTag => value.asInstanceOf[long] - case FloatTag => value.asInstanceOf[float].asInstanceOf[long] - case DoubleTag => value.asInstanceOf[double].asInstanceOf[long] - case _ => throw new Error("value " + value + " is not a long") + def longValue: Long = tag match { + case ByteTag => value.asInstanceOf[Byte].asInstanceOf[Long] + case ShortTag => value.asInstanceOf[Short].asInstanceOf[Long] + case CharTag => value.asInstanceOf[Char].asInstanceOf[Long] + case IntTag => value.asInstanceOf[Int].asInstanceOf[Long] + case LongTag => value.asInstanceOf[Long] + case FloatTag => value.asInstanceOf[Float].asInstanceOf[Long] + case DoubleTag => value.asInstanceOf[Double].asInstanceOf[Long] + case _ => throw new Error("value " + value + " is not a Long") } - def floatValue: float = tag match { - case ByteTag => value.asInstanceOf[byte].asInstanceOf[float] - case ShortTag => value.asInstanceOf[short].asInstanceOf[float] - case CharTag => value.asInstanceOf[char].asInstanceOf[float] - case IntTag => value.asInstanceOf[int].asInstanceOf[float] - case LongTag => value.asInstanceOf[long].asInstanceOf[float] - case FloatTag => value.asInstanceOf[float] - case DoubleTag => value.asInstanceOf[double].asInstanceOf[float] - case _ => throw new Error("value " + value + " is not a float") + def floatValue: Float = tag match { + case ByteTag => value.asInstanceOf[Byte].asInstanceOf[Float] + case ShortTag => value.asInstanceOf[Short].asInstanceOf[Float] + case CharTag => value.asInstanceOf[Char].asInstanceOf[Float] + case IntTag => value.asInstanceOf[Int].asInstanceOf[Float] + case LongTag => value.asInstanceOf[Long].asInstanceOf[Float] + case FloatTag => value.asInstanceOf[Float] + case DoubleTag => value.asInstanceOf[Double].asInstanceOf[Float] + case _ => throw new Error("value " + value + " is not a Float") } - def doubleValue: double = tag match { - case ByteTag => value.asInstanceOf[byte].asInstanceOf[double] - case ShortTag => value.asInstanceOf[short].asInstanceOf[double] - case CharTag => value.asInstanceOf[char].asInstanceOf[double] - case IntTag => value.asInstanceOf[int].asInstanceOf[double] - case LongTag => value.asInstanceOf[long].asInstanceOf[double] - case FloatTag => value.asInstanceOf[float].asInstanceOf[double] - case DoubleTag => value.asInstanceOf[double] - case _ => throw new Error("value " + value + " is not a double") + def doubleValue: Double = tag match { + case ByteTag => value.asInstanceOf[Byte].asInstanceOf[Double] + case ShortTag => value.asInstanceOf[Short].asInstanceOf[Double] + case CharTag => value.asInstanceOf[Char].asInstanceOf[Double] + case IntTag => value.asInstanceOf[Int].asInstanceOf[Double] + case LongTag => value.asInstanceOf[Long].asInstanceOf[Double] + case FloatTag => value.asInstanceOf[Float].asInstanceOf[Double] + case DoubleTag => value.asInstanceOf[Double] + case _ => throw new Error("value " + value + " is not a Double") } /** Convert constant value to conform to given type. @@ -223,7 +223,7 @@ trait Constants { def arrayValue: Array[Constant] = throw new Error("value " + value + " is not an array") - override def hashCode(): int = + override def hashCode(): Int = if (value == null) 0 else value.hashCode() * 41 + 17 } diff --git a/src/compiler/scala/tools/nsc/symtab/Flags.scala b/src/compiler/scala/tools/nsc/symtab/Flags.scala index f9296da61b..bfee9e8597 100644 --- a/src/compiler/scala/tools/nsc/symtab/Flags.scala +++ b/src/compiler/scala/tools/nsc/symtab/Flags.scala @@ -83,18 +83,18 @@ object Flags extends Enumeration { final val AntiShift = 52L // late flags (set by a transformer phase) - final val latePRIVATE = (PRIVATE: long) << LateShift - final val lateDEFERRED = (DEFERRED: long) << LateShift - final val lateINTERFACE = (INTERFACE: long) << LateShift - final val lateMODULE = (MODULE: long) << LateShift - final val lateFINAL = (FINAL: long) << LateShift - final val lateMETHOD = (METHOD: long) << LateShift - final val notPRIVATE = (PRIVATE: long) << AntiShift - final val notDEFERRED = (DEFERRED: long) << AntiShift - final val notPROTECTED = (PROTECTED: long) << AntiShift - final val notABSTRACT = (ABSTRACT: long) << AntiShift - final val notOVERRIDE = (OVERRIDE: long) << AntiShift - final val notMETHOD = (METHOD: long) << AntiShift + final val latePRIVATE = (PRIVATE: Long) << LateShift + final val lateDEFERRED = (DEFERRED: Long) << LateShift + final val lateINTERFACE = (INTERFACE: Long) << LateShift + final val lateMODULE = (MODULE: Long) << LateShift + final val lateFINAL = (FINAL: Long) << LateShift + final val lateMETHOD = (METHOD: Long) << LateShift + final val notPRIVATE = (PRIVATE: Long) << AntiShift + final val notDEFERRED = (DEFERRED: Long) << AntiShift + final val notPROTECTED = (PROTECTED: Long) << AntiShift + final val notABSTRACT = (ABSTRACT: Long) << AntiShift + final val notOVERRIDE = (OVERRIDE: Long) << AntiShift + final val notMETHOD = (METHOD: Long) << AntiShift final val STATICMODULE = lateMODULE final val STATICMEMBER = notOVERRIDE @@ -129,10 +129,10 @@ object Flags extends Enumeration { private def listToString(ss: List[String]): String = ss.filter("" !=).mkString("", " ", "") - def flagsToString(flags: long): String = + def flagsToString(flags: Long): String = listToString(for (i <- List.range(0, 63)) yield flagToString(flags & (1L << i))) - def flagsToString(flags: long, privateWithin: String): String = { + def flagsToString(flags: Long, privateWithin: String): String = { var f = flags val pw = if (privateWithin == "") { @@ -154,7 +154,7 @@ object Flags extends Enumeration { listToString(List(flagsToString(f), pw)) } - private def flagToString(flag: long): String = { + private def flagToString(flag: Long): String = { if (flag == IS_ERROR) "<is-error>" else if (flag == OVERLOADED ) "<overloaded>" else if (flag == LIFTED ) "<lifted>" @@ -163,7 +163,7 @@ object Flags extends Enumeration { else if (flag == IMPLCLASS ) "<implclass/presuper>" else if (flag == TRANS_FLAG ) "<trans-flag>" else if (flag == LOCKED ) "<locked>" - else flag.asInstanceOf[int] match { + else flag.asInstanceOf[Int] match { case IMPLICIT => "implicit" case FINAL => "final" case PRIVATE => "private" @@ -206,7 +206,7 @@ object Flags extends Enumeration { } } - class Flag(mods: int) { + class Flag(mods: Int) { def isPrivate = (mods & PRIVATE ) != 0 def isProtected = (mods & PROTECTED) != 0 def isVariable = (mods & MUTABLE) != 0 diff --git a/src/compiler/scala/tools/nsc/symtab/Names.scala b/src/compiler/scala/tools/nsc/symtab/Names.scala index a27a2e5197..16d6a0f886 100644 --- a/src/compiler/scala/tools/nsc/symtab/Names.scala +++ b/src/compiler/scala/tools/nsc/symtab/Names.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -26,7 +26,7 @@ class Names { /** memory to store all names sequentially */ - var chrs: Array[char] = new Array[char](NAME_SIZE) + var chrs: Array[Char] = new Array[Char](NAME_SIZE) private var nc = 0 /** hashtable for finding term names quickly @@ -39,7 +39,7 @@ class Names { /** the hashcode of a name */ - private def hashValue(cs: Array[char], offset: int, len: int): int = + private def hashValue(cs: Array[Char], offset: Int, len: Int): Int = if (len > 0) (len * (41 * 41 * 41) + cs(offset) * (41 * 41) + @@ -56,7 +56,7 @@ class Names { * @param len ... * @return ... */ - private def equals(index: int, cs: Array[char], offset: int, len: int): boolean = { + private def equals(index: Int, cs: Array[Char], offset: Int, len: Int): Boolean = { var i = 0 while ((i < len) && (chrs(index + i) == cs(offset + i))) i = i + 1; @@ -65,18 +65,18 @@ class Names { /** enter characters into chrs array */ - private def enterChars(cs: Array[char], offset: int, len: int): unit = { + private def enterChars(cs: Array[Char], offset: Int, len: Int): unit = { var i = 0 while (i < len) { if (nc + i == chrs.length) { - val newchrs = new Array[char](chrs.length * 2) + val newchrs = new Array[Char](chrs.length * 2) Array.copy(chrs, 0, newchrs, 0, chrs.length) chrs = newchrs } chrs(nc + i) = cs(offset + i) - i = i + 1 + i += 1 } - if (len == 0) nc = nc + 1 + if (len == 0) nc += 1 else nc = nc + len } @@ -87,9 +87,9 @@ class Names { * @param len ... * @return the created term name */ - def newTermName(cs: Array[char], offset: int, len: int): Name = { - val h = hashValue(cs, offset, len) & HASH_MASK; - var n = termHashtable(h); + def newTermName(cs: Array[Char], offset: Int, len: Int): Name = { + val h = hashValue(cs, offset, len) & HASH_MASK + var n = termHashtable(h) while ((n ne null) && (n.length != len || !equals(n.start, cs, offset, len))) n = n.next; if (n eq null) { @@ -111,8 +111,8 @@ class Names { * @param len ... * @return the created term name */ - def newTermName(bs: Array[byte], offset: int, len: int): Name = { - val cs = new Array[char](bs.length) + def newTermName(bs: Array[Byte], offset: Int, len: Int): Name = { + val cs = new Array[Char](bs.length) val nchrs = UTF8Codec.decode(bs, offset, cs, 0, len) newTermName(cs, 0, nchrs) } @@ -124,7 +124,7 @@ class Names { * @param len ... * @return the created type name */ - def newTypeName(cs: Array[char], offset: int, len: int): Name = + def newTypeName(cs: Array[Char], offset: Int, len: Int): Name = newTermName(cs, offset, len).toTypeName /** create a type name from string @@ -139,21 +139,21 @@ class Names { * @param len ... * @return the create type name */ - def newTypeName(bs: Array[byte], offset: int, len: int): Name = + def newTypeName(bs: Array[Byte], offset: Int, len: Int): Name = newTermName(bs, offset, len).toTypeName - def nameChars: Array[char] = chrs + def nameChars: Array[Char] = chrs implicit def view(s: String): Name = newTermName(s) // Classes ---------------------------------------------------------------------- /** The name class. */ - abstract class Name(index: int, len: int) extends Function1[int, char] { + abstract class Name(index: Int, len: Int) extends Function1[Int, Char] { /** Index into name table */ - def start: int = index + def start: Int = index /** next name in the same hash bucket */ @@ -161,12 +161,12 @@ class Names { /** return the length of this name */ - final def length: int = len + final def length: Int = len final def isEmpty = length == 0 - def isTermName: boolean - def isTypeName: boolean + def isTermName: Boolean + def isTypeName: Boolean def toTermName: Name def toTypeName: Name @@ -177,13 +177,13 @@ class Names { * @param cs ... * @param offset ... */ - final def copyChars(cs: Array[char], offset: int) = + final def copyChars(cs: Array[Char], offset: Int) = Array.copy(chrs, index, cs, offset, len) /** return the ascii representation of this name */ final def toChars = { - val cs = new Array[char](len) + val cs = new Array[Char](len) copyChars(cs, 0) cs } @@ -197,22 +197,22 @@ class Names { * Array must have enough remaining space for all bytes * (i.e. maximally 3*length bytes). */ - final def copyUTF8(bs: Array[byte], offset: int): int = + final def copyUTF8(bs: Array[Byte], offset: Int): Int = UTF8Codec.encode(chrs, index, bs, offset, len) /** return the hash value of this name */ - final override def hashCode(): int = index + final override def hashCode(): Int = index - /** return the i'th char of this name + /** return the i'th Char of this name */ - final def apply(i: int): char = chrs(index + i) + final def apply(i: Int): Char = chrs(index + i) /** return the index of first occurrence of char c in this name, length if not found */ - final def pos(c: char): int = pos(c, 0) + final def pos(c: Char): Int = pos(c, 0) /** return the index of first occurrence of char c in this name, length if not found */ - final def pos(s: String): int = pos(s, 0) + final def pos(s: String): Int = pos(s, 0) /** return the index of the first occurrence of character <code>c</code> in * this name from <code>start</code>, length if not found. @@ -221,9 +221,9 @@ class Names { * @param start ... * @return the index of the first occurrence of <code>c</code> */ - final def pos(c: char, start: int): int = { + final def pos(c: Char, start: Int): Int = { var i = start - while (i < len && chrs(index + i) != c) i = i + 1 + while (i < len && chrs(index + i) != c) i += 1 i } @@ -234,12 +234,12 @@ class Names { * @param start ... * @return the index of the first occurrence of <code>s</code> */ - final def pos(s: String, start: int): int = { + final def pos(s: String, start: Int): Int = { var i = pos(s.charAt(0), start) while (i + s.length() <= len) { var j = 1 while (s.charAt(j) == chrs(index + i + j)) { - j = j + 1 + j += 1 if (j == s.length()) return i } i = pos(s.charAt(0), i + 1) @@ -253,9 +253,9 @@ class Names { * @param c the character * @return the index of the last occurrence of <code>c</code> */ - final def lastPos(c: char): int = lastPos(c, len - 1) + final def lastPos(c: Char): Int = lastPos(c, len - 1) - final def lastPos(s: String): int = lastPos(s, len - s.length()) + final def lastPos(s: String): Int = lastPos(s, len - s.length()) /** return the index of the last occurrence of char <code>c</code> in this * name from <code>start</code>, <code>-1</code> if not found. @@ -264,9 +264,9 @@ class Names { * @param start ... * @return the index of the last occurrence of <code>c</code> */ - final def lastPos(c: char, start: int): int = { + final def lastPos(c: Char, start: Int): Int = { var i = start - while (i >= 0 && chrs(index + i) != c) i = i - 1 + while (i >= 0 && chrs(index + i) != c) i -= 1 i } @@ -277,12 +277,12 @@ class Names { * @param start ... * @return the index of the last occurrence of <code>s</code> */ - final def lastPos(s: String, start: int): int = { + final def lastPos(s: String, start: Int): Int = { var i = lastPos(s.charAt(0), start) while (i >= 0) { var j = 1; while (s.charAt(j) == chrs(index + i + j)) { - j = j + 1; + j += 1 if (j == s.length()) return i; } i = lastPos(s.charAt(0), i - 1) @@ -292,29 +292,29 @@ class Names { /** does this name start with prefix? */ - final def startsWith(prefix: Name): boolean = startsWith(prefix, 0) + final def startsWith(prefix: Name): Boolean = startsWith(prefix, 0) /** does this name start with prefix at given start index? */ - final def startsWith(prefix: Name, start: int): boolean = { + final def startsWith(prefix: Name, start: Int): Boolean = { var i = 0 while (i < prefix.length && start + i < len && chrs(index + start + i) == chrs(prefix.start + i)) - i = i + 1; + i += 1; i == prefix.length } /** does this name end with suffix? */ - final def endsWith(suffix: Name): boolean = endsWith(suffix, len) + final def endsWith(suffix: Name): Boolean = endsWith(suffix, len) /** does this name end with suffix just before given end index? */ - final def endsWith(suffix: Name, end: int): boolean = { + final def endsWith(suffix: Name, end: Int): Boolean = { var i = 1 while (i <= suffix.length && i <= end && chrs(index + end - i) == chrs(suffix.start + suffix.length - i)) - i = i + 1; + i += 1; i > suffix.length } @@ -324,7 +324,7 @@ class Names { * @param to ... * @return ... */ - def subName(from: int, to: int): Name + def subName(from: Int, to: Int): Name /** Replace all occurrences of <code>from</code> by </code>to</code> in * name; result is always a term name. @@ -333,13 +333,13 @@ class Names { * @param to ... * @return ... */ - def replace(from: char, to: char): Name = { - val cs = new Array[char](len) + def replace(from: Char, to: Char): Name = { + val cs = new Array[Char](len) var i = 0 while (i < len) { val ch = this(i) cs(i) = if (ch == from) to else ch - i = i + 1 + i += 1 } newTermName(cs, 0, len) } @@ -361,11 +361,11 @@ class Names { (if (nameDebug && isTypeName) "!" else ""))//debug } - private class TermName(index: int, len: int, hash: int) extends Name(index, len) { + private class TermName(index: Int, len: Int, hash: Int) extends Name(index, len) { next = termHashtable(hash) termHashtable(hash) = this - def isTermName: boolean = true - def isTypeName: boolean = false + def isTermName: Boolean = true + def isTypeName: Boolean = false def toTermName: Name = this def toTypeName = { val h = hashValue(chrs, index, len) & HASH_MASK @@ -376,15 +376,15 @@ class Names { n = new TypeName(index, len, h); n } - def subName(from: int, to: int): Name = + def subName(from: Int, to: Int): Name = newTermName(chrs, start + from, to - from) } - private class TypeName(index: int, len: int, hash: int) extends Name(index, len) { + private class TypeName(index: Int, len: Int, hash: Int) extends Name(index, len) { next = typeHashtable(hash) typeHashtable(hash) = this - def isTermName: boolean = false - def isTypeName: boolean = true + def isTermName: Boolean = false + def isTypeName: Boolean = true def toTermName: Name = { val h = hashValue(chrs, index, len) & HASH_MASK var n = termHashtable(h) @@ -395,7 +395,7 @@ class Names { n } def toTypeName: Name = this - def subName(from: int, to: int): Name = + def subName(from: Int, to: Int): Name = newTypeName(chrs, start + from, to - from) } } diff --git a/src/compiler/scala/tools/nsc/symtab/Scopes.scala b/src/compiler/scala/tools/nsc/symtab/Scopes.scala index 5a60a899da..3cb50c09ab 100644 --- a/src/compiler/scala/tools/nsc/symtab/Scopes.scala +++ b/src/compiler/scala/tools/nsc/symtab/Scopes.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -22,7 +22,7 @@ trait Scopes { */ var next: ScopeEntry = null - override def hashCode(): int = sym.name.start + override def hashCode(): Int = sym.name.start override def toString(): String = sym.toString() } @@ -61,8 +61,8 @@ trait Scopes { /** hook for IDE */ - protected def enter0(sym : Symbol) : Unit = {} - private[Scopes] def enter00(sym : Symbol) = enter0(sym); + protected def enter0(sym: Symbol) {} + private[Scopes] def enter00(sym: Symbol) = enter0(sym) /** The number of times this scope is neted in another */ @@ -114,10 +114,10 @@ trait Scopes { } /** is the scope empty? */ - def isEmpty: boolean = elems eq null + def isEmpty: Boolean = elems eq null /** the number of entries in this scope */ - def size: int = { + def size: Int = { var s = 0 var e = elems while (e ne null) { @@ -152,29 +152,30 @@ trait Scopes { * * @param sym ... */ - def enterUnique(sym: Symbol): unit = { + def enterUnique(sym: Symbol) { assert(lookup(sym.name) == NoSymbol) enter(sym) } - def createHash(): unit = { + def createHash() { hashtable = new Array[ScopeEntry](HASHSIZE) enterInHash(elems) } - private def enterInHash(e: ScopeEntry): unit = + private def enterInHash(e: ScopeEntry) { if (e ne null) { enterInHash(e.next) val i = e.sym.name.start & HASHMASK e.tail = hashtable(i) hashtable(i) = e } + } /** remove entry * * @param e ... */ - def unlink(e: ScopeEntry): unit = { + def unlink(e: ScopeEntry) { if (elems == e) { elems = e.next } else { @@ -195,7 +196,7 @@ trait Scopes { } /** remove symbol */ - def unlink(sym: Symbol): unit = { + def unlink(sym: Symbol) { var e = lookupEntry(sym.name) while (e ne null) { if (e.sym == sym) unlink(e); @@ -262,7 +263,7 @@ trait Scopes { */ def elements: Iterator[Symbol] = toList.elements - def filter(p: Symbol => boolean): Scope = + def filter(p: Symbol => Boolean): Scope = if (!(toList forall p)) newScope(toList filter p) else this def mkString(start: String, sep: String, end: String) = diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 230c92afbd..8019cc7840 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -35,7 +35,7 @@ abstract class SymbolLoaders { abstract class SymbolLoader extends LazyType { /** Load source or class file for `root', return */ - protected def doComplete(root: Symbol): unit + protected def doComplete(root: Symbol): Unit /** The kind of file that's processed by this loader */ protected def kindString: String @@ -132,7 +132,7 @@ abstract class SymbolLoaders { root.setInfo(new PackageClassInfoType(scope, root)) /** Is the given name a valid input file base name? */ - def isValid(name: String): boolean = + def isValid(name: String): Boolean = name.length() > 0 && !name.endsWith("$class") && (settings.XbytecodeRead.value || (name.indexOf("$anon") == -1)); @@ -273,7 +273,7 @@ abstract class SymbolLoaders { } */ class SourcefileLoader(override val sourceFile: AbstractFile) extends SymbolLoader { - protected def doComplete(root: Symbol): unit = + protected def doComplete(root: Symbol): Unit = global.currentRun.compileLate(sourceFile) protected def kindString: String = "source file" protected def sourceString = sourceFile.toString() diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala index c066492fe1..3f01544107 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala @@ -1,8 +1,9 @@ /* NSC -- new scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ + package scala.tools.nsc.symtab import util._ @@ -19,25 +20,26 @@ abstract class SymbolTable extends Names { def settings: Settings def rootLoader: LazyType - def log(msg: AnyRef): unit + def log(msg: AnyRef) /** Are we compiling for the J2ME CLDC platform? */ def forCLDC: Boolean /** Are we compiling for .NET*/ def forMSIL: Boolean + /** are we in a lampion presentation compiler? then disable caching. */ - def inIDE : Boolean; + def inIDE : Boolean /** A period is an ordinal number for a phase in a run. * Phases in later runs have higher periods than phases in earlier runs. * Later phases have higher periods than earlier phases in the same run. */ - type Period = int + type Period = Int final val NoPeriod = 0 /** An ordinal number for compiler runs. First run has number 1. */ - type RunId = int + type RunId = Int final val NoRunId = 0 private var ph: Phase = NoPhase @@ -45,7 +47,7 @@ abstract class SymbolTable extends Names final def phase: Phase = ph - final def phase_=(p: Phase): unit = { + final def phase_=(p: Phase) { //System.out.println("setting phase to " + p) assert((p ne null) && p != NoPhase) ph = p diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index f3f48d3c72..cca6ba2b46 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -40,7 +40,7 @@ trait Symbols { var rawowner = initOwner var rawname = initName - var rawflags: long = 0 + var rawflags: Long = 0 private var rawpos = initPos val id = { ids += 1; ids } @@ -238,7 +238,7 @@ trait Symbols { isTerm && !hasFlag(MUTABLE) && (!hasFlag(METHOD | BYNAMEPARAM) || hasFlag(STABLE)) /** Is this symbol a public */ - final def isPublic: boolean = + final def isPublic: Boolean = !hasFlag(PRIVATE | PROTECTED) && privateWithin == NoSymbol /** Is this symbol a private local */ @@ -258,49 +258,49 @@ trait Symbols { isMethod && hasFlag(CASE) /** Is this symbol an implementation class for a mixin? */ - final def isImplClass: boolean = isClass && hasFlag(IMPLCLASS) + final def isImplClass: Boolean = isClass && hasFlag(IMPLCLASS) /** Is thhis symbol early initialized */ - final def isEarly: boolean = isTerm && hasFlag(PRESUPER) + final def isEarly: Boolean = isTerm && hasFlag(PRESUPER) /** Is this symbol a trait which needs an implementation class? */ - final def needsImplClass: boolean = + final def needsImplClass: Boolean = isTrait && (!hasFlag(INTERFACE) || hasFlag(lateINTERFACE)) && !isImplClass /** Is this a symbol which exists only in the implementation class, not in its trait? */ - final def isImplOnly: boolean = + final def isImplOnly: Boolean = hasFlag(PRIVATE) || (owner.isImplClass || owner.isTrait) && ((hasFlag(notPRIVATE | LIFTED) && !hasFlag(ACCESSOR | SUPERACCESSOR | MODULE) || isConstructor) || (hasFlag(LIFTED) && isModule && isMethod)) /** Is this symbol a module variable ? */ - final def isModuleVar: boolean = isVariable && hasFlag(MODULEVAR) + final def isModuleVar: Boolean = isVariable && hasFlag(MODULEVAR) /** Is this symbol static (i.e. with no outer instance)? */ - final def isStatic: boolean = + final def isStatic: Boolean = hasFlag(STATIC) || isRoot || owner.isStaticOwner /** Does this symbol denote a class that defines static symbols? */ - final def isStaticOwner: boolean = + final def isStaticOwner: Boolean = isPackageClass || isModuleClass && isStatic /** Is this symbol final?*/ - final def isFinal: boolean = ( + final def isFinal: Boolean = ( hasFlag(FINAL) || isTerm && ( hasFlag(PRIVATE) || isLocal || owner.isClass && owner.hasFlag(FINAL | MODULE)) ) /** Is this symbol a sealed class?*/ - final def isSealed: boolean = + final def isSealed: Boolean = isClass && (hasFlag(SEALED) || isUnboxedClass(this)) /** Is this symbol locally defined? I.e. not accessed from outside `this' instance */ - final def isLocal: boolean = owner.isTerm + final def isLocal: Boolean = owner.isTerm /** Is this symbol a constant? */ - final def isConstant: boolean = + final def isConstant: Boolean = isStable && (tpe match { case ConstantType(_) => true case PolyType(_, ConstantType(_)) => true @@ -309,7 +309,7 @@ trait Symbols { }) /** Is this class nested in another class or module (not a package)? */ - final def isNestedClass: boolean = + final def isNestedClass: Boolean = isClass && !isRoot && !owner.isPackageClass /** Is this class locally defined? @@ -318,7 +318,7 @@ trait Symbols { * - its owner is a value * - it is defined within a local class */ - final def isLocalClass: boolean = + final def isLocalClass: Boolean = isClass && (isAnonymousClass || isRefinementClass || isLocal || !owner.isPackageClass && owner.isLocalClass) @@ -330,7 +330,7 @@ trait Symbols { * @param base ... * @return ... */ - final def isIncompleteIn(base: Symbol): boolean = ( + final def isIncompleteIn(base: Symbol): Boolean = ( (this hasFlag DEFERRED) || (this hasFlag ABSOVERRIDE) && { val supersym = superSymbol(base) @@ -338,15 +338,15 @@ trait Symbols { } ) - final def exists: boolean = + final def exists: Boolean = this != NoSymbol && (!owner.isPackageClass || { rawInfo.load(this); rawInfo != NoType }) - final def isInitialized: boolean = + final def isInitialized: Boolean = validTo != NoPeriod - final def isCovariant: boolean = isType && hasFlag(COVARIANT) + final def isCovariant: Boolean = isType && hasFlag(COVARIANT) - final def isContravariant: boolean = isType && hasFlag(CONTRAVARIANT) + final def isContravariant: Boolean = isType && hasFlag(CONTRAVARIANT) /** The variance of this symbol as an integer */ final def variance: int = @@ -357,29 +357,29 @@ trait Symbols { // Flags, owner, and name attributes -------------------------------------------------------------- def owner: Symbol = rawowner - final def owner_=(owner: Symbol): unit = { rawowner = owner } + final def owner_=(owner: Symbol) { rawowner = owner } def ownerChain: List[Symbol] = this :: owner.ownerChain def name: Name = rawname - final def name_=(name: Name): unit = { rawname = name } + final def name_=(name: Name) { rawname = name } /** If this symbol has an expanded name, its original name, otherwise its name itself. * @see expandName */ def originalName = nme.originalName(name) - final def flags: long = { + final def flags: Long = { val fs = rawflags & phase.flagMask (fs | ((fs & LateFlags) >>> LateShift)) & ~(fs >>> AntiShift) } - final def flags_=(fs: long) = rawflags = fs - final def setFlag(mask: long): this.type = { rawflags = rawflags | mask; this } - final def resetFlag(mask: long): this.type = { rawflags = rawflags & ~mask; this } - final def getFlag(mask: long): long = flags & mask - final def hasFlag(mask: long): boolean = (flags & mask) != 0 - final def resetFlags: unit = { rawflags = rawflags & TopLevelCreationFlags } + final def flags_=(fs: Long) = rawflags = fs + final def setFlag(mask: Long): this.type = { rawflags = rawflags | mask; this } + final def resetFlag(mask: Long): this.type = { rawflags = rawflags & ~mask; this } + final def getFlag(mask: Long): Long = flags & mask + final def hasFlag(mask: Long): Boolean = (flags & mask) != 0 + final def resetFlags { rawflags = rawflags & TopLevelCreationFlags } /** The class up to which this symbol is accessible, * or NoSymbol if it is public or not a class member @@ -533,7 +533,7 @@ trait Symbols { } /** Was symbol's type updated during given phase? */ - final def isUpdatedAt(pid: Phase#Id): boolean = { + final def isUpdatedAt(pid: Phase#Id): Boolean = { var infos = this.infos while ((infos ne null) && phaseId(infos.validFrom) != pid + 1) infos = infos.prev infos ne null @@ -565,7 +565,7 @@ trait Symbols { /** Reset symbol to initial state */ - def reset(completer: Type): unit = { + def reset(completer: Type) { resetFlags infos = null validTo = NoPeriod @@ -579,7 +579,7 @@ trait Symbols { * inheritance graph (i.e. subclass.isLess(superclass) always holds). * the ordering is given by: (isType, -|closure| for type symbols, id) */ - final def isLess(that: Symbol): boolean = { + final def isLess(that: Symbol): Boolean = { def closureLength(sym: Symbol) = if (sym.isAbstractType) 1 + sym.info.bounds.hi.closure.length else sym.info.closure.length @@ -595,15 +595,15 @@ trait Symbols { * (this isNestedIn that) holds iff this symbol is defined within * a class or method defining that symbol */ - final def isNestedIn(that: Symbol): boolean = + final def isNestedIn(that: Symbol): Boolean = owner == that || owner != NoSymbol && (owner isNestedIn that) /** Is this class symbol a subclass of that symbol? */ - final def isNonBottomSubClass(that: Symbol): boolean = + final def isNonBottomSubClass(that: Symbol): Boolean = this == that || this.isError || that.isError || info.closurePos(that) >= 0 - final def isSubClass(that: Symbol): boolean = { + final def isSubClass(that: Symbol): Boolean = { isNonBottomSubClass(that) || this == AllClass || this == AllRefClass && @@ -617,7 +617,7 @@ trait Symbols { if (hasFlag(OVERLOADED)) info.asInstanceOf[OverloadedType].alternatives else List(this) - def filter(cond: Symbol => boolean): Symbol = + def filter(cond: Symbol => Boolean): Symbol = if (hasFlag(OVERLOADED)) { //assert(info.isInstanceOf[OverloadedType], "" + this + ":" + info);//DEBUG val alts = alternatives @@ -629,7 +629,7 @@ trait Symbols { } else if (cond(this)) this else NoSymbol - def suchThat(cond: Symbol => boolean): Symbol = { + def suchThat(cond: Symbol => Boolean): Symbol = { val result = filter(cond) assert(!(result hasFlag OVERLOADED), result.alternatives) result @@ -674,7 +674,7 @@ trait Symbols { def typeOfThis = thisSym.tpe /** Sets the type of `this' in a class */ - def typeOfThis_=(tp: Type): unit = + def typeOfThis_=(tp: Type): Unit = throw new Error("typeOfThis cannot be set for " + this) /** If symbol is a class, the type <code>this.type</code> in this class, @@ -870,7 +870,7 @@ trait Symbols { /** Remove private modifier from symbol `sym's definition. If `sym' is a * term symbol rename it by expanding its name to avoid name clashes */ - final def makeNotPrivate(base: Symbol): unit = + final def makeNotPrivate(base: Symbol) { if (this hasFlag PRIVATE) { setFlag(notPRIVATE) if (!hasFlag(DEFERRED) && isTerm) setFlag(lateFINAL) @@ -879,11 +879,12 @@ trait Symbols { if (isModule) moduleClass.makeNotPrivate(base) } } + } /** change name by appending $$<fully-qualified-name-of-class `base'> * Do the same for any accessed symbols or setters/getters */ - def expandName(base: Symbol): unit = + def expandName(base: Symbol) { if (this.isTerm && this != NoSymbol && !hasFlag(EXPANDEDNAME)) { setFlag(EXPANDEDNAME) if (hasFlag(ACCESSOR) && !hasFlag(DEFERRED)) { @@ -895,6 +896,7 @@ trait Symbols { name = base.expandedName(name) if (isType) name = name.toTypeName } + } /** The expanded name of `name' relative to this class as base */ @@ -905,7 +907,7 @@ trait Symbols { def sourceFile: AbstractFile = (if (isModule) moduleClass else toplevelClass).sourceFile - def sourceFile_=(f: AbstractFile): unit = + def sourceFile_=(f: AbstractFile): Unit = throw new Error("sourceFile_= inapplicable for " + this) def isFromClassFile: Boolean = @@ -923,7 +925,7 @@ trait Symbols { // ToString ------------------------------------------------------------------- /** A tag which (in the ideal case) uniquely identifies class symbols */ - final def tag: int = fullNameString.hashCode() + final def tag: Int = fullNameString.hashCode() /** The simple name of this Symbol */ final def simpleName: Name = name @@ -977,7 +979,7 @@ trait Symbols { * Never translates expansions of operators back to operator symbol. * Never adds id. */ - final def fullNameString(separator: char): String = { + final def fullNameString(separator: Char): String = { assert(owner != NoSymbol, this) var str = if (owner.isRoot || @@ -1191,7 +1193,7 @@ trait Symbols { this } - override def reset(completer: Type): unit = { + override def reset(completer: Type) { super.reset(completer) tpePeriod = NoPeriod tyconRunId = NoRunId @@ -1227,7 +1229,7 @@ trait Symbols { private var source: AbstractFile = null override def sourceFile = if (owner.isPackageClass) source else super.sourceFile - override def sourceFile_=(f: AbstractFile): unit = { + override def sourceFile_=(f: AbstractFile) { //System.err.println("set source file of " + this + ": " + f); source = f } @@ -1238,12 +1240,12 @@ trait Symbols { } private var thissym: Symbol = this - override def isClass: boolean = true + override def isClass: Boolean = true override def isTypeMember = false override def isAbstractType = false override def isAliasType = false - override def reset(completer: Type): unit = { + override def reset(completer: Type) { super.reset(completer) thissym = this } @@ -1285,8 +1287,9 @@ trait Symbols { else thissym.tpe /** Sets the self type of the class */ - override def typeOfThis_=(tp: Type): unit = + override def typeOfThis_=(tp: Type) { thissym = newThisSym(pos).setInfo(tp) + } override def cloneSymbolImpl(owner: Symbol): Symbol = { assert(!isModuleClass) @@ -1321,7 +1324,7 @@ trait Symbols { setSourceModule(module) } override def sourceModule = module - def setSourceModule(module: Symbol): unit = this.module = module + def setSourceModule(module: Symbol) { this.module = module } } /** An object repreesenting a missing symbol */ @@ -1342,7 +1345,7 @@ trait Symbols { override def sourceFile: AbstractFile = null override def ownerChain: List[Symbol] = List() override def alternatives: List[Symbol] = List() - override def reset(completer: Type): unit = {} + override def reset(completer: Type) {} override def info: Type = NoType override def rawInfo: Type = NoType def cloneSymbolImpl(owner: Symbol): Symbol = throw new Error() diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index f1c041ac35..40eaef0f6f 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -6,8 +6,8 @@ package scala.tools.nsc.symtab -import compat.Platform.currentTime import scala.collection.mutable.{ListBuffer, HashMap} +import scala.compat.Platform.currentTime import scala.tools.nsc.util.{HashSet, Position, NoPosition} import Flags._ @@ -97,11 +97,11 @@ trait Types { // the following are all operations in class Type that are overridden in some subclass // Important to keep this up-to-date when new operations are added! override def isTrivial = tp.isTrivial - override def isHigherKinded: boolean = tp.isHigherKinded + override def isHigherKinded: Boolean = tp.isHigherKinded override def isNotNull = tp.isNotNull override def isError = tp.isError override def isErroneous = tp.isErroneous - override def isStable: boolean = tp.isStable + override def isStable: Boolean = tp.isStable override def symbol = tp.symbol override def singleDeref = maybeRewrap(tp.singleDeref) override def widen = maybeRewrap(tp.widen) @@ -132,7 +132,7 @@ trait Types { override def prefixString = tp.prefixString override def isComplete = tp.isComplete override def complete(sym: Symbol) = tp.complete(sym) - override def load(sym: Symbol): unit = tp.load(sym) + override def load(sym: Symbol): Unit = tp.load(sym) override def withAttributes(attribs: List[AnnotationInfo]) = tp.withAttributes(attribs) override def withoutAttributes = tp.withoutAttributes } @@ -143,19 +143,19 @@ trait Types { /** Types for which asSeenFrom always is the identity, no matter what * prefix or owner. */ - def isTrivial: boolean = false + def isTrivial: Boolean = false /** Is this type higher-kinded, i.e., is it a type constructor @M */ - def isHigherKinded: boolean = false + def isHigherKinded: Boolean = false /** Does this type denote a stable reference (i.e. singleton type)? */ - def isStable: boolean = false + def isStable: Boolean = false /** Is this type guaranteed not to have `null' as a value? */ - def isNotNull: boolean = false + def isNotNull: Boolean = false /** Does this depend on an enclosing method parameter? */ - def isDependent: boolean = { + def isDependent: Boolean = { IsDependentTraverser.result = false IsDependentTraverser.traverse(this) IsDependentTraverser.result @@ -221,7 +221,7 @@ trait Types { /** For a method or poly type, the number of its value parameter sections, * 0 for all other types */ - def paramSectionCount: int = 0 + def paramSectionCount: Int = 0 /** For a method or poly type, the types of its first value parameter section, * the empty list for all other types */ @@ -247,17 +247,17 @@ trait Types { def normalize = this // @MAT /** Is this type produced as a repair for an error? */ - def isError: boolean = symbol.isError + def isError: Boolean = symbol.isError /** Is this type produced as a repair for an error? */ - def isErroneous: boolean = { + def isErroneous: Boolean = { ErroneousTraverser.result = false ErroneousTraverser.traverse(this) ErroneousTraverser.result } /** Does this type denote a reference type which can be null? */ - // def isNullable: boolean = false + // def isNullable: Boolean = false /** For a classtype or refined type, its defined or declared members; * inherited by subtypes and typerefs. @@ -382,23 +382,23 @@ trait Types { /** Returns optionally first type (in a preorder traverser) which satisfies predicate `p', * or None if none exists. */ - def find(p: Type => boolean): Option[Type] = { + def find(p: Type => Boolean): Option[Type] = { new FindTraverser(p).traverse(this).result } /** Is there part of this type which satisfies predicate `p'? */ - def exists(p: Type => boolean): boolean = !find(p).isEmpty + def exists(p: Type => Boolean): Boolean = !find(p).isEmpty /** Does this type contain a reference to this symbol? */ - def contains(sym: Symbol): boolean = + def contains(sym: Symbol): Boolean = new ContainsTraverser(sym).traverse(this).result /** Does this type contain a reference to this type */ - def containsTp(tp: Type): boolean = + def containsTp(tp: Type): Boolean = new ContainsTypeTraverser(tp).traverse(this).result /** Is this type a subtype of that type? */ - def <:<(that: Type): boolean = { + def <:<(that: Type): Boolean = { if (util.Statistics.enabled) subtypeCount = subtypeCount + 1 val startTime = if (util.Statistics.enabled) currentTime else 0l val result = @@ -411,7 +411,7 @@ trait Types { } /** Is this type equivalent to that type? */ - def =:=(that: Type): boolean = ( + def =:=(that: Type): Boolean = ( (this eq that) || (if (explainSwitch) explain("=", isSameType, this, that) else isSameType(this, that)) @@ -419,7 +419,7 @@ trait Types { /** Does this type implement symbol `sym' with same or stronger type? */ - def specializes(sym: Symbol): boolean = + def specializes(sym: Symbol): Boolean = if (explainSwitch) explain("specializes", specializesSym, this, sym) else specializesSym(this, sym) @@ -435,11 +435,11 @@ trait Types { * - Or phase.erasedTypes is false and both types are neither method nor * poly types. */ - def matches(that: Type): boolean = matchesType(this, that, !phase.erasedTypes) + def matches(that: Type): Boolean = matchesType(this, that, !phase.erasedTypes) /** Same as matches, except that non-method types are always assumed to match. */ - def looselyMatches(that: Type): boolean = matchesType(this, that, true) + def looselyMatches(that: Type): Boolean = matchesType(this, that, true) /** The shortest sorted upwards closed array of types that contains * this type as first element. @@ -460,7 +460,7 @@ trait Types { def closure: Array[Type] = Array(this) /** The maximum depth (@see maxDepth) of each type in the closure of this type. */ - def closureDepth: int = 1 + def closureDepth: Int = 1 def baseClasses: List[Symbol] = List() @@ -469,7 +469,7 @@ trait Types { * @return the index of given class symbol in the closure of this type, * or -1 if no base type with given class symbol exists. */ - def closurePos(sym: Symbol): int = { + def closurePos(sym: Symbol): Int = { val cl = closure var lo = 0 var hi = cl.length - 1 @@ -509,17 +509,17 @@ trait Types { /** Is this type completed (i.e. not a lazy type)? */ - def isComplete: boolean = true + def isComplete: Boolean = true /** If this is a lazy type, assign a new type to `sym'. */ - def complete(sym: Symbol) = {} + def complete(sym: Symbol) {} /** If this is a symbol loader type, load and assign a new type to * `sym'. */ - def load(sym: Symbol): unit = {} + def load(sym: Symbol) {} - private def findDecl(name: Name, excludedFlags: int): Symbol = { + private def findDecl(name: Name, excludedFlags: Int): Symbol = { var alts: List[Symbol] = List() var sym: Symbol = NoSymbol var e: ScopeEntry = decls.lookupEntry(name) @@ -545,7 +545,7 @@ trait Types { * @return ... */ //TODO: use narrow only for modules? (correct? efficiency gain?) - def findMember(name: Name, excludedFlags: int, requiredFlags: long, stableOnly: boolean): Symbol = { + def findMember(name: Name, excludedFlags: Int, requiredFlags: Long, stableOnly: Boolean): Symbol = { if (inIDE) trackTypeIDE(symbol) if (util.Statistics.enabled) findMemberCount = findMemberCount + 1 val startTime = if (util.Statistics.enabled) currentTime else 0l @@ -656,14 +656,14 @@ trait Types { override def decls: Scope = supertype.decls override def baseType(clazz: Symbol): Type = supertype.baseType(clazz) override def closure: Array[Type] = supertype.closure - override def closureDepth: int = supertype.closureDepth + override def closureDepth: Int = supertype.closureDepth override def baseClasses: List[Symbol] = supertype.baseClasses override def isNotNull = supertype.isNotNull } case class NotNullType(tp: Type) extends SubType with TypeProxy { override def supertype = tp - override def isNotNull: boolean = true + override def isNotNull: Boolean = true override def deconst: Type = tp override def toString: String = supertype.toString + " with NotNull" } @@ -674,7 +674,7 @@ trait Types { abstract class SingletonType extends SubType { override def singleDeref: Type def supertype: Type = singleDeref - override def isStable: boolean = true + override def isStable: Boolean = true override def widen: Type = singleDeref.widen override def closure: Array[Type] = { if (util.Statistics.enabled) singletonClosureCount = singletonClosureCount + 1 @@ -686,10 +686,10 @@ trait Types { /** An object representing an erroneous type */ case object ErrorType extends Type { // todo see whether we can do without - override def isError: boolean = true + override def isError: Boolean = true override def decls: Scope = new ErrorScope(NoSymbol) - override def findMember(name: Name, excludedFlags: int, - requiredFlags: long, stableOnly: boolean): Symbol = { + override def findMember(name: Name, excludedFlags: Int, + requiredFlags: Long, stableOnly: Boolean): Symbol = { var sym = decls lookup name if (sym == NoSymbol) { sym = NoSymbol.newErrorSymbol(name) @@ -700,13 +700,13 @@ trait Types { override def baseType(clazz: Symbol): Type = this override def toString: String = "<error>" override def narrow: Type = this - // override def isNullable: boolean = true + // override def isNullable: Boolean = true } /** An object representing an unknown type */ case object WildcardType extends Type { override def toString: String = "?" - // override def isNullable: boolean = true + // override def isNullable: Boolean = true } case class BoundedWildcardType(override val bounds: TypeBounds) extends Type { @@ -715,25 +715,25 @@ trait Types { /** An object representing a non-existing type */ case object NoType extends Type { - override def isTrivial: boolean = true + override def isTrivial: Boolean = true override def toString: String = "<notype>" - // override def isNullable: boolean = true + // override def isNullable: Boolean = true } /** An object representing a non-existing prefix */ case object NoPrefix extends Type { - override def isTrivial: boolean = true - override def isStable: boolean = true + override def isTrivial: Boolean = true + override def isStable: Boolean = true override def prefixString = "" override def toString: String = "<noprefix>" - // override def isNullable: boolean = true + // override def isNullable: Boolean = true } /** A class for this-types of the form <sym>.this.type */ case class ThisType(sym: Symbol) extends SingletonType { //assert(sym.isClass && !sym.isModuleClass || sym.isRoot, sym) - override def isTrivial: boolean = sym.isPackageClass + override def isTrivial: Boolean = sym.isPackageClass override def isNotNull = true override def symbol = sym override def singleDeref: Type = sym.typeOfThis @@ -750,7 +750,7 @@ trait Types { override def narrow: Type = this } - case class DeBruijnIndex(level: int, paramId: int) extends Type { + case class DeBruijnIndex(level: Int, paramId: Int) extends Type { override def isTrivial = true override def isStable = true override def toString = "<param "+level+"."+paramId+">" @@ -761,7 +761,7 @@ trait Types { * `singleType' for creation. */ case class SingleType(pre: Type, sym: Symbol) extends SingletonType { - override val isTrivial: boolean = pre.isTrivial + override val isTrivial: Boolean = pre.isTrivial // override def isNullable = supertype.isNullable override def isNotNull = supertype.isNotNull private var singleDerefCache: Type = _ @@ -798,7 +798,7 @@ trait Types { } case class SuperType(thistpe: Type, supertp: Type) extends SingletonType { - override val isTrivial: boolean = thistpe.isTrivial && supertp.isTrivial + override val isTrivial: Boolean = thistpe.isTrivial && supertp.isTrivial override def isNotNull = true; override def symbol = thistpe.symbol override def singleDeref = supertp @@ -813,11 +813,11 @@ trait Types { /** A class for the bounds of abstract types and type parameters */ case class TypeBounds(lo: Type, hi: Type) extends SubType { - override val isTrivial: boolean = lo.isTrivial && hi.isTrivial + override val isTrivial: Boolean = lo.isTrivial && hi.isTrivial def supertype: Type = hi override def bounds: TypeBounds = this def containsType(that: Type) = that <:< this || lo <:< that && that <:< hi; - // override def isNullable: boolean = AllRefClass.tpe <:< lo; + // override def isNullable: Boolean = AllRefClass.tpe <:< lo; override def toString = ">: " + lo + " <: " + hi } @@ -829,7 +829,7 @@ trait Types { private var closurePeriod = NoPeriod private var baseClassesCache: List[Symbol] = _ private var baseClassesPeriod = NoPeriod - private var closureDepthCache: int = _ + private var closureDepthCache: Int = _ override def closure: Array[Type] = { def computeClosure: Array[Type] = @@ -843,7 +843,7 @@ trait Types { val nparents = parents.length if (nparents != 0) { val pclosure = new Array[Array[Type]](nparents) - val index = new Array[int](nparents) + val index = new Array[Int](nparents) var i = 0 for (p <- parents) { pclosure(i) = if (p.closure eq null) AnyClass.info.closure // cyclic reference @@ -851,7 +851,7 @@ trait Types { index(i) = 0 i += 1 } - def nextBaseType(i: int): Type = { + def nextBaseType(i: Int): Type = { val j = index(i) val pci = pclosure(i) if (j < pci.length) pci(j) else AnyClass.tpe @@ -920,7 +920,7 @@ trait Types { closureCache } - override def closureDepth: int = { closure; closureDepthCache } + override def closureDepth: Int = { closure; closureDepthCache } override def baseClasses: List[Symbol] = { if (inIDE) trackTypeIDE(symbol) @@ -933,7 +933,7 @@ trait Types { var mixins = parents.tail val sbcs = superclazz.baseClasses var bcs = sbcs - def isNew(clazz: Symbol): boolean = ( + def isNew(clazz: Symbol): Boolean = ( superclazz.closurePos(clazz) < 0 && { var p = bcs; while ((p ne sbcs) && (p.head != clazz)) p = p.tail; @@ -982,9 +982,9 @@ trait Types { symbol.thisType } - override def isNotNull: boolean = parents exists (_.isNotNull) + override def isNotNull: Boolean = parents exists (_.isNotNull) - // override def isNullable: boolean = + // override def isNullable: Boolean = // parents forall (p => p.isNullable && !p.symbol.isAbstractType); override def toString: String = @@ -1048,7 +1048,7 @@ trait Types { * @param which in {NonExpansive, Expansive} * @param from The type parameter from which references originate. */ - private def getRefs(which: int, from: Symbol): Set[Symbol] = refs(which) get from match { + private def getRefs(which: Int, from: Symbol): Set[Symbol] = refs(which) get from match { case Some(set) => set case None => Set() } @@ -1056,7 +1056,7 @@ trait Types { /** Augment existing refs map with reference <pre>from -> to</pre> * @param which <- {NonExpansive, Expansive} */ - private def addRef(which: int, from: Symbol, to: Symbol) { + private def addRef(which: Int, from: Symbol, to: Symbol) { refs(which) = refs(which) + (from -> (getRefs(which, from) + to)) } @@ -1064,7 +1064,7 @@ trait Types { * all elements <pre>sym</pre> of set `to'. * @param which <- {NonExpansive, Expansive} */ - private def addRefs(which: int, from: Symbol, to: Set[Symbol]) { + private def addRefs(which: Int, from: Symbol, to: Set[Symbol]) { refs(which) = refs(which) + (from -> (getRefs(which, from) ++ to)) } @@ -1105,7 +1105,7 @@ trait Types { * Set state to Initialized if no change resulted from propagation. * @return true iff there as a change in last iteration */ - private def propagate(): boolean = { + private def propagate(): Boolean = { if (state == UnInitialized) computeRefs() //Console.println("Propagate "+symbol+", initial expansive = "+refs(Expansive)+", nonexpansive = "+refs(NonExpansive))//DEBUG val lastRefs = Array(refs(0), refs(1)) @@ -1130,11 +1130,11 @@ trait Types { change } - // override def isNullable: boolean = + // override def isNullable: Boolean = // symbol == AnyClass || // symbol != AllClass && (symbol isSubClass ObjectClass) && !(symbol isSubClass NonNullClass); - // override def isNonNull: boolean = symbol == NonNullClass || super.isNonNull; + // override def isNonNull: Boolean = symbol == NonNullClass || super.isNonNull; } class PackageClassInfoType(decls: Scope, clazz: Symbol) @@ -1146,7 +1146,7 @@ trait Types { */ case class ConstantType(value: Constant) extends SingletonType { assert(value.tpe.symbol != UnitClass) - override def isTrivial: boolean = true + override def isTrivial: Boolean = true override def isNotNull = value.value != null override def symbol: Symbol = value.tpe.symbol override def singleDeref: Type = @@ -1155,8 +1155,8 @@ trait Types { override def deconst: Type = value.tpe override def toString: String = value.tpe.toString + "(" + value.escapedStringValue + ")" - // override def isNullable: boolean = value.value eq null - // override def isNonNull: boolean = value.value ne null + // override def isNullable: Boolean = value.value eq null + // override def isNonNull: Boolean = value.value ne null } /** A class for named types of the form @@ -1178,13 +1178,13 @@ trait Types { private var parentsPeriod = NoPeriod private var closureCache: Array[Type] = _ private var closurePeriod = NoPeriod - private var closureDepthCache: int = _ + private var closureDepthCache: Int = _ - override def isStable: boolean = { + override def isStable: Boolean = { sym.isAbstractType && (sym.info.bounds.hi.symbol isSubClass SingletonClass) } - override val isTrivial: boolean = + override val isTrivial: Boolean = pre.isTrivial && !sym.isTypeParameter && args.forall(_.isTrivial) override def isNotNull = @@ -1321,11 +1321,11 @@ A type's symbol should never be inspected directly. closureCache } - override def closureDepth: int = { closure; closureDepthCache } + override def closureDepth: Int = { closure; closureDepthCache } override def baseClasses: List[Symbol] = thisInfo.baseClasses - // override def isNullable: boolean = sym.info.isNullable + // override def isNullable: Boolean = sym.info.isNullable override def toString: String = { if (!settings.debug.value) { @@ -1369,11 +1369,11 @@ A type's symbol should never be inspected directly. */ case class MethodType(override val paramTypes: List[Type], override val resultType: Type) extends Type { - override val isTrivial: boolean = + override val isTrivial: Boolean = paramTypes.forall(_.isTrivial) && resultType.isTrivial //assert(paramTypes forall (pt => !pt.symbol.isImplClass))//DEBUG - override def paramSectionCount: int = resultType.paramSectionCount + 1 + override def paramSectionCount: Int = resultType.paramSectionCount + 1 override def resultType(actuals: List[Type]) = new InstantiateDeBruijnMap(actuals).apply(resultType) @@ -1382,7 +1382,7 @@ A type's symbol should never be inspected directly. protected def paramPrefix = "(" - private def dependentToString(base: int): String = { + private def dependentToString(base: Int): String = { val params = for ((pt, n) <- paramTypes.zipWithIndex) yield "x$"+n+":"+pt val res = resultType match { case mt: MethodType => mt.dependentToString(base + params.length) @@ -1405,18 +1405,18 @@ A type's symbol should never be inspected directly. /** A class containing the commonalities of existential and universal types */ abstract class QuantifiedType extends Type { def quantified: Type - override def paramSectionCount: int = quantified.paramSectionCount + override def paramSectionCount: Int = quantified.paramSectionCount override def paramTypes: List[Type] = quantified.paramTypes override def parents: List[Type] = quantified.parents override def decls: Scope = quantified.decls override def symbol: Symbol = quantified.symbol override def prefix: Type = quantified.prefix override def closure: Array[Type] = quantified.closure - override def closureDepth: int = quantified.closureDepth + override def closureDepth: Int = quantified.closureDepth override def baseClasses: List[Symbol] = quantified.baseClasses override def baseType(clazz: Symbol): Type = quantified.baseType(clazz) override def narrow: Type = quantified.narrow - // override def isNullable: boolean = quantified.isNullable; + // override def isNullable: Boolean = quantified.isNullable; } /** A class representing a polymorphic type or, if tparams.length == 0, @@ -1561,8 +1561,8 @@ A type's symbol should never be inspected directly. /** A class representing an as-yet unevaluated type. */ abstract class LazyType extends Type { - override def isComplete: boolean = false - override def complete(sym: Symbol): unit + override def isComplete: Boolean = false + override def complete(sym: Symbol) override def toString = "<?>" } @@ -1871,7 +1871,7 @@ A type's symbol should never be inspected directly. } */ - def instantiate(tp: Type): boolean = + def instantiate(tp: Type): Boolean = if (lobounds.forall(_ <:< tp) && hibounds.forall(tp <:< _)) { inst = tp; true } else false @@ -2041,7 +2041,7 @@ A type's symbol should never be inspected directly. } abstract class TypeTraverser extends TypeMap { - def traverse(tp: Type): TypeTraverser //todo: return unit instead? + def traverse(tp: Type): TypeTraverser //todo: return Unit instead? def apply(tp: Type): Type = { traverse(tp); tp } } @@ -2123,7 +2123,7 @@ A type's symbol should never be inspected directly. /** Are `sym' and `sym1' the same. * Can be tuned by subclasses. */ - protected def matches(sym: Symbol, sym1: Symbol): boolean = sym eq sym1 + protected def matches(sym: Symbol, sym1: Symbol): Boolean = sym eq sym1 /** Map target to type, can be tuned by subclasses */ protected def toType(fromtp: Type, t: T): Type @@ -2274,7 +2274,7 @@ A type's symbol should never be inspected directly. } /** A map to implement the `filter' method */ - class FilterTraverser(p: Type => boolean) extends TypeTraverser { + class FilterTraverser(p: Type => Boolean) extends TypeTraverser { val hits = new ListBuffer[Type] def traverse(tp: Type): FilterTraverser = { if (p(tp)) hits += tp @@ -2284,7 +2284,7 @@ A type's symbol should never be inspected directly. } /** A map to implement the `filter' method */ - class FindTraverser(p: Type => boolean) extends TypeTraverser { + class FindTraverser(p: Type => Boolean) extends TypeTraverser { var result: Option[Type] = None def traverse(tp: Type): FindTraverser = { if (result.isEmpty) { @@ -2297,7 +2297,7 @@ A type's symbol should never be inspected directly. /** A map to implement the `contains' method */ object ErroneousTraverser extends TypeTraverser { - var result: boolean = _ + var result: Boolean = _ def traverse(tp: Type): TypeTraverser = { if (!result) { result = tp.isError @@ -2308,7 +2308,7 @@ A type's symbol should never be inspected directly. } object IsDependentTraverser extends TypeTraverser { - var result: boolean = _ + var result: Boolean = _ def traverse(tp: Type): TypeTraverser = { tp match { case DeBruijnIndex(_, _) => result = true @@ -2338,7 +2338,7 @@ A type's symbol should never be inspected directly. } tp } - private def register(sym: Symbol): unit = { + private def register(sym: Symbol) { while (result != NoSymbol && sym != result && !(sym isNestedIn result)) result = result.owner; } @@ -2360,7 +2360,7 @@ A type's symbol should never be inspected directly. } if (rebind0 == NoSymbol) { assert(false, ""+pre+"."+sym+" does no longer exist, phase = "+phase) } /** The two symbols have the same fully qualified name */ - def corresponds(sym1: Symbol, sym2: Symbol): boolean = + def corresponds(sym1: Symbol, sym2: Symbol): Boolean = sym1.name == sym2.name && (sym1.isPackageClass || corresponds(sym1.owner, sym2.owner)) if (!corresponds(sym.owner, rebind0.owner)) { if (settings.debug.value) Console.println("ADAPT1 pre = "+pre+", sym = "+sym+sym.locationString+", rebind = "+rebind0+rebind0.locationString) @@ -2440,21 +2440,21 @@ A type's symbol should never be inspected directly. import Math.max /** The maximum depth of all types in the closures of each of the types `tps' */ - final def maxClosureDepth(tps: Seq[Type]): int = { + final def maxClosureDepth(tps: Seq[Type]): Int = { var d = 0 for (tp <- tps) d = max(d, tp.closureDepth) d } /** The maximum depth of all types `tps' */ - final def maxDepth(tps: Seq[Type]): int = { + final def maxDepth(tps: Seq[Type]): Int = { var d = 0 for (tp <- tps) d = max(d, maxDepth(tp)) d } /** The maximum depth of type `tp' */ - final def maxDepth(tp: Type): int = tp match { + final def maxDepth(tp: Type): Int = tp match { case TypeRef(pre, sym, args) => max(maxDepth(pre), maxDepth(args) + 1) case RefinedType(parents, decls) => @@ -2471,15 +2471,15 @@ A type's symbol should never be inspected directly. 1 } - final def isValid(period: Period): boolean = + final def isValid(period: Period): Boolean = period != 0 && runId(period) == currentRunId && { val pid = phaseId(period) if (phase.id > pid) infoTransformers.nextFrom(pid).pid >= phase.id else infoTransformers.nextFrom(phase.id).pid >= pid } - final def isValidForBaseClasses(period: Period): boolean = { - def noChangeInBaseClasses(it: InfoTransformer, limit: Phase#Id): boolean = ( + final def isValidForBaseClasses(period: Period): Boolean = { + def noChangeInBaseClasses(it: InfoTransformer, limit: Phase#Id): Boolean = ( it.pid >= limit || !it.changesBaseClasses && noChangeInBaseClasses(it.next, limit) ); @@ -2497,7 +2497,7 @@ A type's symbol should never be inspected directly. * @return true, iff `tp1' and `tp2' denote * equivalent types. */ - def isSameType(tp1: Type, tp2: Type): boolean = { + def isSameType(tp1: Type, tp2: Type): Boolean = { (tp1, tp2) match { case (ErrorType, _) => true case (WildcardType, _) => true @@ -2535,7 +2535,7 @@ A type's symbol should never be inspected directly. ((tp1.isHigherKinded && tp2.isHigherKinded && tp1.normalize =:= tp2.normalize) || isSameTypes(args1, args2)) case (RefinedType(parents1, ref1), RefinedType(parents2, ref2)) => - def isSubScope(s1: Scope, s2: Scope): boolean = s2.toList.forall { + def isSubScope(s1: Scope, s2: Scope): Boolean = s2.toList.forall { sym2 => val sym1 = s1.lookup(sym2.name) sym1 != NoSymbol && @@ -2592,14 +2592,14 @@ A type's symbol should never be inspected directly. /** Are `tps1' and `tps2' lists of pairwise equivalent * types? */ - def isSameTypes(tps1: List[Type], tps2: List[Type]): boolean = + def isSameTypes(tps1: List[Type], tps2: List[Type]): Boolean = tps1.length == tps2.length && List.forall2(tps1, tps2)((tp1, tp2) => tp1 =:= tp2) - var stc: int = 0 + var stc: Int = 0 private var pendingSubTypes = new collection.mutable.HashSet[SubTypePair] - def isSubType(tp1: Type, tp2: Type): boolean = try { + def isSubType(tp1: Type, tp2: Type): Boolean = try { stc = stc + 1 if (stc >= LogPendingSubTypesThreshold) { val p = new SubTypePair(tp1, tp2) @@ -2629,7 +2629,7 @@ A type's symbol should never be inspected directly. * @param tp2 ... * @return ... */ - def isSubType0(tp1: Type, tp2: Type): boolean = { + def isSubType0(tp1: Type, tp2: Type): Boolean = { (tp1, tp2) match { case (ErrorType, _) => true case (WildcardType, _) => true @@ -2653,7 +2653,7 @@ A type's symbol should never be inspected directly. if (inIDE) { trackTypeIDE(sym1); trackTypeIDE(sym2); } def isSubArgs(tps1: List[Type], tps2: List[Type], - tparams: List[Symbol]): boolean = ( + tparams: List[Symbol]): Boolean = ( tps1.isEmpty && tps2.isEmpty || !tps1.isEmpty && !tps2.isEmpty && @@ -2765,7 +2765,7 @@ A type's symbol should never be inspected directly. * that all elements of `tps1' conform to corresponding elements * of `tps2'? */ - def isSubTypes(tps1: List[Type], tps2: List[Type]): boolean = + def isSubTypes(tps1: List[Type], tps2: List[Type]): Boolean = tps1.length == tps2.length && List.forall2(tps1, tps2)((tp1, tp2) => tp1 <:< tp2) @@ -2773,7 +2773,7 @@ A type's symbol should never be inspected directly. * stronger type? Exact only if `sym' is a member of some * refinement type, otherwise we might return false negatives. */ - def specializesSym(tp: Type, sym: Symbol): boolean = + def specializesSym(tp: Type, sym: Symbol): Boolean = tp.symbol == AllClass || tp.symbol == AllRefClass && (sym.owner isSubClass ObjectClass) || (tp.nonPrivateMember(sym.name).alternatives exists @@ -2782,7 +2782,7 @@ A type's symbol should never be inspected directly. /** Does member `sym1' of `tp1' have a stronger type * than member `sym2' of `tp2'? */ - private def specializesSym(tp1: Type, sym1: Symbol, tp2: Type, sym2: Symbol): boolean = { + private def specializesSym(tp1: Type, sym1: Symbol, tp2: Type, sym2: Symbol): Boolean = { val info1 = tp1.memberInfo(sym1) val info2 = tp2.memberInfo(sym2).substThis(tp2.symbol, tp1) //System.out.println("specializes "+tp1+"."+sym1+":"+info1+sym1.locationString+" AND "+tp2+"."+sym2+":"+info2)//DEBUG @@ -2792,7 +2792,7 @@ A type's symbol should never be inspected directly. } /** A function implementing `tp1' matches `tp2' */ - private def matchesType(tp1: Type, tp2: Type, alwaysMatchSimple: boolean): boolean = (tp1, tp2) match { + private def matchesType(tp1: Type, tp2: Type, alwaysMatchSimple: Boolean): Boolean = (tp1, tp2) match { case (MethodType(pts1, res1), MethodType(pts2, res2)) => matchingParams(pts1, pts2, tp2.isInstanceOf[JavaMethodType]) && matchesType(res1, res2, alwaysMatchSimple) && @@ -2817,7 +2817,7 @@ A type's symbol should never be inspected directly. } /** Are `tps1' and `tps2' lists of pairwise equivalent types? */ - private def matchingParams(tps1: List[Type], tps2: List[Type], tps2isJava: boolean): boolean = ( + private def matchingParams(tps1: List[Type], tps2: List[Type], tps2isJava: Boolean): Boolean = ( tps1.length == tps2.length && List.forall2(tps1, tps2)((tp1, tp2) => (tp1 =:= tp2) || tps2isJava & tp1.symbol == ObjectClass && tp2.symbol == AnyClass) @@ -2866,10 +2866,10 @@ A type's symbol should never be inspected directly. * @throws NoInstance */ def solve(tvars: List[TypeVar], tparams: List[Symbol], - variances: List[int], upper: boolean) { + variances: List[Int], upper: Boolean) { val config = tvars zip (tparams zip variances) - def solveOne(tvar: TypeVar, tparam: Symbol, variance: int): unit = { + def solveOne(tvar: TypeVar, tparam: Symbol, variance: Int) { if (tvar.constr.inst == NoType) { val up = if (variance != CONTRAVARIANT) upper else !upper tvar.constr.inst = null @@ -2922,7 +2922,7 @@ A type's symbol should never be inspected directly. * @param targs ... * @return ... */ - def isWithinBounds(pre: Type, owner: Symbol, tparams: List[Symbol], targs: List[Type]): boolean = { + def isWithinBounds(pre: Type, owner: Symbol, tparams: List[Symbol], targs: List[Type]): Boolean = { val bounds = tparams map { tparam => tparam.info.asSeenFrom(pre, owner).instantiateTypeParams(tparams, targs).bounds } @@ -2938,7 +2938,7 @@ A type's symbol should never be inspected directly. * * @See closure for a definition of sorted and upwards closed. */ - private def glbList(tss: List[List[Type]], depth: int): List[Type] = { + private def glbList(tss: List[List[Type]], depth: Int): List[Type] = { val tss1 = tss filter (ts => !ts.isEmpty) if (tss1.isEmpty) List() else if (tss1.tail.isEmpty) tss.head @@ -2959,7 +2959,7 @@ A type's symbol should never be inspected directly. * * @See glbList for more explanations. */ - private def glbArray(tss: List[Array[Type]], depth: int): Array[Type] = { + private def glbArray(tss: List[Array[Type]], depth: Int): Array[Type] = { val tss1 = tss map { ts: Array[Type] => List.fromArray(ts) } val glbs = glbList(tss1, depth) val result = new Array[Type](glbs.length) @@ -2974,7 +2974,7 @@ A type's symbol should never be inspected directly. * * @See glbList for more explanations. */ - private def lubList(tss: List[List[Type]], depth: int): List[Type] = + private def lubList(tss: List[List[Type]], depth: Int): List[Type] = if (tss.tail.isEmpty) tss.head else if (tss exists (_.isEmpty)) List() else { @@ -2991,7 +2991,7 @@ A type's symbol should never be inspected directly. * * @See lubList for more explanations. */ - private def lubArray(tss: List[Array[Type]], depth: int): Array[Type] = { + private def lubArray(tss: List[Array[Type]], depth: Int): Array[Type] = { var lubs = lubList(tss map { ts: Array[Type] => List.fromArray(ts) }, depth) var arr = new Array[Type](lubs.length) var i = 0 @@ -3051,7 +3051,7 @@ A type's symbol should never be inspected directly. def lub(ts: List[Type]): Type = lub(ts, maxClosureDepth(ts) + LubGlbMargin) /** The least upper bound wrt <:< of a list of types */ - def lub(ts: List[Type], depth: int): Type = { + def lub(ts: List[Type], depth: Int): Type = { def lub0(ts0: List[Type]): Type = elimSub(ts0 map (_.deconst)) match { case List() => AllClass.tpe case List(t) => t @@ -3100,7 +3100,7 @@ A type's symbol should never be inspected directly. } } } - def refines(tp: Type, sym: Symbol): boolean = { + def refines(tp: Type, sym: Symbol): Boolean = { val syms = tp.nonPrivateMember(sym.name).alternatives; !syms.isEmpty && (syms forall (alt => // todo alt != sym is strictly speaking not correct, but without it we lose @@ -3137,7 +3137,7 @@ A type's symbol should never be inspected directly. def glb(ts: List[Type]): Type = glb(ts, maxClosureDepth(ts) + LubGlbMargin) /** The greatest lower bound wrt <:< of a list of types */ - private def glb(ts: List[Type], depth: int): Type = { + private def glb(ts: List[Type], depth: Int): Type = { def glb0(ts0: List[Type]): Type = elimSuper(ts0 map (_.deconst)) match { case List() => AnyClass.tpe case List(t) => t @@ -3252,7 +3252,7 @@ A type's symbol should never be inspected directly. * Return `Some(x)' if the computation succeeds with result `x'. * Return `None' if the computuation fails. */ - private def mergePrefixAndArgs(tps: List[Type], variance: int, depth: int): Option[Type] = tps match { + private def mergePrefixAndArgs(tps: List[Type], variance: Int, depth: Int): Option[Type] = tps match { case List(tp) => Some(tp) case TypeRef(_, sym, _) :: rest => @@ -3292,7 +3292,7 @@ A type's symbol should never be inspected directly. /** Make symbol `sym' a member of scope `tp.decls' * where `thistp' is the narrowed owner type of the scope. */ - def addMember(thistp: Type, tp: Type, sym: Symbol): unit = { + def addMember(thistp: Type, tp: Type, sym: Symbol) { assert(sym != NoSymbol) if (settings.debug.value) log("add member " + sym)//debug if (!(thistp specializes sym)) { @@ -3370,7 +3370,7 @@ A type's symbol should never be inspected directly. /** Perform operation `p' on arguments `tp1', * `arg2' and print trace of computation. */ - private def explain[T](op: String, p: (Type, T) => boolean, tp1: Type, arg2: T): boolean = { + private def explain[T](op: String, p: (Type, T) => Boolean, tp1: Type, arg2: T): Boolean = { Console.println(indent + tp1 + " " + op + " " + arg2 + "?") indent = indent + " " val result = p(tp1, arg2) @@ -3385,8 +3385,9 @@ A type's symbol should never be inspected directly. * @param found ... * @param required ... */ - def explainTypes(found: Type, required: Type): unit = + def explainTypes(found: Type, required: Type) { if (settings.explaintypes.value) withTypesExplained(found <:< required) + } def withTypesExplained[A](op: => A): A = { val s = explainSwitch diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 3a52959622..145cccbe2b 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -45,9 +45,9 @@ abstract class ClassfileParser { protected var instanceDefs: Scope = _ // the scope of all instance definitions protected var staticDefs: Scope = _ // the scope of all static definitions protected var pool: ConstantPool = _ // the classfile's constant pool - protected var isScala: boolean = _ // does class file describe a scala class? - protected var hasMeta: boolean = _ // does class file contain jaco meta attribute?s - protected var busy: boolean = false // lock to detect recursive reads + protected var isScala: Boolean = _ // does class file describe a scala class? + protected var hasMeta: Boolean = _ // does class file contain jaco meta attribute?s + protected var busy: Boolean = false // lock to detect recursive reads protected var classTParams = Map[Name,Symbol]() protected val fresh = new FreshNameCreator @@ -121,7 +121,7 @@ abstract class ClassfileParser { class ConstantPool { private val len = in.nextChar - private val starts = new Array[int](len) + private val starts = new Array[Int](len) private val values = new Array[AnyRef](len) private val internalized = new Array[Name](len) @@ -146,7 +146,7 @@ abstract class ClassfileParser { } } - def getName(index: int): Name = { + def getName(index: Int): Name = { if (index <= 0 || len <= index) errorBadIndex(index) var name = values(index).asInstanceOf[Name] if (name eq null) { @@ -158,7 +158,7 @@ abstract class ClassfileParser { name } - def getExternalName(index: int): Name = { + def getExternalName(index: Int): Name = { if (index <= 0 || len <= index) errorBadIndex(index) if (internalized(index) eq null) { internalized(index) = getName(index).replace('/', '.') @@ -166,7 +166,7 @@ abstract class ClassfileParser { internalized(index) } - def getClassSymbol(index: int): Symbol = { + def getClassSymbol(index: Int): Symbol = { if (index <= 0 || len <= index) errorBadIndex(index) var c = values(index).asInstanceOf[Symbol] if (c eq null) { @@ -275,13 +275,13 @@ abstract class ClassfileParser { c } - def getType(index: int): Type = + def getType(index: Int): Type = sigToType(getExternalName(index)) - def getSuperClass(index: int): Symbol = + def getSuperClass(index: Int): Symbol = if (index == 0) definitions.AnyClass else getClassSymbol(index) - def getConstant(index: int): Constant = { + def getConstant(index: Int): Constant = { if (index <= 0 || len <= index) errorBadIndex(index) var value = values(index) if (value eq null) { diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/MetaParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/MetaParser.scala index 06e464bbaa..21251e3ed8 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/MetaParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/MetaParser.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -7,6 +7,7 @@ package scala.tools.nsc.symtab.classfile import java.util.{StringTokenizer, NoSuchElementException} + import scala.collection.mutable.ListBuffer import scala.tools.nsc.util.{Position,NoPosition} @@ -21,7 +22,7 @@ abstract class MetaParser{ private var token: String = _ private var locals: Scope = null - def parse(meta: String, sym: Symbol, symtype: Type): unit = { + def parse(meta: String, sym: Symbol, symtype: Type) { //System.out.println("parse meta for " + sym + ":" + meta + ", locals = " + locals);//DEBUG this.scanner = new StringTokenizer(meta, "()[], \t<;", true) this.owner = sym @@ -34,12 +35,13 @@ abstract class MetaParser{ else owner.setInfo(symtype); } - protected def nextToken(): unit = + protected def nextToken() { try { do { token = scanner.nextToken().trim() } while (token.length() == 0) } catch { case ex: NoSuchElementException => token = "" } + } protected def parseType(): Type = { val str = token @@ -65,7 +67,7 @@ abstract class MetaParser{ if (token == "+") { nextToken(); Flags.COVARIANT } else if (token == "-") { nextToken(); Flags.CONTRAVARIANT } else 0; - assert(token.startsWith("?")); + assert(token startsWith "?", token) val sym = owner.newTypeParameter(NoPosition, newTypeName(token)).setFlag(vflag) nextToken() val lo = @@ -105,14 +107,14 @@ abstract class MetaParser{ tps.toList } - protected def parseClass(): unit = { + protected def parseClass() { locals = newScope def parse(): Type = { - nextToken(); + nextToken() if (token == "[") { PolyType(parseTypeParams(), parse()) } else if (token == "extends") { - val tps = new ListBuffer[Type]; + val tps = new ListBuffer[Type] do { nextToken(); tps += parseType() } while (token == "with"); @@ -126,9 +128,9 @@ abstract class MetaParser{ assert(token == ";") } - protected def parseMethod(): unit = { + protected def parseMethod() { val globals = locals - locals = if (locals eq null) newScope else newScope(locals); + locals = if (locals eq null) newScope else newScope(locals) def parse(): Type = { nextToken(); if (token == "[") PolyType(parseTypeParams(), parse()) @@ -140,13 +142,13 @@ abstract class MetaParser{ assert(token == ";") } - protected def parseField(): unit = { + protected def parseField() { nextToken() owner.setInfo(parseType()) assert(token == ";") } - protected def parseConstr(): unit = { + protected def parseConstr() { def parse(): Type = { nextToken() if (token == "(") MethodType(parseParams(), parse()) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala b/src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala index 859a42804f..986fc11ffd 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala @@ -12,36 +12,36 @@ package scala.tools.nsc.symtab.classfile * @param from The first index where defined data are found * @param to The first index where new data can be written */ -class PickleBuffer(data: Array[byte], from: int, to: int) { +class PickleBuffer(data: Array[Byte], from: Int, to: Int) { var bytes = data var readIndex = from var writeIndex = to /** Double bytes array */ - private def dble: unit = { - val bytes1 = new Array[byte](bytes.length * 2) + private def dble() { + val bytes1 = new Array[Byte](bytes.length * 2) Array.copy(bytes, 0, bytes1, 0, writeIndex) bytes = bytes1 } - def ensureCapacity(capacity: int) = - while (bytes.length < writeIndex + capacity) dble + def ensureCapacity(capacity: Int) = + while (bytes.length < writeIndex + capacity) dble() // -- Basic output routines -------------------------------------------- /** Write a byte of data */ - def writeByte(b: int) { - if (writeIndex == bytes.length) dble - bytes(writeIndex) = b.asInstanceOf[byte] + def writeByte(b: Int) { + if (writeIndex == bytes.length) dble() + bytes(writeIndex) = b.asInstanceOf[Byte] writeIndex += 1 } /** Write a natural number in big endian format, base 128. * All but the last digits have bit 0x80 set. */ - def writeNat(x: int) { - def writeNatPrefix(x: int): unit = { + def writeNat(x: Int) { + def writeNatPrefix(x: Int) { val y = x >>> 7 if (y != 0) writeNatPrefix(y) writeByte((x & 0x7f) | 0x80) @@ -57,15 +57,15 @@ class PickleBuffer(data: Array[byte], from: int, to: int) { * @param pos ... * @param x ... */ - def patchNat(pos: int, x: int) { - def patchNatPrefix(x: int) { + def patchNat(pos: Int, x: Int) { + def patchNatPrefix(x: Int) { writeByte(0) Array.copy(bytes, pos, bytes, pos+1, writeIndex - (pos+1)) - bytes(pos) = ((x & 0x7f) | 0x80).asInstanceOf[byte] + bytes(pos) = ((x & 0x7f) | 0x80).asInstanceOf[Byte] val y = x >>> 7 if (y != 0) patchNatPrefix(y) } - bytes(pos) = (x & 0x7f).asInstanceOf[byte] + bytes(pos) = (x & 0x7f).asInstanceOf[Byte] val y = x >>> 7 if (y != 0) patchNatPrefix(y) } @@ -74,7 +74,7 @@ class PickleBuffer(data: Array[byte], from: int, to: int) { * * @param x The long number to be written. */ - def writeLong(x: long) { + def writeLong(x: Long) { val y = x >> 8 val z = x & 0xff if (-y != (z >> 7)) writeLong(y) @@ -84,16 +84,16 @@ class PickleBuffer(data: Array[byte], from: int, to: int) { // -- Basic input routines -------------------------------------------- /** Peek at the current byte without moving the read index */ - def peekByte(): int = bytes(readIndex) + def peekByte(): Int = bytes(readIndex) /** Read a byte */ - def readByte(): int = { + def readByte(): Int = { val x = bytes(readIndex); readIndex += 1; x } /** Read a natural number in big endian format, base 128. * All but the last digits have bit 0x80 set.*/ - def readNat(): int = { + def readNat(): Int = { var b = 0 var x = 0 do { @@ -104,7 +104,7 @@ class PickleBuffer(data: Array[byte], from: int, to: int) { } /** Read a long number in signed big endian format, base 256. */ - def readLong(len: int): long = { + def readLong(len: Int): Long = { var x = 0L var i = 0 while (i < len) { @@ -123,21 +123,21 @@ class PickleBuffer(data: Array[byte], from: int, to: int) { * @param op ... * @return ... */ - def until[T](end: int, op: () => T): List[T] = + def until[T](end: Int, op: () => T): List[T] = if (readIndex == end) List() else op() :: until(end, op); /** Perform operation <code>op</code> the number of * times specified. Concatenate the results into a list. */ - def times[T](n: int, op: ()=>T): List[T] = + def times[T](n: Int, op: ()=>T): List[T] = if (n == 0) List() else op() :: times(n-1, op) /** Create an index. * * @return ... */ - def createIndex: Array[int] = { - val index = new Array[int](readNat()) + def createIndex: Array[Int] = { + val index = new Array[Int](readNat()) for (i <- 0 until index.length) { index(i) = readIndex readByte() diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/PickleFormat.scala b/src/compiler/scala/tools/nsc/symtab/classfile/PickleFormat.scala index ca6e05a4f8..ce90bd9627 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/PickleFormat.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/PickleFormat.scala @@ -107,7 +107,7 @@ object PickleFormat { * len is remaining length after `len'. */ val MajorVersion = 4 - val MinorVersion = 0 + val MinorVersion = 1 final val TERMname = 1 final val TYPEname = 2 diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 44c281386d..1300f3709d 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -27,8 +27,8 @@ abstract class Pickler extends SubComponent { def newPhase(prev: Phase): StdPhase = new PicklePhase(prev) class PicklePhase(prev: Phase) extends StdPhase(prev) { - def apply(unit: CompilationUnit): unit = { - def pickle(tree: Tree): unit = { + def apply(unit: CompilationUnit) { + def pickle(tree: Tree) { def add(sym: Symbol, pickle: Pickle) = { if (currentRun.compiles(sym) && !currentRun.symData.contains(sym)) { @@ -55,7 +55,7 @@ abstract class Pickler extends SubComponent { } private class Pickle(rootName: Name, rootOwner: Symbol) - extends PickleBuffer(new Array[byte](4096), -1, 0) { + extends PickleBuffer(new Array[Byte](4096), -1, 0) { import scala.collection.mutable.HashMap private var entries = new Array[AnyRef](256) private var ep = 0 @@ -66,7 +66,7 @@ abstract class Pickler extends SubComponent { * @param sym ... * @return ... */ - private def isLocal(sym: Symbol): boolean = ( + private def isLocal(sym: Symbol): Boolean = ( sym.isRefinementClass || sym.name.toTermName == rootName && sym.owner == rootOwner || sym != NoSymbol && isLocal(sym.owner) @@ -80,7 +80,7 @@ abstract class Pickler extends SubComponent { * @param entry ... * @return <code>true</code> iff entry is new. */ - private def putEntry(entry: AnyRef): boolean = index.get(entry) match { + private def putEntry(entry: AnyRef): Boolean = index.get(entry) match { case Some(_) => false case None => if (ep == entries.length) { @@ -99,44 +99,46 @@ abstract class Pickler extends SubComponent { * * @param sym ... */ - def putSymbol(sym: Symbol): unit = if (putEntry(sym)) { - if (isLocal(sym)) { - putEntry(sym.name) - putSymbol(sym.owner) - putSymbol(sym.privateWithin) - putType(sym.info) - if (sym.thisSym.tpe != sym.tpe) - putType(sym.typeOfThis); - putSymbol(sym.alias) - if (!sym.children.isEmpty) { - val (locals, globals) = sym.children.toList.partition(_.isLocalClass) - val children = - if (locals.isEmpty) globals - else { - val localChildDummy = sym.newClass(sym.pos, nme.LOCALCHILD) - localChildDummy.setInfo(ClassInfoType(List(sym.tpe), EmptyScope, localChildDummy)) - localChildDummy :: globals - } - putChildren(sym, children.sort((x, y) => x isLess y)) - } - for (attr <- sym.attributes.reverse) { - if (attr.atp.symbol isNonBottomSubClass definitions.StaticAnnotationClass) - putAnnotation(sym, attr) + def putSymbol(sym: Symbol) { + if (putEntry(sym)) { + if (isLocal(sym)) { + putEntry(sym.name) + putSymbol(sym.owner) + putSymbol(sym.privateWithin) + putType(sym.info) + if (sym.thisSym.tpe != sym.tpe) + putType(sym.typeOfThis); + putSymbol(sym.alias) + if (!sym.children.isEmpty) { + val (locals, globals) = sym.children.toList.partition(_.isLocalClass) + val children = + if (locals.isEmpty) globals + else { + val localChildDummy = sym.newClass(sym.pos, nme.LOCALCHILD) + localChildDummy.setInfo(ClassInfoType(List(sym.tpe), EmptyScope, localChildDummy)) + localChildDummy :: globals + } + putChildren(sym, children.sort((x, y) => x isLess y)) + } + for (attr <- sym.attributes.reverse) { + if (attr.atp.symbol isNonBottomSubClass definitions.StaticAnnotationClass) + putAnnotation(sym, attr) + } + } else if (sym != NoSymbol) { + putEntry(if (sym.isModuleClass) sym.name.toTermName else sym.name) + if (!sym.owner.isRoot) putSymbol(sym.owner) } - } else if (sym != NoSymbol) { - putEntry(if (sym.isModuleClass) sym.name.toTermName else sym.name) - if (!sym.owner.isRoot) putSymbol(sym.owner) } } + private def putSymbols(syms: List[Symbol]) = syms foreach putSymbol - /** Store type and everythig it refers to in map <code>index</code>. * * @param tp ... */ - private def putType(tp: Type): unit = if (putEntry(tp)) { + private def putType(tp: Type): Unit = if (putEntry(tp)) { tp match { case NoType | NoPrefix | DeBruijnIndex(_, _) => ; @@ -166,9 +168,9 @@ abstract class Pickler extends SubComponent { throw new FatalError("bad type: " + tp + "(" + tp.getClass + ")") } } - private def putTypes(tps: List[Type]): unit = tps foreach putType + private def putTypes(tps: List[Type]) { tps foreach putType } - private def putTree(tree: reflect.Tree): unit = if (putEntry(tree)) { + private def putTree(tree: reflect.Tree): Unit = if (putEntry(tree)) { tree match { case reflect.Ident(sym) => putSymbol(sym) case reflect.Select(qual, sym) => putTree(qual); putSymbol(sym) @@ -202,7 +204,7 @@ abstract class Pickler extends SubComponent { private def putRefTreess(trees: List[List[reflect.Tree]]) = trees foreach putRefTrees - private def putType(tpe: reflect.Type): unit = if(putEntry(tpe)) { + private def putType(tpe: reflect.Type): Unit = if (putEntry(tpe)) { tpe match { case reflect.NoPrefix => () case reflect.NoType => () @@ -226,10 +228,11 @@ abstract class Pickler extends SubComponent { } } - private def putRefTypes(tpes: List[reflect.Type]) = + private def putRefTypes(tpes: List[reflect.Type]) { tpes foreach putType + } - private def putSymbol(sym: reflect.Symbol): unit = if(putEntry(sym)) { + private def putSymbol(sym: reflect.Symbol): Unit = if(putEntry(sym)) { sym match { case reflect.Class(fullname) => putConstant(Constant(fullname)) @@ -269,12 +272,12 @@ abstract class Pickler extends SubComponent { else if (c.tag == ClassTag) putEntry(c.typeValue) } - private def putChildren(sym: Symbol, children: List[Symbol]): unit = { + private def putChildren(sym: Symbol, children: List[Symbol]) { assert(putEntry((sym, children))) children foreach putSymbol } - private def putAnnotation(sym: Symbol, annot: AnnotationInfo): unit = { + private def putAnnotation(sym: Symbol, annot: AnnotationInfo) { assert(putEntry((sym, annot))) val AnnotationInfo(atp, args, assocs) = annot putType(atp) @@ -282,16 +285,17 @@ abstract class Pickler extends SubComponent { for ((name, c) <- assocs) { putEntry(name); putAnnotationArg(c) } } - private def putAnnotation(annot: AnnotationInfo): unit = - if(putEntry(annot)) { + private def putAnnotation(annot: AnnotationInfo) { + if (putEntry(annot)) { val AnnotationInfo(tpe, args, assocs) = annot putType(tpe) args foreach putAnnotationArg for ((name, rhs) <- assocs) { putEntry(name); putAnnotationArg(rhs) } } + } private def putAnnotationArg(arg: AnnotationArgument) { - if(putEntry(arg)) { + if (putEntry(arg)) { arg.constant match { case Some(c) => putConstant(c) case _ => putTree(arg.tree) @@ -299,27 +303,28 @@ abstract class Pickler extends SubComponent { } } - private def putAnnotations(annots: List[AnnotationInfo]): unit = + private def putAnnotations(annots: List[AnnotationInfo]) { annots foreach putAnnotation + } // Phase 2 methods: Write all entries to byte array ------------------------------ - private val buf = new PickleBuffer(new Array[byte](4096), -1, 0) + private val buf = new PickleBuffer(new Array[Byte](4096), -1, 0) /** Write a reference to object, i.e., the object's number in the map * <code>index</code>. * * @param ref ... */ - private def writeRef(ref: AnyRef): unit = writeNat(index(ref)) - private def writeRefs(refs: List[AnyRef]): unit = refs foreach writeRef + private def writeRef(ref: AnyRef) { writeNat(index(ref)) } + private def writeRefs(refs: List[AnyRef]) { refs foreach writeRef } /** Write name, owner, flags, and info of a symbol. * * @param sym ... * @return the position offset */ - private def writeSymInfo(sym: Symbol): int = { + private def writeSymInfo(sym: Symbol): Int = { var posOffset = 0 if (sym.pos != NoPosition && sym.owner.isClass && !sym.pos.offset.isEmpty) { writeNat(sym.pos.offset.get) @@ -334,14 +339,14 @@ abstract class Pickler extends SubComponent { } /** Write a name in UTF8 format. */ - def writeName(name: Name): unit = { + def writeName(name: Name) { ensureCapacity(name.length * 3) writeIndex = name.copyUTF8(bytes, writeIndex) } /** Write an entry */ - private def writeEntry(entry: AnyRef): unit = { - def writeBody(entry: AnyRef): int = entry match { + private def writeEntry(entry: AnyRef) { + def writeBody(entry: AnyRef): Int = entry match { case name: Name => writeName(name) if (name.isTermName) TERMname else TYPEname @@ -628,7 +633,7 @@ abstract class Pickler extends SubComponent { } /** Write byte array */ - def finish = { + def finish { assert(writeIndex == 0) writeNat(MajorVersion) writeNat(MinorVersion) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala index 7783e7cb7c..4cd8515900 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala @@ -29,17 +29,19 @@ abstract class UnPickler { * @param bytes bytearray from which we unpickle * @param filename filename associated with bytearray, only used for error messages */ - def unpickle(bytes: Array[byte], offset: int, classRoot: Symbol, moduleRoot: Symbol, filename: String): unit = try { - new UnPickle(bytes, offset, classRoot, moduleRoot) - } catch { - case ex: IOException => - throw ex - case ex: Throwable => - if (settings.debug.value) ex.printStackTrace() - throw new RuntimeException("error reading Scala signature of "+filename+": "+ex.getMessage()) + def unpickle(bytes: Array[Byte], offset: Int, classRoot: Symbol, moduleRoot: Symbol, filename: String) { + try { + new UnPickle(bytes, offset, classRoot, moduleRoot) + } catch { + case ex: IOException => + throw ex + case ex: Throwable => + if (settings.debug.value) ex.printStackTrace() + throw new RuntimeException("error reading Scala signature of "+filename+": "+ex.getMessage()) + } } - private class UnPickle(bytes: Array[byte], offset: int, classRoot: Symbol, moduleRoot: Symbol) extends PickleBuffer(bytes, offset, -1) { + private class UnPickle(bytes: Array[Byte], offset: Int, classRoot: Symbol, moduleRoot: Symbol) extends PickleBuffer(bytes, offset, -1) { if (settings.debug.value) global.log("unpickle " + classRoot + " and " + moduleRoot) checkVersion() private val index = createIndex @@ -70,26 +72,26 @@ abstract class UnPickler { } /** Does entry represent an (internal) symbol */ - private def isSymbolEntry(i: int): boolean = { + private def isSymbolEntry(i: Int): boolean = { val tag = bytes(index(i)) % PosOffset (firstSymTag <= tag && tag <= lastSymTag && (tag != CLASSsym || !isRefinementSymbolEntry(i))) } /** Does entry represent an (internal or external) symbol */ - private def isSymbolRef(i: int): boolean = { + private def isSymbolRef(i: Int): Boolean = { val tag = bytes(index(i)) % PosOffset (firstSymTag <= tag && tag <= lastExtSymTag) } /** Does entry represent a name? */ - private def isNameEntry(i: int): boolean = { + private def isNameEntry(i: Int): Boolean = { val tag = bytes(index(i)) tag == TERMname || tag == TYPEname } /** Does entry represent a symbol attribute? */ - private def isAnnotationEntry(i: int): boolean = { + private def isAnnotationEntry(i: Int): Boolean = { val tag = bytes(index(i)) tag == ATTRIBUTE || tag == CHILDREN } @@ -97,7 +99,7 @@ abstract class UnPickler { /** Does entry represent a refinement symbol? * pre: Entry is a class symbol */ - private def isRefinementSymbolEntry(i: int): boolean = { + private def isRefinementSymbolEntry(i: Int): Boolean = { val savedIndex = readIndex readIndex = index(i) val tag = readByte() @@ -109,9 +111,11 @@ abstract class UnPickler { result } - /** If entry at `i' is undefined, define it by performing operation `op' with - * readIndex at start of i'th entry. Restore readIndex afterwards. */ - private def at[T <: AnyRef](i: int, op: () => T): T = { + /** If entry at <code>i</code> is undefined, define it by performing + * operation <code>op</code> with <code>readIndex at start of i'th + * entry. Restore <code>readIndex</code> afterwards. + */ + private def at[T <: AnyRef](i: Int, op: () => T): T = { var r = entries(i) if (r eq null) { val savedIndex = readIndex @@ -281,12 +285,12 @@ abstract class UnPickler { tag match { case LITERALunit => Constant(()) case LITERALboolean => Constant(if (readLong(len) == 0) false else true) - case LITERALbyte => Constant(readLong(len).asInstanceOf[byte]) - case LITERALshort => Constant(readLong(len).asInstanceOf[short]) - case LITERALchar => Constant(readLong(len).asInstanceOf[char]) - case LITERALint => Constant(readLong(len).asInstanceOf[int]) + case LITERALbyte => Constant(readLong(len).asInstanceOf[Byte]) + case LITERALshort => Constant(readLong(len).asInstanceOf[Short]) + case LITERALchar => Constant(readLong(len).asInstanceOf[Char]) + case LITERALint => Constant(readLong(len).asInstanceOf[Int]) case LITERALlong => Constant(readLong(len)) - case LITERALfloat => Constant(Float.intBitsToFloat(readLong(len).asInstanceOf[int])) + case LITERALfloat => Constant(Float.intBitsToFloat(readLong(len).asInstanceOf[Int])) case LITERALdouble => Constant(Double.longBitsToDouble(readLong(len))) case LITERALstring => Constant(readNameRef().toString()) case LITERALnull => Constant(null) @@ -551,17 +555,17 @@ abstract class UnPickler { private def errorBadSignature(msg: String) = throw new RuntimeException("malformed Scala signature of " + classRoot.name + " at " + readIndex + "; " + msg) - private class LazyTypeRef(i: int) extends LazyType { + private class LazyTypeRef(i: Int) extends LazyType { private val definedAtRunId = currentRunId override def complete(sym: Symbol) { val tp = at(i, readType) sym setInfo tp if (currentRunId != definedAtRunId) sym.setInfo(adaptToNewRunMap(tp)) } - override def load(sym: Symbol): unit = complete(sym) + override def load(sym: Symbol) { complete(sym) } } - private class LazyTypeRefAndAlias(i: int, j: int) extends LazyTypeRef(i) { + private class LazyTypeRefAndAlias(i: Int, j: Int) extends LazyTypeRef(i) { override def complete(sym: Symbol) { super.complete(sym) var alias = at(j, readSymbol) diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index 269e2fb247..082f917f72 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -24,7 +24,7 @@ abstract class AddInterfaces extends InfoTransform { * such traits. * </p> */ - override def phaseNewFlags: long = lateDEFERRED | lateINTERFACE + override def phaseNewFlags: Long = lateDEFERRED | lateINTERFACE /** Type reference after erasure; to be defined in subclass * <code>Erasure</code>. @@ -55,7 +55,7 @@ abstract class AddInterfaces extends InfoTransform { /** Is given trait member symbol a member of the trait's interface * after this transform is performed? */ - private def isInterfaceMember(sym: Symbol): boolean = { + private def isInterfaceMember(sym: Symbol): Boolean = { sym.isType || { sym.info; // to set lateMETHOD flag if necessary sym.isMethod && !(sym hasFlag (PRIVATE | BRIDGE | LABEL)) && @@ -64,7 +64,7 @@ abstract class AddInterfaces extends InfoTransform { } /** Does symbol need an implementation method? */ - private def needsImplMethod(sym: Symbol): boolean = + private def needsImplMethod(sym: Symbol): Boolean = sym.isMethod && isInterfaceMember(sym) && (!(sym hasFlag (DEFERRED | SUPERACCESSOR)) || (sym hasFlag lateDEFERRED)) @@ -151,7 +151,7 @@ abstract class AddInterfaces extends InfoTransform { decls } - override def complete(sym: Symbol): unit = { + override def complete(sym: Symbol) { def implType(tp: Type): Type = tp match { case ClassInfoType(parents, decls, _) => assert(phase == implClassPhase, sym) @@ -165,7 +165,7 @@ abstract class AddInterfaces extends InfoTransform { sym.setInfo(implType(atPhase(currentRun.erasurePhase)(iface.info))) } - override def load(clazz: Symbol): unit = complete(clazz) + override def load(clazz: Symbol) { complete(clazz) } } /** If type <code>tp</code> refers to a non-interface trait, return a @@ -213,7 +213,7 @@ abstract class AddInterfaces extends InfoTransform { private class ChangeOwnerAndReturnTraverser(oldowner: Symbol, newowner: Symbol) extends ChangeOwnerTraverser(oldowner, newowner) { - override def traverse(tree: Tree): unit = { + override def traverse(tree: Tree) { tree match { case Return(expr) => if (tree.symbol == oldowner) tree.symbol = newowner @@ -349,7 +349,7 @@ abstract class AddInterfaces extends InfoTransform { } /* val ensureNoEscapes = new TypeTraverser { - def ensureNoEscape(sym: Symbol): unit = { + def ensureNoEscape(sym: Symbol) { if (sym.hasFlag(PRIVATE)) { var o = currentOwner; while (o != NoSymbol && o != sym.owner && !o.isLocal && !o.hasFlag(PRIVATE)) diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 748d27dc98..83cbd27812 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -58,7 +58,7 @@ abstract class Constructors extends Transform { ps.head } - var thisRefSeen: boolean = false + var thisRefSeen: Boolean = false val intoConstructorTransformer = new Transformer { override def transform(tree: Tree): Tree = tree match { diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 9494b3bba6..78c35f345b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -347,7 +347,7 @@ trait Namers { self: Analyzer => // --- Lazy Type Assignment -------------------------------------------------- def typeCompleter(tree: Tree) = new TypeCompleter(tree) { - override def complete(sym: Symbol): unit = { + override def complete(sym: Symbol) { if (settings.debug.value) log("defining " + sym); val tp = typeSig(tree) sym.setInfo(tp) @@ -361,13 +361,13 @@ trait Namers { self: Analyzer => } def moduleClassTypeCompleter(tree: Tree) = new TypeCompleter(tree) { - override def complete(sym: Symbol): unit = { + override def complete(sym: Symbol) { tree.symbol.info // sets moduleClass info as a side effect. } } def getterTypeCompleter(tree: Tree) = new TypeCompleter(tree) { - override def complete(sym: Symbol): unit = { + override def complete(sym: Symbol) { if (settings.debug.value) log("defining " + sym); sym.setInfo(PolyType(List(), typeSig(tree))) if (settings.debug.value) log("defined " + sym); @@ -376,7 +376,7 @@ trait Namers { self: Analyzer => } def setterTypeCompleter(tree: Tree) = new TypeCompleter(tree) { - override def complete(sym: Symbol): unit = { + override def complete(sym: Symbol) { if (settings.debug.value) log("defining " + sym); sym.setInfo(MethodType(List(typeSig(tree)), UnitClass.tpe)) if (settings.debug.value) log("defined " + sym); @@ -385,13 +385,13 @@ trait Namers { self: Analyzer => } def selfTypeCompleter(tree: Tree) = new TypeCompleter(tree) { - override def complete(sym: Symbol): unit = { + override def complete(sym: Symbol) { sym.setInfo(typer.typedType(tree).tpe) } } def caseFactoryCompleter(tree: Tree) = new TypeCompleter(tree) { - override def complete(sym: Symbol): unit = { + override def complete(sym: Symbol) { val clazz = tree.symbol var tpe = clazz.primaryConstructor.tpe val tparams = clazz.typeParams @@ -471,7 +471,7 @@ trait Namers { self: Analyzer => if (onlyPresentation) methodArgumentNames(meth) = vparamss.map(_.map(_.symbol)); - def convertToDeBruijn(vparams: List[Symbol], level: int): TypeMap = new TypeMap { + def convertToDeBruijn(vparams: List[Symbol], level: Int): TypeMap = new TypeMap { def apply(tp: Type) = { tp match { case SingleType(_, sym) => @@ -836,7 +836,7 @@ trait Namers { self: Analyzer => * This is used for error messages, where we want to speak in terms * of the actual declaration or definition, not in terms of the generated setters * and getters */ - def underlying(member: Symbol) : Symbol = + def underlying(member: Symbol): Symbol = if (member hasFlag ACCESSOR) { if (member hasFlag DEFERRED) { val getter = if (member.isSetter) member.getter(member.owner) else member diff --git a/src/compiler/scala/tools/nsc/typechecker/Variances.scala b/src/compiler/scala/tools/nsc/typechecker/Variances.scala index 41ca733914..35b63e6644 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Variances.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Variances.scala @@ -1,60 +1,62 @@ /* NSC -- new scala compiler - * Copyright 2005 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ -package scala.tools.nsc.typechecker; -import symtab.Flags._; +package scala.tools.nsc.typechecker + +import symtab.Flags._ /** Variances form a lattice, 0 <= COVARIANT <= Variances, 0 <= CONTRAVARIANT <= VARIANCES */ trait Variances { - val global: Global; - import global._; + val global: Global + import global._ /** Convert variance to string */ - private def varianceString(variance: int): String = + private def varianceString(variance: Int): String = if (variance == COVARIANT) "covariant" else if (variance == CONTRAVARIANT) "contravariant" - else "invariant"; + else "invariant" /** Flip between covariant and contravariant */ - private def flip(v: int): int = { - if (v == COVARIANT) CONTRAVARIANT; - else if (v == CONTRAVARIANT) COVARIANT; + private def flip(v: Int): Int = { + if (v == COVARIANT) CONTRAVARIANT + else if (v == CONTRAVARIANT) COVARIANT else v } - private def compose(v1: int, v2: int) = + private def compose(v1: Int, v2: Int) = if (v1 == 0) 0 else if (v1 == CONTRAVARIANT) flip(v2) else v2; /** Map everything below VARIANCES to 0 */ - private def cut(v: int): int = - if (v == VARIANCES) v else 0; + private def cut(v: Int): Int = + if (v == VARIANCES) v else 0 /** Compute variance of type parameter `tparam' in types of all symbols `sym'. */ - def varianceInSyms(syms: List[Symbol])(tparam: Symbol): int = - (VARIANCES /: syms) ((v, sym) => v & varianceInSym(sym)(tparam)); + def varianceInSyms(syms: List[Symbol])(tparam: Symbol): Int = + (VARIANCES /: syms) ((v, sym) => v & varianceInSym(sym)(tparam)) /** Compute variance of type parameter `tparam' in type of symbol `sym'. */ - def varianceInSym(sym: Symbol)(tparam: Symbol): int = + def varianceInSym(sym: Symbol)(tparam: Symbol): Int = if (sym.isAliasType) cut(varianceInType(sym.info)(tparam)) - else varianceInType(sym.info)(tparam); + else varianceInType(sym.info)(tparam) /** Compute variance of type parameter `tparam' in all types `tps'. */ - def varianceInTypes(tps: List[Type])(tparam: Symbol): int = - (VARIANCES /: tps) ((v, tp) => v & varianceInType(tp)(tparam)); + def varianceInTypes(tps: List[Type])(tparam: Symbol): Int = + (VARIANCES /: tps) ((v, tp) => v & varianceInType(tp)(tparam)) /** Compute variance of type parameter `tparam' in all type arguments - * `tps' which correspond to formal type parameters `tparams1'. */ - def varianceInArgs(tps: List[Type], tparams1: List[Symbol])(tparam: Symbol): int = { - var v: int = VARIANCES; - for (val (tp, tparam1) <- tps zip tparams1) { - val v1 = varianceInType(tp)(tparam); + * <code>tps</code> which correspond to formal type parameters `tparams1'. + */ + def varianceInArgs(tps: List[Type], tparams1: List[Symbol])(tparam: Symbol): Int = { + var v: Int = VARIANCES; + for ((tp, tparam1) <- tps zip tparams1) { + val v1 = varianceInType(tp)(tparam) v = v & (if (tparam1.isCovariant) v1 else if (tparam1.isContravariant) flip(v1) else cut(v1)) @@ -62,8 +64,8 @@ trait Variances { v } - /** Compute variance of type parameter `tparam' in type `tp'. */ - def varianceInType(tp: Type)(tparam: Symbol): int = tp match { + /** Compute variance of type parameter <code>tparam</code> in type <code>tp</code>. */ + def varianceInType(tp: Type)(tparam: Symbol): Int = tp match { case ErrorType | WildcardType | NoType | NoPrefix | ThisType(_) | ConstantType(_) => VARIANCES case SingleType(pre, sym) => diff --git a/src/compiler/scala/tools/nsc/util/CharArrayReader.scala b/src/compiler/scala/tools/nsc/util/CharArrayReader.scala index 3bf9eba923..7cd72be464 100644 --- a/src/compiler/scala/tools/nsc/util/CharArrayReader.scala +++ b/src/compiler/scala/tools/nsc/util/CharArrayReader.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -8,10 +8,10 @@ package scala.tools.nsc.util import scala.tools.nsc.util.SourceFile.{LF, FF, CR, SU} -class CharArrayReader(buf: Array[char], start: int, /* startline: int, startcol: int, */ - decodeUni: boolean, error: String => unit) extends Iterator[Char] { +class CharArrayReader(buf: Array[Char], start: Int, /* startline: Int, startcol: Int, */ + decodeUni: Boolean, error: String => Unit) extends Iterator[Char] { - def this(buf: Array[char], decodeUni: boolean, error: String => unit) = + def this(buf: Array[Char], decodeUni: Boolean, error: String => Unit) = this(buf, 0, /* 1, 1, */ decodeUni, error) /** layout constant @@ -20,18 +20,18 @@ class CharArrayReader(buf: Array[char], start: int, /* startline: int, startcol: /** the line and column position of the current character */ - var ch: char = _ + var ch: Char = _ var bp = start var oldBp = -1 - var oldCh : char = _ + var oldCh: Char = _ - //private var cline: int = _ - //private var ccol: int = _ + //private var cline: Int = _ + //private var ccol: Int = _ def cpos = bp - var isUnicode: boolean = _ - var lastLineStartPos: int = 0 - var lineStartPos: int = 0 - var lastBlankLinePos: int = 0 + var isUnicode: Boolean = _ + var lastLineStartPos: Int = 0 + var lineStartPos: Int = 0 + var lastBlankLinePos: Int = 0 private var onlyBlankChars = false //private var nextline = startline @@ -42,13 +42,13 @@ class CharArrayReader(buf: Array[char], start: int, /* startline: int, startcol: if (onlyBlankChars) lastBlankLinePos = lineStartPos lineStartPos = bp onlyBlankChars = true - //nextline = nextline + 1; - //nextcol = 1; + //nextline += 1 + //nextcol = 1 } - def hasNext: boolean = bp < buf.length + def hasNext: Boolean = bp < buf.length - def last: char = if(bp > start + 2) buf(bp - 2) else ' ' // XML literals + def last: Char = if (bp > start + 2) buf(bp - 2) else ' ' // XML literals def next: Char = { //cline = nextline @@ -56,7 +56,7 @@ class CharArrayReader(buf: Array[char], start: int, /* startline: int, startcol: if(!hasNext) return SU // there is an endless stream of SU's at the end oldBp = bp - oldCh = ch; + oldCh = ch ch = buf(bp) isUnicode = false bp = bp + 1 @@ -66,39 +66,40 @@ class CharArrayReader(buf: Array[char], start: int, /* startline: int, startcol: case CR => if (buf(bp) == LF) { ch = LF - bp = bp + 1 + bp += 1 } markNewLine() case LF | FF => markNewLine() case '\\' => - def evenSlashPrefix: boolean = { + def evenSlashPrefix: Boolean = { var p = bp - 2 - while (p >= 0 && buf(p) == '\\') p = p - 1; + while (p >= 0 && buf(p) == '\\') p -= 1 (bp - p) % 2 == 0 } - def udigit: int = { + def udigit: Int = { val d = digit2int(buf(bp), 16) - if (d >= 0) { bp = bp + 1; /* nextcol = nextcol + 1 */ } + if (d >= 0) { bp += 1; /* nextcol = nextcol + 1 */ } else error("error in unicode escape"); d } - // nextcol = nextcol + 1 + // nextcol += 1 if (buf(bp) == 'u' && decodeUni && evenSlashPrefix) { do { - bp = bp + 1; // nextcol = nextcol + 1; + bp += 1 //; nextcol += 1 } while (buf(bp) == 'u'); val code = udigit << 12 | udigit << 8 | udigit << 4 | udigit - ch = code.asInstanceOf[char] + ch = code.asInstanceOf[Char] isUnicode = true } case _ => if (ch > ' ') onlyBlankChars = false - // nextcol = nextcol + 1 + // nextcol += 1 } ch } - def rewind = { + + def rewind { if (oldBp == -1) throw new IllegalArgumentException bp = oldBp ch = oldCh @@ -109,7 +110,7 @@ class CharArrayReader(buf: Array[char], start: int, /* startline: int, startcol: def copy: CharArrayReader = new CharArrayReader(buf, bp, /* nextcol, nextline, */ decodeUni, error) - def digit2int(ch: char, base: int): int = { + def digit2int(ch: Char, base: Int): Int = { if ('0' <= ch && ch <= '9' && ch < '0' + base) ch - '0' else if ('A' <= ch && ch < 'A' + base - 10) diff --git a/src/compiler/scala/tools/nsc/util/HashSet.scala b/src/compiler/scala/tools/nsc/util/HashSet.scala index fea6e8886e..818f19f1f1 100644 --- a/src/compiler/scala/tools/nsc/util/HashSet.scala +++ b/src/compiler/scala/tools/nsc/util/HashSet.scala @@ -1,12 +1,12 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ package scala.tools.nsc.util -class HashSet[T >: Null <: AnyRef](initialCapacity: int) extends Set[T] { +class HashSet[T >: Null <: AnyRef](initialCapacity: Int) extends Set[T] { def this() = this(16) @@ -14,7 +14,7 @@ class HashSet[T >: Null <: AnyRef](initialCapacity: int) extends Set[T] { private var used = 0 private var table = new Array[AnyRef](capacity) - def size: int = used + def size: Int = used def findEntry(x: T): T = { var h = x.hashCode() % capacity @@ -26,7 +26,7 @@ class HashSet[T >: Null <: AnyRef](initialCapacity: int) extends Set[T] { entry.asInstanceOf[T] } - def addEntry(x: T): unit = { + def addEntry(x: T) { var h = x.hashCode() % capacity var entry = table(h) while (entry ne null) { @@ -35,30 +35,30 @@ class HashSet[T >: Null <: AnyRef](initialCapacity: int) extends Set[T] { entry = table(h) } table(h) = x - used = used + 1 - if (used >= (capacity >> 2)) growTable + used += 1 + if (used >= (capacity >> 2)) growTable() } def elements = new Iterator[T] { private var i = 0 - def hasNext: boolean = { - while (i < capacity && (table(i) eq null)) i = i + 1; + def hasNext: Boolean = { + while (i < capacity && (table(i) eq null)) i += 1 i < capacity } def next: T = - if (hasNext) { i = i + 1; table(i - 1).asInstanceOf[T] } + if (hasNext) { i += 1; table(i - 1).asInstanceOf[T] } else null } - private def growTable: unit = { + private def growTable() { val oldtable = table - capacity = capacity * 2 + capacity *= 2 table = new Array[AnyRef](capacity) var i = 0 while (i < oldtable.length) { val entry = oldtable(i) if (entry ne null) addEntry(entry.asInstanceOf[T]) - i = i + 1 + i += 1 } } } diff --git a/src/compiler/scala/tools/nsc/util/ListBuffer.scala b/src/compiler/scala/tools/nsc/util/ListBuffer.scala index 348b3f5700..ac842782fd 100644 --- a/src/compiler/scala/tools/nsc/util/ListBuffer.scala +++ b/src/compiler/scala/tools/nsc/util/ListBuffer.scala @@ -11,19 +11,20 @@ class ListBuffer[T] extends Iterator[T] { private var first = new LinkedList[T] private var limit = first - def +=(x: T): unit = { + def +=(x: T) { limit.elem = x limit.next = new LinkedList[T] limit = limit.next } - def ++=(xs: Iterable[T]): unit = + def ++=(xs: Iterable[T]) { for (x <- xs.elements) +=(x) + } def +(x: T): ListBuffer[T] = { +=(x); this } def ++(xs: Iterable[T]): ListBuffer[T] = { ++=(xs); this } - def hasNext: boolean = + def hasNext: Boolean = first != limit def next: T = { @@ -36,7 +37,7 @@ class ListBuffer[T] extends Iterator[T] { def elements: Iterator[T] = new Iterator[T] { var first = ListBuffer.this.first - def hasNext: boolean = + def hasNext: Boolean = first != limit def next: T = { @@ -47,7 +48,7 @@ class ListBuffer[T] extends Iterator[T] { } } - def clear: unit = { first = limit } + def clear { first = limit } /** override for efficiency */ override def toList: List[T] = { diff --git a/src/compiler/scala/tools/nsc/util/NameTransformer.scala b/src/compiler/scala/tools/nsc/util/NameTransformer.scala index fa953b88c0..43108a4501 100644 --- a/src/compiler/scala/tools/nsc/util/NameTransformer.scala +++ b/src/compiler/scala/tools/nsc/util/NameTransformer.scala @@ -10,12 +10,12 @@ object NameTransformer { private val nops = 128 private val ncodes = 26 * 26 - private class OpCodes(val op: char, val code: String, val next: OpCodes) + private class OpCodes(val op: Char, val code: String, val next: OpCodes) private val op2code = new Array[String](nops) private val code2op = new Array[OpCodes](ncodes) - private def enterOp(op: char, code: String) = { + private def enterOp(op: Char, code: String) = { op2code(op) = code val c = (code.charAt(1) - 'a') * 26 + code.charAt(2) - 'a' code2op(c) = new OpCodes(op, code, code2op(c)) diff --git a/src/compiler/scala/tools/nsc/util/Set.scala b/src/compiler/scala/tools/nsc/util/Set.scala index 9101841e3f..dc27412e10 100644 --- a/src/compiler/scala/tools/nsc/util/Set.scala +++ b/src/compiler/scala/tools/nsc/util/Set.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -12,11 +12,11 @@ abstract class Set[T <: AnyRef] { def findEntry(x: T): T - def addEntry(x: T): unit + def addEntry(x: T): Unit def elements: Iterator[T] - def contains(x: T): boolean = + def contains(x: T): Boolean = findEntry(x) ne null def toList = elements.toList diff --git a/src/compiler/scala/tools/nsc/util/ShowPickled.scala b/src/compiler/scala/tools/nsc/util/ShowPickled.scala index 617ab47e47..3000e6d61a 100644 --- a/src/compiler/scala/tools/nsc/util/ShowPickled.scala +++ b/src/compiler/scala/tools/nsc/util/ShowPickled.scala @@ -6,10 +6,10 @@ package scala.tools.nsc.util +import java.io.{File, FileInputStream, PrintStream, IOException} import java.lang.Integer.toHexString import java.lang.Float.intBitsToFloat import java.lang.Double.longBitsToDouble -import java.io.{File, FileInputStream, PrintStream, IOException} import symtab.{Flags, Names} import symtab.classfile.{PickleBuffer, PickleFormat} @@ -18,7 +18,7 @@ object ShowPickled extends Names { import PickleFormat._ - def tag2string(tag: int): String = tag match { + def tag2string(tag: Int): String = tag match { case TERMname => "TERMname" case TYPEname => "TYPEname" case NONEsym => "NONEsym" @@ -66,7 +66,7 @@ object ShowPickled extends Names { out.println("Version " + buf.readNat() + "." + buf.readNat()) val index = buf.createIndex - def printNameRef() = { + def printNameRef() { val x = buf.readNat() val savedIndex = buf.readIndex buf.readIndex = index(x) @@ -81,7 +81,7 @@ object ShowPickled extends Names { def printTypeRef() = printNat() def printConstantRef() = printNat() - def printSymInfo() = { + def printSymInfo() { printNameRef() printSymbolRef() val flags = buf.readNat() @@ -90,7 +90,7 @@ object ShowPickled extends Names { printTypeRef() } - def printEntry(i: int): unit = { + def printEntry(i: Int) { buf.readIndex = index(i) out.print(i + "," + buf.readIndex + ": ") val tag = buf.readByte() @@ -138,17 +138,17 @@ object ShowPickled extends Names { case LITERALboolean => out.print(if (buf.readLong(len) == 0) " false" else " true") case LITERALbyte => - out.print(" " + buf.readLong(len).asInstanceOf[byte]) + out.print(" " + buf.readLong(len).asInstanceOf[Byte]) case LITERALshort => - out.print(" " + buf.readLong(len).asInstanceOf[short]) + out.print(" " + buf.readLong(len).asInstanceOf[Short]) case LITERALchar => - out.print(" " + buf.readLong(len).asInstanceOf[char]) + out.print(" " + buf.readLong(len).asInstanceOf[Char]) case LITERALint => - out.print(" " + buf.readLong(len).asInstanceOf[int]) + out.print(" " + buf.readLong(len).asInstanceOf[Int]) case LITERALlong => out.print(" " + buf.readLong(len)) case LITERALfloat => - out.print(" " + intBitsToFloat(buf.readLong(len).asInstanceOf[int])) + out.print(" " + intBitsToFloat(buf.readLong(len).asInstanceOf[Int])) case LITERALdouble => out.print(" " + longBitsToDouble(buf.readLong(len))) case LITERALstring => @@ -172,11 +172,11 @@ object ShowPickled extends Names { for (i <- 0 until index.length) printEntry(i) } - def main(args: Array[String]): unit = { + def main(args: Array[String]) { val file = new File(args(0)) try { val stream = new FileInputStream(file) - val data = new Array[byte](stream.available()) + val data = new Array[Byte](stream.available()) stream.read(data) val pickle = new PickleBuffer(data, 0, data.length) printFile(pickle, Console.out) diff --git a/src/compiler/scala/tools/nsc/util/SourceFile.scala b/src/compiler/scala/tools/nsc/util/SourceFile.scala index ec4bd911b1..f810fe96f0 100644 --- a/src/compiler/scala/tools/nsc/util/SourceFile.scala +++ b/src/compiler/scala/tools/nsc/util/SourceFile.scala @@ -127,10 +127,11 @@ class SourceFile(val file: AbstractFile, _content: Array[Char]) { buf.toString() } - private def normalize(input : Array[char]): Array[char] = - if (input.length > 0 && input(input.length - 1) == SU) input + private def normalize(input : Array[Char]): Array[Char] = + if (input.length > 0 && input(input.length - 1) == SU) + input else { - val content = new Array[char](input.length + 1) + val content = new Array[Char](input.length + 1) Array.copy(input, 0, content, 0, input.length) content(input.length) = SU content diff --git a/src/compiler/scala/tools/nsc/util/TreeSet.scala b/src/compiler/scala/tools/nsc/util/TreeSet.scala index e4dc8f4fd6..54ff5e2dd3 100644 --- a/src/compiler/scala/tools/nsc/util/TreeSet.scala +++ b/src/compiler/scala/tools/nsc/util/TreeSet.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -11,7 +11,7 @@ package scala.tools.nsc.util * @author Martin Odersky * @version 1.0 */ -class TreeSet[T >: Null <: AnyRef](less: (T, T) => boolean) extends Set[T] { +class TreeSet[T >: Null <: AnyRef](less: (T, T) => Boolean) extends Set[T] { private class Tree(val elem: T) { var l: Tree = null @@ -30,7 +30,7 @@ class TreeSet[T >: Null <: AnyRef](less: (T, T) => boolean) extends Set[T] { find(tree) } - def addEntry(x: T): unit = { + def addEntry(x: T) { def add(t: Tree): Tree = { if (t eq null) new Tree(x) else if (less(x, t.elem)) { t.l = add(t.l); t } diff --git a/src/compiler/scala/tools/util/SocketConnection.scala b/src/compiler/scala/tools/util/SocketConnection.scala index 7936cfea72..2bb202dd6d 100644 --- a/src/compiler/scala/tools/util/SocketConnection.scala +++ b/src/compiler/scala/tools/util/SocketConnection.scala @@ -22,7 +22,7 @@ import java.net.UnknownHostException */ class SocketConnection(hostname: String, port: Int) { - def this(port: int) = this(InetAddress.getLocalHost().getHostName(), port) + def this(port: Int) = this(InetAddress.getLocalHost().getHostName(), port) private var socket: Socket = _ var out: PrintWriter = _ diff --git a/src/compiler/scala/tools/util/SocketServer.scala b/src/compiler/scala/tools/util/SocketServer.scala index cfa5b3170e..5c3db29e18 100644 --- a/src/compiler/scala/tools/util/SocketServer.scala +++ b/src/compiler/scala/tools/util/SocketServer.scala @@ -25,18 +25,18 @@ import java.net.ServerSocket */ abstract class SocketServer { - def shutDown: boolean - def session(): unit + def shutDown: Boolean + def session() var out: PrintWriter = _ var in: BufferedReader = _ - def fatal(msg: String) = { + def fatal(msg: String): Nothing = { System.err.println(msg) exit(1) } - val port: int = try { + val port: Int = try { val s = new ServerSocket(0) // a port of 0 creates a socket on any free port. val p = s.getLocalPort() s.close() diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index 233b11cc3d..61364836d2 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -35,8 +35,8 @@ object Predef { type boolean = scala.Boolean type unit = scala.Unit - type All = Nothing - type AllRef = Null + @deprecated type All = Nothing + @deprecated type AllRef = Null type String = java.lang.String type StringBuilder = compat.StringBuilder diff --git a/test/scalatest b/test/scalatest index 4dbac001ea..b5107ddc71 100755 --- a/test/scalatest +++ b/test/scalatest @@ -289,7 +289,7 @@ MSIL="msil" EXE="exe" # Tests the .NET backend. test_run_msil() { - assemblies=`get_os_pathlist ./predef.dll`; + assemblies=`get_os_pathlist $PREFIX/lib/predef.dll:$PREFIX/lib/scalaruntime.dll:$PREFIX/lib/mscorlib.dll`; rm -f "$dstbase".$MSIL && rm -f "$dstbase".$EXE && @@ -304,7 +304,7 @@ test_run_msil() { * ) ilasm /output:"$os_dstbase".$EXE "$os_dstbase".$MSIL \ > /dev/null && - mono "$dstbase.$EXE" "msil";; + env MONO_PATH="$PREFIX/lib" mono "$dstbase.$EXE" "msil";; esac && rm -f "$dstbase".$EXE && rm -f "$dstbase".$MSIL; |