diff options
author | Martin Odersky <odersky@gmail.com> | 2007-03-05 14:21:28 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-03-05 14:21:28 +0000 |
commit | 2c11ab6c75c4389a35d029aeb69d5d437e83a85a (patch) | |
tree | 6353eaeeb6e075f6e6844c87f61f7ab63cf71593 | |
parent | 0d03cad11528942ccdd8917b6d106b1dbb9afa79 (diff) | |
download | scala-2c11ab6c75c4389a35d029aeb69d5d437e83a85a.tar.gz scala-2c11ab6c75c4389a35d029aeb69d5d437e83a85a.tar.bz2 scala-2c11ab6c75c4389a35d029aeb69d5d437e83a85a.zip |
fixed bugs 948/971;
added () to parameterless methods with side-effects.
37 files changed, 152 insertions, 89 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 8467bcb302..dc2ce3cb2f 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -204,10 +204,12 @@ trait Definitions requires SymbolTable { */ def unapplyTypeListFromReturnType(tp1: Type): List[Type] = { // rename: unapplyTypeListFromReturnType val tp = unapplyUnwrap(tp1) - val B = BooleanClass; - val O = OptionClass; val S = SomeClass; tp.symbol match { // unapplySeqResultToMethodSig - case B => Nil - case O | S => + val B = BooleanClass + val O = OptionClass + val S = SomeClass + tp.symbol match { // unapplySeqResultToMethodSig + case B => Nil + case O | S => val prod = tp.typeArgs.head getProductArgs(prod) match { case Some(all @ (x1::x2::xs)) => all // n >= 2 @@ -452,11 +454,29 @@ trait Definitions requires SymbolTable { val boxedClass = new HashMap[Symbol, Symbol] val unboxMethod = new HashMap[Symbol, Symbol] // Type -> Method - val isUnbox = new HashSet[Symbol] val boxMethod = new HashMap[Symbol, Symbol] // Type -> Method - val isBox = new HashSet[Symbol] val boxedArrayClass = new HashMap[Symbol, Symbol] + def isUnbox(m: Symbol) = m.name == nme.unbox && { + m.tpe match { + case MethodType(_, restpe) => (boxMethod get restpe.symbol) match { + case Some(`m`) => true + case _ => false + } + case _ => false + } + } + + def isBox(m: Symbol) = m.name == nme.box && { + m.tpe match { + case MethodType(List(argtpe), _) => (unboxMethod get argtpe.symbol) match { + case Some(`m`) => true + case _ => false + } + case _ => false + } + } + val refClass = new HashMap[Symbol, Symbol] private val abbrvTag = new HashMap[Symbol, char] @@ -475,7 +495,7 @@ trait Definitions requires SymbolTable { }) val clazz = newClass(ScalaPackageClass, name, List(AnyValClass.typeConstructor)) - .setFlag(ABSTRACT /* SEALED */) // bq: SEALED is interesting for case class descendants, only + .setFlag(ABSTRACT | FINAL) boxedClass(clazz) = getClass(boxedName) boxedArrayClass(clazz) = getClass("scala.runtime.Boxed" + name + "Array") refClass(clazz) = getClass("scala.runtime." + name + "Ref") @@ -489,11 +509,9 @@ trait Definitions requires SymbolTable { val box = newMethod(mclass, nme.box, List(clazz.typeConstructor), ObjectClass.typeConstructor) boxMethod(clazz) = box - isBox += box val unbox = newMethod(mclass, nme.unbox, List(ObjectClass.typeConstructor), clazz.typeConstructor) unboxMethod(clazz) = unbox - isUnbox += unbox clazz } @@ -709,7 +727,7 @@ trait Definitions requires SymbolTable { val anyparam = List(AnyClass.typeConstructor) AnyValClass = newClass(ScalaPackageClass, nme.AnyVal, anyparam) - .setFlag(FINAL | SEALED) + .setFlag(SEALED) ObjectClass = getClass(if (forMSIL) "System.Object" else "java.lang.Object") diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index 980dea08f1..417ab89308 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -841,8 +841,10 @@ trait Symbols requires SymbolTable { if (this hasFlag PRIVATE) { setFlag(notPRIVATE) if (!hasFlag(DEFERRED) && isTerm) setFlag(lateFINAL) - expandName(base) - if (isModule) moduleClass.makeNotPrivate(base) + if (!isStaticModule) { + expandName(base) + if (isModule) moduleClass.makeNotPrivate(base) + } } /** change name by appending $$<fully-qualified-name-of-class `base'> diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala index 45b44f6f17..b12f79898e 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala @@ -234,11 +234,9 @@ abstract class TypeParser { if (typ.IsValueType) { val box = statics.newMethod(NoPos, nme.box). setInfo(MethodType(List(clazz.tpe), definitions.ObjectClass.tpe)); - definitions.isBox += box; definitions.boxMethod(clazz) = box; val unbox = statics.newMethod(NoPos, nme.unbox). setInfo(MethodType(List(definitions.ObjectClass.tpe), clazz.tpe)); - definitions.isUnbox += unbox; definitions.unboxMethod(clazz) = unbox; //Console.println(typ.FullName + " : " + parents); } diff --git a/src/library/scala/Console.scala b/src/library/scala/Console.scala index d2f926a652..4dfc1d90ad 100644 --- a/src/library/scala/Console.scala +++ b/src/library/scala/Console.scala @@ -148,11 +148,11 @@ object Console { * output (i.e. output not terminated by a new line character) has * to be made visible on the terminal. */ - def flush: Unit = out.flush() + def flush(): Unit = out.flush() /** Print a new line character on the terminal. */ - def println: Unit = out.println() + def println(): Unit = out.println() /** Print out an object followed by a new line character. * @@ -194,7 +194,7 @@ object Console { * * @return the string read from the terminal. */ - def readLine: String = in.readLine() + def readLine(): String = in.readLine() /** Print a formatted text and read a full line from the terminal * @@ -204,7 +204,7 @@ object Console { */ def readLine(text: String, args: Any*): String = { format(text, args: _*) - readLine + readLine() } @@ -212,7 +212,7 @@ object Console { * * @return the boolean value read from the terminal. */ - def readBoolean: Boolean = readLine.toLowerCase() match { + def readBoolean(): Boolean = readLine().toLowerCase() match { case "true" => true case "t" => true case "yes" => true @@ -222,27 +222,27 @@ object Console { /** Read a byte value from the terminal. */ - def readByte: Byte = readLine.toByte + def readByte(): Byte = readLine().toByte /** Read a short value from the terminal. */ - def readShort: Short = readLine.toByte + def readShort(): Short = readLine().toByte /** Read a char value from the terminal. */ - def readChar: Char = readLine charAt 0 + def readChar(): Char = readLine() charAt 0 /** Read an int value from the terminal. */ - def readInt: Int = readLine.toInt + def readInt(): Int = readLine().toInt /** Read a float value from the terminal. */ - def readFloat: Float = readLine.toFloat + def readFloat(): Float = readLine().toFloat /** Read a double value from the terminal. */ - def readDouble: Double = readLine.toDouble + def readDouble(): Double = readLine().toDouble /** Read in some structured input, specified by a format specifier. * See class <code>java.text.MessageFormat</code> for details of @@ -252,7 +252,7 @@ object Console { * @return a list of all extracted values. */ def readf(format: String): List[Any] = - textComponents(new MessageFormat(format).parse(readLine)) + textComponents(new MessageFormat(format).parse(readLine())) /** Read in some structured input, specified by a format specifier. * Opposed to <code>readf</code>, this function only returns the diff --git a/src/library/scala/Iterator.scala b/src/library/scala/Iterator.scala index 1a3a022ca6..9d88a72626 100644 --- a/src/library/scala/Iterator.scala +++ b/src/library/scala/Iterator.scala @@ -27,7 +27,7 @@ object Iterator { val empty = new Iterator[Nothing] { def hasNext: Boolean = false - def next: Nothing = throw new NoSuchElementException("next on empty iterator") + def next(): Nothing = throw new NoSuchElementException("next on empty iterator") } /** @@ -37,7 +37,7 @@ object Iterator { def single[a](x: a) = new Iterator[a] { private var hasnext = true def hasNext: Boolean = hasnext - def next: a = + def next(): a = if (hasnext) { hasnext = false; x } else throw new NoSuchElementException("next on empty iterator") } @@ -62,8 +62,8 @@ object Iterator { private var i = start val end = if ((start + length) < xs.length) start else xs.length def hasNext: Boolean = i < end - def next: a = if (hasNext) { val x = xs(i) ; i = i + 1 ; x } - else throw new NoSuchElementException("next on empty iterator") + def next(): a = if (hasNext) { val x = xs(i) ; i = i + 1 ; x } + else throw new NoSuchElementException("next on empty iterator") def head: a = if (hasNext) xs(i); else throw new NoSuchElementException("head on empty iterator") } @@ -77,7 +77,7 @@ object Iterator { private var i = 0 private val len = str.length() def hasNext = i < len - def next = { val c = str charAt i; i = i + 1; c } + def next() = { val c = str charAt i; i = i + 1; c } def head = str charAt i } @@ -89,7 +89,7 @@ object Iterator { private var c: Int = 0 private val cmax = n.arity def hasNext = c < cmax - def next = { val a = n element c; c = c + 1; a } + def next() = { val a = n element c; c = c + 1; a } } /** @@ -125,7 +125,7 @@ object Iterator { new BufferedIterator[Int] { private var i = lo def hasNext: Boolean = if (step > 0) i < end else i > end - def next: Int = + def next(): Int = if (hasNext) { val j = i; i = i + step; j } else throw new NoSuchElementException("next on empty iterator") def head: Int = @@ -148,7 +148,7 @@ object Iterator { new BufferedIterator[Int] { private var i = lo def hasNext: Boolean = i < end - def next: Int = + def next(): Int = if (i < end) { val j = i; i = step(i); j } else throw new NoSuchElementException("next on empty iterator") def head: Int = @@ -178,7 +178,7 @@ object Iterator { new BufferedIterator[Int] { private var i = lo def hasNext: Boolean = true - def next: Int = { val j = i; i = i + step; j } + def next(): Int = { val j = i; i = i + step; j } def head: Int = i } @@ -194,7 +194,7 @@ object Iterator { new BufferedIterator[Int] { private var i = lo def hasNext: Boolean = true - def next: Int = { val j = i; i = step(i); j } + def next(): Int = { val j = i; i = step(i); j } def head: Int = i } @@ -216,7 +216,7 @@ trait Iterator[+A] { /** Returns the next element. */ - def next: A + def next(): A /** Returns a new iterator that iterates only over the first <code>n</code> * elements. @@ -227,7 +227,7 @@ trait Iterator[+A] { def take(n: Int) = new Iterator[A] { var remaining = n def hasNext = remaining > 0 && Iterator.this.hasNext - def next: A = + def next(): A = if (hasNext) { remaining = remaining - 1; Iterator.this.next } else throw new NoSuchElementException("next on empty iterator") } @@ -245,7 +245,7 @@ trait Iterator[+A] { */ def map[B](f: A => B): Iterator[B] = new Iterator[B] { def hasNext = Iterator.this.hasNext - def next = f(Iterator.this.next) + def next() = f(Iterator.this.next) } /** Returns a new iterator that first yields the elements of this @@ -254,7 +254,7 @@ trait Iterator[+A] { */ def append[B >: A](that: Iterator[B]) = new Iterator[B] { def hasNext = Iterator.this.hasNext || that.hasNext - def next = if (Iterator.this.hasNext) Iterator.this.next else that.next + def next() = if (Iterator.this.hasNext) Iterator.this.next else that.next } /** Returns a new iterator that first yields the elements of this @@ -262,7 +262,7 @@ trait Iterator[+A] { */ def ++[B >: A](that: Iterator[B]) = new Iterator[B] { def hasNext = Iterator.this.hasNext || that.hasNext - def next = if (Iterator.this.hasNext) Iterator.this.next else that.next + def next() = if (Iterator.this.hasNext) Iterator.this.next else that.next } /** Applies the given function <code>f</code> to each element of @@ -281,7 +281,7 @@ trait Iterator[+A] { cur = f(Iterator.this.next) hasNext } else false - def next: B = + def next(): B = if (cur.hasNext) cur.next else if (Iterator.this.hasNext) { cur = f(Iterator.this.next) @@ -301,7 +301,7 @@ trait Iterator[+A] { skip ahead && p(hd) } - def next: A = + def next(): A = if (hasNext) { ahead = false; hd } else throw new NoSuchElementException("next on empty iterator") def head: A = { skip; hd } diff --git a/src/library/scala/collection/BitSet.scala b/src/library/scala/collection/BitSet.scala index 374ad1fb71..a1343d6697 100644 --- a/src/library/scala/collection/BitSet.scala +++ b/src/library/scala/collection/BitSet.scala @@ -51,7 +51,7 @@ abstract class BitSet extends Set[Int] { } findNext def hasNext: Boolean = i < capacity - def next: Int = { val j = i; i = i + 1; findNext; j } + def next(): Int = { val j = i; i = i + 1; findNext; j } } diff --git a/src/library/scala/collection/Map.scala b/src/library/scala/collection/Map.scala index 1d00aaf44b..eed6be9290 100644 --- a/src/library/scala/collection/Map.scala +++ b/src/library/scala/collection/Map.scala @@ -98,7 +98,7 @@ trait Map[A, +B] extends PartialFunction[A, B] with Iterable[(A, B)] { /** @return the keys of this map as a set. */ - def keySet = new Set[A] { + def keySet: Set[A] = new Set[A] { def size = Map.this.size def contains(key : A) = Map.this.contains(key) def elements = Map.this.elements.map(._1) diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala index 5ed7a5dbb8..0d97a50176 100644 --- a/src/library/scala/collection/mutable/DoubleLinkedList.scala +++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala @@ -42,7 +42,7 @@ abstract class DoubleLinkedList[A, This >: Null <: DoubleLinkedList[A, This]] that.prev = this } - def remove: Unit = { + def remove() { if (next ne null) next.prev = prev if (prev ne null) diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala index 6bb6af59f3..0c9ec9c4d6 100644 --- a/src/library/scala/collection/mutable/FlatHashTable.scala +++ b/src/library/scala/collection/mutable/FlatHashTable.scala @@ -105,7 +105,7 @@ trait FlatHashTable[A] { while (i < table.length && (null == table(i))) i = i + 1; i < table.length } - def next: A = + def next(): A = if (hasNext) { i = i + 1; table(i - 1).asInstanceOf[A] } else Iterator.empty.next } diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index f0932242bc..cce39bcfcc 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -245,7 +245,7 @@ final class ListBuffer[A] extends Buffer[A] { override def elements = new Iterator[A] { var cursor: List[A] = null def hasNext: Boolean = !start.isEmpty && cursor != last - def next: A = + def next(): A = if (!hasNext) { throw new NoSuchElementException("next on empty Iterator") } else { diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala index 8983949aaa..84166c47bd 100644 --- a/src/library/scala/collection/mutable/MutableList.scala +++ b/src/library/scala/collection/mutable/MutableList.scala @@ -60,7 +60,7 @@ trait MutableList[A] extends Seq[A] with PartialFunction[Int, A] { len = len + 1 } - protected def reset: Unit = { + protected def reset() { first = null last = null len = 0 diff --git a/src/library/scala/collection/mutable/ObservableBuffer.scala b/src/library/scala/collection/mutable/ObservableBuffer.scala index e1c98a1e85..424c80ea86 100644 --- a/src/library/scala/collection/mutable/ObservableBuffer.scala +++ b/src/library/scala/collection/mutable/ObservableBuffer.scala @@ -31,7 +31,7 @@ trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This abstract override def +(element: A): Buffer[A] = { super.+(element) publish(new Include((End, element)) with Undoable { - def undo: Unit = trimEnd(1) + def undo() { trimEnd(1) } }) this } @@ -39,7 +39,7 @@ trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This abstract override def +:(element: A): Buffer[A] = { super.+:(element); publish(new Include((Start, element)) with Undoable { - def undo: Unit = trimStart(1) + def undo() { trimStart(1) } }) this } @@ -50,7 +50,7 @@ trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This val it = iter.elements while (it.hasNext) { publish(new Include((Index(i), it.next)) with Undoable { - def undo: Unit = remove(i); + def undo { remove(i) } }) i = i + 1 } @@ -60,7 +60,7 @@ trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This val oldelement = apply(n) super.update(n, newelement) publish(new Update((Index(n), newelement)) with Undoable { - def undo: Unit = update(n, oldelement) + def undo { update(n, oldelement) } }) } @@ -68,7 +68,7 @@ trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This val oldelement = apply(n) super.remove(n) publish(new Remove((Index(n), oldelement)) with Undoable { - def undo: Unit = insert(n, oldelement) + def undo { insert(n, oldelement) } }) oldelement } @@ -76,7 +76,7 @@ trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This abstract override def clear(): Unit = { super.clear publish(new Reset with Undoable { - def undo: Unit = throw new UnsupportedOperationException("cannot undo") + def undo { throw new UnsupportedOperationException("cannot undo") } }) } } diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index 9b3cba4928..b4e35aebb3 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -109,7 +109,7 @@ class PriorityQueue[A <% Ordered[A]] extends ResizableArray[A] { * @throws Predef.NoSuchElementException * @return the element with the highest priority. */ - def dequeue: A = + def dequeue(): A = if (size > 1) { size = size - 1 swap(1, size) @@ -140,7 +140,7 @@ class PriorityQueue[A <% Ordered[A]] extends ResizableArray[A] { Array.copy(array, 0, as, 0, size) var i = size - 1 def hasNext: Boolean = i > 0 - def next: A = { + def next(): A = { val res = as(1) as(1) = as(i) i = i - 1 diff --git a/src/library/scala/collection/mutable/PriorityQueueProxy.scala b/src/library/scala/collection/mutable/PriorityQueueProxy.scala index 869caf805a..1162570b12 100644 --- a/src/library/scala/collection/mutable/PriorityQueueProxy.scala +++ b/src/library/scala/collection/mutable/PriorityQueueProxy.scala @@ -72,7 +72,7 @@ abstract class PriorityQueueProxy[A <% Ordered[A]] extends PriorityQueue[A] * * @return the element with the highest priority. */ - override def dequeue: A = self.dequeue + override def dequeue(): A = self.dequeue /** Returns the element with the highest priority in the queue, * or throws an error if there is no element contained in the queue. diff --git a/src/library/scala/collection/mutable/Publisher.scala b/src/library/scala/collection/mutable/Publisher.scala index 7e6e386fb8..8d499e2e24 100644 --- a/src/library/scala/collection/mutable/Publisher.scala +++ b/src/library/scala/collection/mutable/Publisher.scala @@ -40,7 +40,7 @@ trait Publisher[A, This <: Publisher[A, This]] requires This { def removeSubscription(sub: Subscriber[A, This]): Unit = filters -= sub - def removeSubscriptions: Unit = filters.clear + def removeSubscriptions() { filters.clear } protected def publish(event: A): Unit = filters.keys.foreach(sub => diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala index 9e610ac392..ccb829171b 100644 --- a/src/library/scala/collection/mutable/Queue.scala +++ b/src/library/scala/collection/mutable/Queue.scala @@ -63,7 +63,7 @@ class Queue[A] extends MutableList[A] { * @throws Predef.NoSuchElementException * @return the first element of the queue. */ - def dequeue: A = + def dequeue(): A = if (first eq null) throw new NoSuchElementException("queue empty") else { diff --git a/src/library/scala/collection/mutable/QueueProxy.scala b/src/library/scala/collection/mutable/QueueProxy.scala index e882303db2..dc880edd71 100644 --- a/src/library/scala/collection/mutable/QueueProxy.scala +++ b/src/library/scala/collection/mutable/QueueProxy.scala @@ -71,7 +71,7 @@ trait QueueProxy[A] extends Queue[A] with SeqProxy[A] { * * @return the first element of the queue. */ - override def dequeue: A = self.dequeue + override def dequeue(): A = self.dequeue /** Returns the first element in the queue, or throws an error if there * is no element contained in the queue. diff --git a/src/library/scala/collection/mutable/ResizableArray.scala b/src/library/scala/collection/mutable/ResizableArray.scala index acd8d53179..daf3888ade 100644 --- a/src/library/scala/collection/mutable/ResizableArray.scala +++ b/src/library/scala/collection/mutable/ResizableArray.scala @@ -53,7 +53,7 @@ trait ResizableArray[A] extends Seq[A] { def elements: Iterator[A] = new Iterator[A] { var i = 0 def hasNext: Boolean = i < size - def next: A = { i = i + 1; array(i - 1) } + def next(): A = { i = i + 1; array(i - 1) } } //########################################################################## diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala index 9b7f0760b5..7f01e7e9d5 100644 --- a/src/library/scala/collection/mutable/Stack.scala +++ b/src/library/scala/collection/mutable/Stack.scala @@ -72,7 +72,7 @@ class Stack[A] extends MutableList[A] { * @throws Predef.NoSuchElementException * @return the top element */ - def pop: A = + def pop(): A = if (first ne null) { val res = first.elem first = first.next diff --git a/src/library/scala/collection/mutable/StackProxy.scala b/src/library/scala/collection/mutable/StackProxy.scala index 24b8d743e3..245dbd9605 100644 --- a/src/library/scala/collection/mutable/StackProxy.scala +++ b/src/library/scala/collection/mutable/StackProxy.scala @@ -77,7 +77,7 @@ trait StackProxy[A] extends Stack[A] with SeqProxy[A] { /** Removes the top element from the stack. */ - override def pop: A = self.pop + override def pop(): A = self.pop /** * Removes all elements from the stack. After this operation completed, diff --git a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala index 26edf0d68d..008afee9b6 100644 --- a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala +++ b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala @@ -57,7 +57,7 @@ class SynchronizedPriorityQueue[A <% Ordered[A]] extends PriorityQueue[A] { * * @return the element with the highest priority. */ - override def dequeue: A = synchronized { super.dequeue } + override def dequeue(): A = synchronized { super.dequeue } /** Returns the element with the highest priority in the queue, * or throws an error if there is no element contained in the queue. diff --git a/src/library/scala/collection/mutable/SynchronizedQueue.scala b/src/library/scala/collection/mutable/SynchronizedQueue.scala index 19f4813301..6bc0d83b1b 100644 --- a/src/library/scala/collection/mutable/SynchronizedQueue.scala +++ b/src/library/scala/collection/mutable/SynchronizedQueue.scala @@ -60,7 +60,7 @@ class SynchronizedQueue[A] extends Queue[A] { * * @return the first element of the queue. */ - override def dequeue: A = synchronized { super.dequeue } + override def dequeue(): A = synchronized { super.dequeue } /** Returns the first element in the queue, or throws an error if there * is no element contained in the queue. diff --git a/src/library/scala/collection/mutable/SynchronizedStack.scala b/src/library/scala/collection/mutable/SynchronizedStack.scala index c1acb68792..ffc1105fbd 100644 --- a/src/library/scala/collection/mutable/SynchronizedStack.scala +++ b/src/library/scala/collection/mutable/SynchronizedStack.scala @@ -66,7 +66,7 @@ class SynchronizedStack[A] extends Stack[A] { /** Removes the top element from the stack. */ - override def pop: A = synchronized { super.pop } + override def pop(): A = synchronized { super.pop } /** * Removes all elements from the stack. After this operation completed, diff --git a/src/library/scala/collection/mutable/Undoable.scala b/src/library/scala/collection/mutable/Undoable.scala index 302273595a..8adb8f5b54 100644 --- a/src/library/scala/collection/mutable/Undoable.scala +++ b/src/library/scala/collection/mutable/Undoable.scala @@ -22,5 +22,5 @@ trait Undoable { /** Undo the last operation. */ - def undo: Unit + def undo() } diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala index ff72873f86..f9d34fa024 100644 --- a/src/library/scala/io/Source.scala +++ b/src/library/scala/io/Source.scala @@ -51,7 +51,7 @@ object Source { def fromChar(c: Char): Source = { val it = Iterator.single(c) new Source { - def reset = fromChar(c) + def reset() = fromChar(c) val iter = it } } @@ -64,7 +64,7 @@ object Source { def fromChars(chars: Array[Char]): Source = { val it = Iterator.fromArray(chars) new Source { - def reset = fromChars(chars) + def reset() = fromChars(chars) val iter = it } } @@ -77,7 +77,7 @@ object Source { def fromString(s: String): Source = { val it = Iterator.fromString(s) new Source { - def reset = fromString(s) + def reset() = fromString(s) val iter = it } } @@ -157,7 +157,7 @@ object Source { data = bufIn.read() } val s = new Source { - def reset = fromURL(url) + def reset() = fromURL(url) val iter = it } s.descr = url.toString() @@ -366,6 +366,6 @@ abstract class Source extends Iterator[Char] { } /** the actual reset method */ - def reset: Source + def reset(): Source } diff --git a/src/library/scala/ref/Reference.scala b/src/library/scala/ref/Reference.scala index f59964de72..daebef9526 100644 --- a/src/library/scala/ref/Reference.scala +++ b/src/library/scala/ref/Reference.scala @@ -18,7 +18,7 @@ trait Reference[+T <: AnyRef] extends Function0[T] { def apply(): T def get = if (!isValid) None else Some(apply()) override def toString = if (!isValid) "<deleted>" else apply().toString - def clear: Unit - def enqueue: Boolean - def isEnqueued: Boolean + def clear(): Unit + def enqueue(): Boolean + def isEnqueued(): Boolean } diff --git a/src/library/scala/runtime/BoxedArray.scala b/src/library/scala/runtime/BoxedArray.scala index 0036c8f4fe..dbe70968e1 100644 --- a/src/library/scala/runtime/BoxedArray.scala +++ b/src/library/scala/runtime/BoxedArray.scala @@ -43,7 +43,7 @@ abstract class BoxedArray extends Seq[Any] { def elements = new Iterator[Any] { var index = 0 def hasNext: Boolean = index < length - def next: Any = { val i = index; index = i + 1; apply(i) } + def next(): Any = { val i = index; index = i + 1; apply(i) } } /** The underlying array value diff --git a/src/library/scala/runtime/RichChar.scala b/src/library/scala/runtime/RichChar.scala index d4b66a305f..e982ec6d0a 100644 --- a/src/library/scala/runtime/RichChar.scala +++ b/src/library/scala/runtime/RichChar.scala @@ -55,7 +55,7 @@ final class RichChar(x: Char) extends Proxy with Ordered[Char] { def to(y: Char): Iterator[Char] = new BufferedIterator[Char] { private var ch = x def hasNext: Boolean = ch < y - def next: Char = + def next(): Char = if (hasNext) { val j = ch; ch = (ch + 1).toChar; j } else throw new NoSuchElementException("next on empty iterator") def head: Char = diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala index e5f88bcba6..e5f275d71d 100644 --- a/src/library/scala/runtime/RichString.scala +++ b/src/library/scala/runtime/RichString.scala @@ -80,7 +80,7 @@ final class RichString(val self: String) extends Proxy with Seq[Char] with Order val len = self.length var index = 0 def hasNext: Boolean = index < len - def next: String = { + def next(): String = { if (index >= len) throw new NoSuchElementException("next on empty iterator") val start = index while (index < len && !isLineBreak(apply(index))) index = index + 1 diff --git a/src/library/scala/testing/Benchmark.scala b/src/library/scala/testing/Benchmark.scala index 6cbe587b46..4d7cc751cf 100644 --- a/src/library/scala/testing/Benchmark.scala +++ b/src/library/scala/testing/Benchmark.scala @@ -38,7 +38,7 @@ import compat.Platform trait Benchmark { /** this method should be implemented by the concrete benchmark */ - def run: Unit + def run() var multiplier = 1 @@ -53,7 +53,7 @@ trait Benchmark { for (val i <- List.range(1, noTimes + 1)) yield { val startTime = Platform.currentTime var i = 0; while(i < multiplier) { - run + run() i = i + 1 } val stopTime = Platform.currentTime diff --git a/src/library/scala/testing/UnitTest.scala b/src/library/scala/testing/UnitTest.scala index db2eab6f4e..10cade8a88 100644 --- a/src/library/scala/testing/UnitTest.scala +++ b/src/library/scala/testing/UnitTest.scala @@ -21,7 +21,7 @@ package scala.testing object UnitTest { class Report(report_ok: () => Unit, report_fail: (String,String) => Unit) { - def ok: Unit = report_ok() + def ok(): Unit = report_ok() def fail(actual: String, expected: String): Unit = report_fail(actual, expected) } diff --git a/src/library/scala/util/parsing/CharInputStreamIterator.scala b/src/library/scala/util/parsing/CharInputStreamIterator.scala index d08fa20b6d..af14e1fce0 100644 --- a/src/library/scala/util/parsing/CharInputStreamIterator.scala +++ b/src/library/scala/util/parsing/CharInputStreamIterator.scala @@ -26,7 +26,7 @@ class CharInputStreamIterator(in: InputStream) extends Iterator[char] { private var chSet = false private var error: IOException = null - private def lookahead: unit = try { + private def lookahead(): unit = try { ch = in.read(); chSet = ch >= 0 } catch { case ex: EOFException => ch = -1 @@ -38,7 +38,7 @@ class CharInputStreamIterator(in: InputStream) extends Iterator[char] { chSet } - def next: char = { + def next(): char = { if (!chSet) lookahead chSet = false ch.asInstanceOf[char] diff --git a/src/library/scala/util/parsing/SimpleTokenizer.scala b/src/library/scala/util/parsing/SimpleTokenizer.scala index b7bab36e81..760fdc6f92 100644 --- a/src/library/scala/util/parsing/SimpleTokenizer.scala +++ b/src/library/scala/util/parsing/SimpleTokenizer.scala @@ -36,7 +36,7 @@ class SimpleTokenizer(in: Iterator[char], delimiters: String) extends Iterator[S private val EOI = -1 - private def nextChar: int = if (in.hasNext) in.next else EOI + private def nextChar(): int = if (in.hasNext) in.next else EOI private var ch: int = nextChar @@ -44,17 +44,17 @@ class SimpleTokenizer(in: Iterator[char], delimiters: String) extends Iterator[S def hasNext: boolean = ch != EOI - def next: String = { - while (ch <= ' ' && ch != EOI) ch = nextChar + def next(): String = { + while (ch <= ' ' && ch != EOI) ch = nextChar() if (ch == EOI) "" else { buf.setLength(0) if (isDelimiter(ch)) { - buf append ch.asInstanceOf[char]; ch = nextChar + buf append ch.asInstanceOf[char]; ch = nextChar() } else { while (ch > ' ' && ch != EOI && !isDelimiter(ch)) { buf append ch.asInstanceOf[char] - ch = nextChar + ch = nextChar() } } if (tracing) Console.println("<" + buf.toString() + ">") diff --git a/test/files/neg/bug960.check b/test/files/neg/bug960.check new file mode 100644 index 0000000000..7929176c87 --- /dev/null +++ b/test/files/neg/bug960.check @@ -0,0 +1,7 @@ +bug960.scala:18: error: cannot resolve overloaded unapply + case List(x, xs) => 7
+ ^ +bug960.scala:12: error: method unapply is defined twice + def unapply[a](xs: List[a]): Option[Null] = xs match {
+ ^ +two errors found diff --git a/test/files/neg/bug960.scala b/test/files/neg/bug960.scala new file mode 100755 index 0000000000..5101cf8433 --- /dev/null +++ b/test/files/neg/bug960.scala @@ -0,0 +1,20 @@ +sealed abstract class List[+a] +private case object Nil extends List[Nothing] +private final case class Cons[+a](head: a, tail: List[a]) +extends List[a] + +object List { + def unapply[a](xs: List[a]): Option[(a, List[a])] = xs match { + case Nil => None + case Cons(x, xs) => Some(x, xs) + } + + def unapply[a](xs: List[a]): Option[Null] = xs match { + case Nil => Some(null) + case Cons(_, _) => None + } + + def foo[a](xs: List[a]) = xs match { + case List(x, xs) => 7 + } +} diff --git a/test/files/neg/bug961.check b/test/files/neg/bug961.check new file mode 100644 index 0000000000..d03645bfdf --- /dev/null +++ b/test/files/neg/bug961.check @@ -0,0 +1,4 @@ +bug961.scala:11: error: Temp.this.B does not take parameters + B() match {
+ ^ +one error found diff --git a/test/files/neg/bug961.scala b/test/files/neg/bug961.scala new file mode 100755 index 0000000000..eb1620abe1 --- /dev/null +++ b/test/files/neg/bug961.scala @@ -0,0 +1,14 @@ +object Temp{ + abstract class A + object B{ + private case class B_inner extends A + def apply: A = B_inner + def unapply(a: A) = a match { + case B_inner() => true + case _ => false + } + } + B() match { + case B() => Console.println("match") + } +} |