diff options
author | michelou <michelou@epfl.ch> | 2007-05-21 12:16:24 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2007-05-21 12:16:24 +0000 |
commit | b196a656c04f94e9bfe6e4d858f795c3094006d5 (patch) | |
tree | 5e2a38f9d64166752d9df01e61df1717208526d2 | |
parent | 0d4ac84f324c0a8f3cf47761b5e92a3c3ea34ac6 (diff) | |
download | scala-b196a656c04f94e9bfe6e4d858f795c3094006d5.tar.gz scala-b196a656c04f94e9bfe6e4d858f795c3094006d5.tar.bz2 scala-b196a656c04f94e9bfe6e4d858f795c3094006d5.zip |
synchronized with trunk
27 files changed, 234 insertions, 173 deletions
diff --git a/src/actors/scala/actors/remote/Serializer.scala b/src/actors/scala/actors/remote/Serializer.scala index 2532e63dfe..6e71171997 100644 --- a/src/actors/scala/actors/remote/Serializer.scala +++ b/src/actors/scala/actors/remote/Serializer.scala @@ -41,7 +41,7 @@ abstract class Serializer(val service: Service) { } @throws(classOf[IOException]) - def writeBytes(outputStream: DataOutputStream, bytes: Array[byte]): unit = { + def writeBytes(outputStream: DataOutputStream, bytes: Array[byte]) { val length = bytes.length; // original length outputStream.writeInt(length) @@ -50,7 +50,7 @@ abstract class Serializer(val service: Service) { } @throws(classOf[IOException]) - def writeObject(outputStream: DataOutputStream, obj: AnyRef) = { + def writeObject(outputStream: DataOutputStream, obj: AnyRef) { val bytes = serialize(obj) writeBytes(outputStream, bytes) } diff --git a/src/actors/scala/actors/remote/Service.scala b/src/actors/scala/actors/remote/Service.scala index 819e039c6d..10bdd3edcf 100644 --- a/src/actors/scala/actors/remote/Service.scala +++ b/src/actors/scala/actors/remote/Service.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -10,6 +10,9 @@ package scala.actors.remote +/** + * @author Philipp Haller + */ trait Service { val kernel = new NetKernel(this) val serializer: Serializer diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index c28b0de4e9..57a4f10bd2 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -78,7 +78,12 @@ trait Trees { var tpe: Type = _ def setPos(pos: Position): this.type = { rawpos = pos; this } - def setType(tp: Type): this.type = { /*assert(kindingIrrelevant(tp) || !kindStar || !tp.isHigherKinded, ""+tp+" should not be higher-kinded");*/ tpe = tp; this } + def setType(tp: Type): this.type = { + /*assert(kindingIrrelevant(tp) || !kindStar || !tp.isHigherKinded, + tp+" should not be higher-kinded");*/ + tpe = tp + this + } def symbol: Symbol = null def symbol_=(sym: Symbol): unit = diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index b668e28c05..5ddf6b052d 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -1378,15 +1378,22 @@ abstract class GenICode extends SubComponent { local } + /** True if the equality comparison is between values that require the use of the rich equality + * comparator (scala.runtime.Comparator.equals). This is the case when either side of the + * comparison might have a run-time type subtype of java.lang.Number or java.lang.Character. + * When it is statically known that both sides are equal and subtypes of Number of Character, + * not using the rich equality is possible (their own equals method will do ok.)*/ def mustUseAnyComparator: Boolean = { val lsym = l.tpe.symbol val rsym = r.tpe.symbol (lsym == definitions.ObjectClass) || (rsym == definitions.ObjectClass) || - (lsym isNonBottomSubClass definitions.BoxedNumberClass)|| - (!forMSIL && (lsym isNonBottomSubClass BoxedCharacterClass)) || - (rsym isNonBottomSubClass definitions.BoxedNumberClass) || - (!forMSIL && (rsym isNonBottomSubClass BoxedCharacterClass)) + (lsym != rsym) && ( + (lsym isNonBottomSubClass definitions.BoxedNumberClass) || + (!forMSIL && (lsym isNonBottomSubClass BoxedCharacterClass)) || + (rsym isNonBottomSubClass definitions.BoxedNumberClass) || + (!forMSIL && (rsym isNonBottomSubClass BoxedCharacterClass)) + ) } if (mustUseAnyComparator) { diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index 6643c8c4fa..c23477e3d0 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -239,6 +239,10 @@ trait Symbols { final def isPrivateLocal = hasFlag(PRIVATE) && hasFlag(LOCAL) + /** Is this symbol a protected local */ + final def isProtectedLocal = + hasFlag(PROTECTED) && hasFlag(LOCAL) + /** Does this symbol denote the primary constructor of its enclosing class? */ final def isPrimaryConstructor = isConstructor && owner.primaryConstructor == this diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 1f2305446b..ac009e4c3e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1217,6 +1217,8 @@ trait Infer { try { infer } catch { + case ex: CyclicReference => + throw ex case ex: TypeError => context.reportGeneralErrors = reportGeneralErrors context.implicitsEnabled = true diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 2b5d898fa5..8aa83f3438 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -377,9 +377,13 @@ abstract class RefChecks extends InfoTransform { var state = CoVariance while (sym != clazz && state != AnyVariance) { //Console.println("flip: " + sym + " " + sym.isParameter());//DEBUG - if ((sym hasFlag PARAM) && !sym.owner.isConstructor) state = -state; - else if (!sym.owner.isClass || sym.isPrivateLocal) state = AnyVariance; - else if (sym.isAliasType) state = NoVariance; + if ((sym hasFlag PARAM) && !sym.owner.isConstructor && + !(tvar.isTypeParameterOrSkolem && sym.isTypeParameterOrSkolem && + tvar.owner == sym.owner)) state = -state; + else if (!sym.owner.isClass || sym.isPrivateLocal || sym.isProtectedLocal) + state = AnyVariance + else if (sym.isAliasType) + state = NoVariance sym = sym.owner } state diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index b71e17498a..b1e81f6ad4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1366,7 +1366,7 @@ trait Typers requires Analyzer { val member = stat.symbol if (context.owner.info.baseClasses.tail forall (bc => member.matchingSymbol(bc, context.owner.thisType) == NoSymbol)) { - if (!settings.Xexperimental.value) + if (!settings.Xexperimental.value && !member.isErroneous) error(member.pos, member.toString+" does not refine a member of its base type") } else { member setFlag OVERRIDE diff --git a/src/compiler/scala/tools/util/AbstractTimer.scala b/src/compiler/scala/tools/util/AbstractTimer.scala index f734692a79..0fe9625197 100644 --- a/src/compiler/scala/tools/util/AbstractTimer.scala +++ b/src/compiler/scala/tools/util/AbstractTimer.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -35,19 +35,20 @@ abstract class AbstractTimer { def issue(message: String, duration: Long): Unit /** Starts a new timer. */ - def start() = { + def start() { starts += currentTime } /** Ends the current timer. */ - def stop(message: String): Unit = { + def stop(message: String) { val stop = currentTime issue(message, stop - starts.pop) } /** Drops the current timer. */ - def drop(): Unit = + def drop() { starts.pop + } //######################################################################## } diff --git a/src/compiler/scala/tools/util/SocketConnection.scala b/src/compiler/scala/tools/util/SocketConnection.scala index c1a9fb2a20..7936cfea72 100644 --- a/src/compiler/scala/tools/util/SocketConnection.scala +++ b/src/compiler/scala/tools/util/SocketConnection.scala @@ -1,12 +1,12 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ -// $id: $ +// $Id$ package scala.tools.util @@ -45,7 +45,7 @@ class SocketConnection(hostname: String, port: Int) { } } - def close() = { + def close() { in.close() out.close() socket.close() diff --git a/src/compiler/scala/tools/util/SocketServer.scala b/src/compiler/scala/tools/util/SocketServer.scala index 06b732c6cb..cfa5b3170e 100644 --- a/src/compiler/scala/tools/util/SocketServer.scala +++ b/src/compiler/scala/tools/util/SocketServer.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -46,7 +46,7 @@ abstract class SocketServer { fatal("Could not listen on any port; exiting.") } - def run(): unit = + def run() { while (!shutDown) { val serverSocket = try { new ServerSocket(port) @@ -75,6 +75,7 @@ abstract class SocketServer { clientSocket.close() serverSocket.close() } + } } diff --git a/src/compiler/scala/tools/util/StringOps.scala b/src/compiler/scala/tools/util/StringOps.scala index b1cd5d9b1a..98c0934f19 100644 --- a/src/compiler/scala/tools/util/StringOps.scala +++ b/src/compiler/scala/tools/util/StringOps.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ diff --git a/src/compiler/scala/tools/util/UTF8Codec.scala b/src/compiler/scala/tools/util/UTF8Codec.scala index d2d420c4b6..c082a3f0d7 100644 --- a/src/compiler/scala/tools/util/UTF8Codec.scala +++ b/src/compiler/scala/tools/util/UTF8Codec.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -23,20 +23,20 @@ object UTF8Codec { val end = from + len while (i < end) { val ch = src(i) - i = i + 1 + i += 1 if (ch < 128) { dst(j) = ch.toByte - j = j + 1 + j += 1 } else if (ch <= 0x3FF) { dst(j) = (0xC0 | (ch >> 6)).toByte dst(j+1) = (0x80 | (ch & 0x3F)).toByte - j = j + 2 + j += 2 } else { dst(j) = (0xE0 | (ch >> 12)).toByte dst(j+1) = (0x80 | ((ch >> 6) & 0x3F)).toByte dst(j+2) = (0x80 | (ch & 0x3F)).toByte - j = j + 3 + j += 3 } } j @@ -45,7 +45,6 @@ object UTF8Codec { def encode(s: String, dst: Array[Byte], to: Int): Int = encode(s.toCharArray(), 0, dst, to, s.length()) - def encode(s: String): Array[Byte] = { val dst = new Array[Byte](s.length() * 3) val len = encode(s, dst, 0) @@ -60,17 +59,17 @@ object UTF8Codec { val end = from + len while (i < end) { var b = src(i) & 0xFF - i = i + 1 + i += 1 if (b >= 0xE0) { b = ((b & 0x0F) << 12) | (src(i) & 0x3F) << 6 b = b | (src(i+1) & 0x3F) - i = i + 2 + i += 2 } else if (b >= 0xC0) { b = ((b & 0x1F) << 6) | (src(i) & 0x3F) - i = i + 1 + i += 1 } dst(j) = b.toChar - j = j + 1 + j += 1 } j } diff --git a/src/library/scala/Symbol.scala b/src/library/scala/Symbol.scala index 112764a223..6110fa07dd 100644 --- a/src/library/scala/Symbol.scala +++ b/src/library/scala/Symbol.scala @@ -13,7 +13,7 @@ package scala import scala.collection.jcl -private[scala] object internedSymbols extends jcl.HashMap[String, ref.WeakReference[Symbol]] +private[scala] object internedSymbols extends jcl.WeakHashMap[Symbol, ref.WeakReference[Symbol]] /** <p> * Instances of <code>Symbol</code> can be created easily with @@ -47,10 +47,10 @@ final case class Symbol(name: String) { * * @return the unique reference to this symbol. */ - def intern: Symbol = synchronized { - internedSymbols.get(name).map(.get).getOrElse(None) match { + def intern: Symbol = internedSymbols.synchronized { + internedSymbols.get(this).map(.get).getOrElse(None) match { case Some(sym) => sym case _ => - internedSymbols(name) = new ref.WeakReference(this); this + internedSymbols(this) = new ref.WeakReference(this); this } } } diff --git a/src/library/scala/runtime/Comparator.java b/src/library/scala/runtime/Comparator.java index c73c7506ba..705bf30d5c 100644 --- a/src/library/scala/runtime/Comparator.java +++ b/src/library/scala/runtime/Comparator.java @@ -36,8 +36,8 @@ public class Comparator { * ICode phase, method <code>genEqEqPrimitive</code>) only when either * side of the comparison is a subclass of <code>AnyVal</code>, of * <code>java.lang.Number</code>, of <code>java.lang.Character</code> or - * is exactly <code>Any</code> or <code>AnyRef</code>. - */ + * is exactly <code>Any</code> or <code>AnyRef</code>, but when both sides + * have different types. */ public static boolean equals(Object a, Object b) { if (a == null) return b == null; diff --git a/src/library/scala/testing/Benchmark.scala b/src/library/scala/testing/Benchmark.scala index 77c5613572..7542635f5b 100644 --- a/src/library/scala/testing/Benchmark.scala +++ b/src/library/scala/testing/Benchmark.scala @@ -14,17 +14,17 @@ package scala.testing import compat.Platform -/** <code>Benchmark</code> can be used to quickly turn an existing - * class into a benchmark. Here is a short example: - * - * <pre> +/** <p> + * <code>Benchmark</code> can be used to quickly turn an existing + * class into a benchmark. Here is a short example: + * </p><pre> * <b>object</b> sort1 <b>extends</b> Sorter <b>with</b> Benchmark { * <b>def</b> run = sort(List.range(1, 1000)) * } * </pre> * <p> - * The run method has to be defined by the user, who will perform - * the timed operation there. + * The <code>run</code> method has to be defined by the user, who + * will perform the timed operation there. * Run the benchmark as follows: * </p> * <pre> @@ -34,6 +34,8 @@ import compat.Platform * This will run the benchmark 5 times and log the execution times in * a file called <code>times.log</code> * </p> + * + * @author Burak Emir */ trait Benchmark { @@ -67,7 +69,7 @@ trait Benchmark { * consecutive runs, and the name of a log file where to * append the times. */ - def main(args: Array[String]): Unit = { + def main(args: Array[String]) { if (args.length > 1) { val logFile = new java.io.FileWriter(args(1), true) // append, not overwrite if (args.length >= 3) diff --git a/src/library/scala/testing/SUnit.scala b/src/library/scala/testing/SUnit.scala index 7c0f76303c..7449328816 100644 --- a/src/library/scala/testing/SUnit.scala +++ b/src/library/scala/testing/SUnit.scala @@ -39,26 +39,31 @@ import scala.collection.mutable.ArrayBuffer * Console.println(tf.toString()) * } * </pre> + * <p> + * The trait <code>TestConsoleMain</code> contains this code as + * a <code>main</code> method, for convenience. + * </p> * - * The trait TestConsoleMain contains this code as a main method, for convenience. + * @author Burak Emir */ object SUnit { - /** convenience trait, mix it in a TestMain object and implement "suite" to get this code + /** convenience trait, mix it in a TestMain object and implement "suite" to get this code * <b>val</b> r = <b>new</b> TestResult() * suite.run(r) * <b>for</b> (<b>val</b> tf <- r.failures()) { * Console.println(tf.toString()) - */ + */ trait TestConsoleMain { - def suite: TestSuite - def main(args:Array[String]) { + def suite: TestSuite + def main(args: Array[String]) { val r = new TestResult() suite.run(r) for (tf <- r.failures()) Console.println(tf.toString()) } } + /** a Test can be run with its result being collected */ trait Test { def run(r: TestResult): Unit @@ -165,21 +170,23 @@ object SUnit { assertNotNull("(no message)", actual) /** - * @deprecated use assertNotEq instead - */ - @deprecated def assertNotSame(msg: String, expected: => AnyRef, actual: => AnyRef): Unit = + * @deprecated use assertNotEq instead + */ + @deprecated + def assertNotSame(msg: String, expected: => AnyRef, actual: => AnyRef): Unit = if (expected.eq(actual)) fail(msg) /** - * @deprecated use assertNotEq instead + * @deprecated use assertNotEq instead */ - @deprecated def assertNotSame(expected: => AnyRef, actual: => AnyRef): Unit = + @deprecated + def assertNotSame(expected: => AnyRef, actual: => AnyRef): Unit = assertNotEq("(no message)", expected, actual) /** fail if expected eq actual */ def assertNotEq(msg: String, expected: => AnyRef, actual: => AnyRef) { if (expected eq actual) fail(msg) - } + } /** fail if expected eq actual */ def assertNotEq(expected: => AnyRef, actual: => AnyRef) { @@ -195,14 +202,16 @@ object SUnit { assertNull("(no message)", actual) /** - * @deprecated use assertEq instead - */ + * @deprecated use assertEq instead + */ + @deprecated def assertSame(msg: String, expected: => AnyRef, actual: => AnyRef): Unit = if(!expected.eq(actual)) fail(msg) /** - * @deprecated use assertEq instead - */ + * @deprecated use assertEq instead + */ + @deprecated def assertSame(expected: => AnyRef, actual: => AnyRef): Unit = assertEq("(no message)", expected, actual) diff --git a/src/library/scala/testing/UnitTest.scala b/src/library/scala/testing/UnitTest.scala index b6975a8e22..74c826044d 100644 --- a/src/library/scala/testing/UnitTest.scala +++ b/src/library/scala/testing/UnitTest.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -11,19 +11,23 @@ package scala.testing - /** * Some simple methods to support unit testing with assertions * to contain more JUnit style assertions which use Scala's features. - * @deprecated use SUnit instead + * + * @author Burak Emir + * + * @deprecated use <a href="SUnit.html" target="contentFrame">SUnit</a> + * instead. */ @deprecated object UnitTest { class Report(report_ok: () => Unit, report_fail: (String,String) => Unit) { def ok(): Unit = report_ok() - def fail(actual: String, expected: String): Unit = + def fail(actual: String, expected: String) { report_fail(actual, expected) + } } var report = new Report( @@ -36,7 +40,7 @@ object UnitTest { /** * @param r ... */ - def setReporter(r: Report) = { + def setReporter(r: Report) { this.report = r } diff --git a/src/library/scala/text/Document.scala b/src/library/scala/text/Document.scala index 336ad30cc2..0808714c9d 100644 --- a/src/library/scala/text/Document.scala +++ b/src/library/scala/text/Document.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -36,14 +36,14 @@ abstract class Document { def :/:(hd: String): Document = hd :: DocBreak :: this /** - * Format this document on WRITER and try to set line breaks so that - * the result fits in WIDTH columns. + * Format this document on <code>writer</code> and try to set line + * breaks so that the result fits in <code>width</code> columns. * * @param width ... * @param writer ... */ - def format(width: Int, writer: Writer): Unit = { - type FmtState = (Int,Boolean,Document) + def format(width: Int, writer: Writer) { + type FmtState = (Int, Boolean, Document) def fits(w: Int, state: List[FmtState]): boolean = state match { case _ if w < 0 => @@ -66,12 +66,12 @@ abstract class Document { fits(w, (i, false, d) :: z) } - def spaces(n: Int): Unit = { + def spaces(n: Int) { var rem = n - while (rem >= 16) { writer write " "; rem = rem - 16 } - if (rem >= 8) { writer write " "; rem = rem - 8 } - if (rem >= 4) { writer write " "; rem = rem - 4 } - if (rem >= 2) { writer write " "; rem = rem - 2} + while (rem >= 16) { writer write " "; rem -= 16 } + if (rem >= 8) { writer write " "; rem -= 8 } + if (rem >= 4) { writer write " "; rem -= 4 } + if (rem >= 2) { writer write " "; rem -= 2} if (rem == 1) { writer write " " } } diff --git a/src/library/scala/util/Fluid.scala b/src/library/scala/util/Fluid.scala index 78e749ee17..046ad2decc 100644 --- a/src/library/scala/util/Fluid.scala +++ b/src/library/scala/util/Fluid.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -15,37 +15,42 @@ package scala.util import Predef._ import java.lang.InheritableThreadLocal -/** Fluids provide a binding mechanism where the current - * value is found through <em>dynamic scope</em>, but where - * access to the fluid itself is resolved through </em>static - * binding</em> to a variable referencing the fluid. - * - * The current value can be retrieved with the - * <code>value</code> method. New values can be - * pushed using the <code>withValue</code> method. - * Values pushed via <code>withValue</code> only - * stay valid while the <code>withValue</code>'s - * <em>second</em> argument, a parameterless closure, - * executes. When the second argument finishes, - * the fluid reverts to the previous value. - * - * Usage of <code>withValue</code> looks like this: - * <blockquote><pre> - * someFluid.withValue(newValue) { - * // ... code called in here that calls value ... - * // ... will be given back the newValue ... - * } - * </pre></blockquote> - * - * Each thread gets its own stack of bindings. When a - * new thread is created, the fluid gets a copy of - * the stack of bindings from the parent thread, and - * from then on the bindings for the new thread - * are independent of those for the original thread. - * - * @author Lex Spoon - * @version 1.0, 21/03/2006 - */ +/** <p> + * Fluids provide a binding mechanism where the current + * value is found through <em>dynamic scope</em>, but where + * access to the fluid itself is resolved through </em>static + * binding</em> to a variable referencing the fluid. + * </p> + * <p> + * The current value can be retrieved with the + * <code>value</code> method. New values can be + * pushed using the <code>withValue</code> method. + * Values pushed via <code>withValue</code> only + * stay valid while the <code>withValue</code>'s + * <em>second</em> argument, a parameterless closure, + * executes. When the second argument finishes, + * the fluid reverts to the previous value. + * </p> + * <p> + * Usage of <code>withValue</code> looks like this: + * </p> + * <blockquote><pre> + * someFluid.withValue(newValue) { + * // ... code called in here that calls value ... + * // ... will be given back the newValue ... + * } + * </pre></blockquote> + * <p> + * Each thread gets its own stack of bindings. When a + * new thread is created, the fluid gets a copy of + * the stack of bindings from the parent thread, and + * from then on the bindings for the new thread + * are independent of those for the original thread. + * </p> + * + * @author Lex Spoon + * @version 1.0, 21/03/2006 + */ class Fluid[T](init: T) { private val tl = new InheritableThreadLocal { override def initialValue = init.asInstanceOf[AnyRef] @@ -71,7 +76,7 @@ class Fluid[T](init: T) { } /** Change the currently bound value, discarding the old value. - * Usually withValue() gives better semantics. + * Usually <code>withValue()</code> gives better semantics. */ def value_=(newval: T) = { tl.set(newval) } diff --git a/src/library/scala/util/Sorting.scala b/src/library/scala/util/Sorting.scala index 24f0de23c1..be5acbeed9 100644 --- a/src/library/scala/util/Sorting.scala +++ b/src/library/scala/util/Sorting.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2006-2007, Ross Judson ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -99,9 +99,9 @@ object Sorting { var i = 0 while (i < n) { swap(a, b) - i = i + 1 - a = a + 1 - b = b + 1 + i += 1 + a += 1 + b += 1 } } def med3(a: Int, b: Int, c: Int) = { @@ -118,9 +118,9 @@ object Sorting { var j = i while (j > off && x(j-1) > x(j)) { swap(j, j-1) - j = j - 1 + j -= 1 } - i = i + 1 + i += 1 } } else { // Choose a partition element, v @@ -142,29 +142,29 @@ object Sorting { var a = off var b = a var c = off + len - 1 - var d = c; + var d = c var done = false while(!done) { while (b <= c && x(b) <= v) { if (x(b) == v) { swap(a, b) - a = a + 1 + a += 1 } - b = b + 1 + b += 1 } while (c >= b && x(c) >= v) { if (x(c) == v) { swap(c, d) - d = d - 1 + d -= 1 } - c = c - 1 + c -= 1 } if (b > c) { done = true } else { swap(b, c) - c = c - 1 - b = b + 1 + c -= 1 + b += 1 } } @@ -196,10 +196,10 @@ object Sorting { var b = _b var i = 0 while (i < n) { - swap(a,b) - i = i + 1 - a = a + 1 - b = b + 1 + swap(a, b) + i += 1 + a += 1 + b += 1 } } def med3(a: Int, b: Int, c: Int) = { @@ -216,9 +216,9 @@ object Sorting { var j = i while (j > off && x(j-1) > x(j)) { swap(j, j-1) - j = j - 1 + j -= 1 } - i = i + 1 + i += 1 } } else { // Choose a partition element, v @@ -246,28 +246,28 @@ object Sorting { while (b <= c && x(b) <= v) { if (x(b) == v) { swap(a, b) - a = a + 1 + a += 1 } - b = b + 1 + b += 1 } while (c >= b && x(c) >= v) { if (x(c) == v) { swap(c, d) - d = d - 1 + d -= 1 } - c = c - 1 + c -= 1 } if (b > c) { done = true } else { swap(b, c) - c = c - 1 - b = b + 1 + c -= 1 + b += 1 } } // Swap partition elements back to middle - val n = off + len; + val n = off + len var s = Math.min(a-off, b-a) vecswap(off, b-s, s) s = Math.min(d-c, n-d-1) @@ -295,9 +295,9 @@ object Sorting { var i = 0 while (i < n) { swap(a, b) - i = i + 1 - a = a + 1 - b = b + 1 + i += 1 + a += 1 + b += 1 } } def med3(a: Int, b: Int, c: Int) = @@ -313,10 +313,10 @@ object Sorting { while (i < len + off) { var j = i while (j>off && x(j-1)>x(j)) { - swap(j,j-1) - j = j - 1 + swap(j, j-1) + j -= 1 } - i = i + 1 + i += 1 } } else { // Choose a partition element, v @@ -344,23 +344,23 @@ object Sorting { while (b <= c && x(b) <= v) { if (x(b) == v) { swap(a, b) - a = a + 1 + a += 1 } - b = b + 1 + b += 1 } while (c >= b && x(c) >= v) { if (x(c) == v) { swap(c, d) - d = d - 1 + d -= 1 } - c = c - 1 + c -= 1 } if (b > c) { done = true } else { swap(b, c) - c = c - 1 - b = b + 1 + c -= 1 + b += 1 } } @@ -392,10 +392,10 @@ object Sorting { var b = _b var i = 0 while (i < n) { - swap(a,b) - i = i + 1 - a = a + 1 - b = b + 1 + swap(a, b) + i += 1 + a += 1 + b += 1 } } def med3(a: Int, b: Int, c: Int) = @@ -412,9 +412,9 @@ object Sorting { var j = i while (j > off && x(j-1) > x(j)) { swap(j, j-1) - j = j - 1 + j -= 1 } - i = i + 1 + i += 1 } } else { // Choose a partition element, v @@ -442,23 +442,23 @@ object Sorting { while (b <= c && x(b) <= v) { if (x(b) == v) { swap(a, b) - a = a + 1 + a += 1 } - b = b + 1 + b += 1 } while (c >= b && x(c) >= v) { if (x(c) == v) { swap(c, d) - d = d - 1 + d -= 1 } - c = c - 1 + c -= 1 } if (b > c) { done = true } else { swap(b, c) - c = c - 1 - b = b + 1 + c -= 1 + b += 1 } } @@ -489,17 +489,17 @@ object Sorting { while (k <= hi) { if ((t_lo <= mid) && ((t_hi > hi) || (f(a(t_lo), a(t_hi))))) { scratch(k) = a(t_lo) - t_lo = t_lo + 1 + t_lo += 1 } else { scratch(k) = a(t_hi) - t_hi = t_hi + 1 + t_hi += 1 } - k = k + 1 + k += 1 } k = lo while (k <= hi) { a(k) = scratch(k) - k = k + 1 + k += 1 } } } diff --git a/test/files/neg/bug649.check b/test/files/neg/bug649.check index a548c41912..80220e1af2 100644 --- a/test/files/neg/bug649.check +++ b/test/files/neg/bug649.check @@ -1,4 +1,4 @@ -bug649.scala:3: error: method foo is defined twice +bug649.scala:3: error: illegal cyclic reference involving method foo def foo[A] = foo[A] ^ one error found diff --git a/test/pending/res/bug1092.res b/test/pending/res/bug1092.res new file mode 100644 index 0000000000..6deef8afd0 --- /dev/null +++ b/test/pending/res/bug1092.res @@ -0,0 +1 @@ +bug1092/A.scala bug1092/B.scala bug1092/C.scala diff --git a/test/pending/res/bug1092/A.scala b/test/pending/res/bug1092/A.scala new file mode 100644 index 0000000000..192e7afe11 --- /dev/null +++ b/test/pending/res/bug1092/A.scala @@ -0,0 +1,4 @@ +object HolderA { + class A(a: Int) +} + diff --git a/test/pending/res/bug1092/B.scala b/test/pending/res/bug1092/B.scala new file mode 100644 index 0000000000..5c80e8e84d --- /dev/null +++ b/test/pending/res/bug1092/B.scala @@ -0,0 +1,4 @@ +object HolderB { + import HolderA.A + trait B extends A +} diff --git a/test/pending/res/bug1092/C.scala b/test/pending/res/bug1092/C.scala new file mode 100644 index 0000000000..f961a93b5b --- /dev/null +++ b/test/pending/res/bug1092/C.scala @@ -0,0 +1,6 @@ +object C extends Application { + import HolderA.A + import HolderB.B + + println(new A(4) with B) +} diff --git a/test/scalatest b/test/scalatest index d4cf45ae76..7dc76614f4 100755 --- a/test/scalatest +++ b/test/scalatest @@ -489,7 +489,7 @@ test_check_all() { test_add_file() { [ $# = 1 ] || abort "internal error"; case "$1" in - *.scala ) + *.scala | *.res ) if [ ! \( -d "$1" -o -f "$1" \) ]; then abort "don't know what to do with '$1'"; fi;; |