summaryrefslogtreecommitdiff
path: root/test/files/pos/tcpoly_seq_typealias.scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2008-05-20 13:29:39 +0000
committermichelou <michelou@epfl.ch>2008-05-20 13:29:39 +0000
commitc1f07338ed21e551446a5c98d262d738a9b7b0ce (patch)
tree8143f69f0b97ff8bb02600991476b104afa652dc /test/files/pos/tcpoly_seq_typealias.scala
parent7d71e4cf09074f3d1cf7539d28bba64a976524d6 (diff)
downloadscala-c1f07338ed21e551446a5c98d262d738a9b7b0ce.tar.gz
scala-c1f07338ed21e551446a5c98d262d738a9b7b0ce.tar.bz2
scala-c1f07338ed21e551446a5c98d262d738a9b7b0ce.zip
int -> Int, etc..
Diffstat (limited to 'test/files/pos/tcpoly_seq_typealias.scala')
-rw-r--r--test/files/pos/tcpoly_seq_typealias.scala54
1 files changed, 27 insertions, 27 deletions
diff --git a/test/files/pos/tcpoly_seq_typealias.scala b/test/files/pos/tcpoly_seq_typealias.scala
index 0498c3b2f6..7a9312a60a 100644
--- a/test/files/pos/tcpoly_seq_typealias.scala
+++ b/test/files/pos/tcpoly_seq_typealias.scala
@@ -1,4 +1,4 @@
-package examples.tcpoly.collection;
+package examples.tcpoly.collection
trait HOSeq {
// an internal interface that encapsulates the accumulation of elements (of type elT) to produce
@@ -56,13 +56,13 @@ trait HOSeq {
final class ListBuffer[A] {
private var start: List[A] = Nil
private var last: ::[A] = _
- private var exported: boolean = false
+ private var exported: Boolean = false
/** Appends a single element to this buffer.
*
* @param x the element to append.
*/
- def += (x: A): unit = {
+ def += (x: A) {
if (exported) copy
if (start.isEmpty) {
last = new HOSeq.this.:: (x, Nil)
@@ -83,13 +83,13 @@ trait HOSeq {
/** Clears the buffer contents.
*/
- def clear: unit = {
+ def clear {
start = Nil
exported = false
}
/** Copy contents of this buffer */
- private def copy = {
+ private def copy {
var cursor = start
val limit = last.tail
clear
@@ -101,36 +101,36 @@ trait HOSeq {
}
implicit def listAccumulator[elT]: Accumulator[List, elT] = new Accumulator[List, elT] {
- private[this] val buff = new ListBuffer[elT]
- def += (el: elT): Unit = buff += el
- def result: List[elT] = buff.toList
+ private[this] val buff = new ListBuffer[elT]
+ def += (el: elT): Unit = buff += el
+ def result: List[elT] = buff.toList
}
trait List[+t] extends Iterable[t] {
- type m[+x] = List[x]
-
- def head: t
- def tail: List[t]
- def isEmpty: Boolean
- def elements: Iterator[t] = new Iterator[t] {
- var these = List.this
- def hasNext: Boolean = !these.isEmpty
- def next: t =
- if (!hasNext)
- throw new NoSuchElementException("next on empty Iterator")
- else {
- val result = these.head; these = these.tail; result
- }
- }
- // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t
- def accumulator[t]: Accumulator[List, t] = listAccumulator[t]
+ type m[+x] = List[x]
+
+ def head: t
+ def tail: List[t]
+ def isEmpty: Boolean
+ def elements: Iterator[t] = new Iterator[t] {
+ var these = List.this
+ def hasNext: Boolean = !these.isEmpty
+ def next: t =
+ if (!hasNext)
+ throw new NoSuchElementException("next on empty Iterator")
+ else {
+ val result = these.head; these = these.tail; result
+ }
+ }
+ // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t
+ def accumulator[t]: Accumulator[List, t] = listAccumulator[t]
}
// TODO: the var tl approach does not seem to work because subtyping isn't fully working yet
final case class ::[+b](hd: b, private val tl: List[b]) extends List[b] {
def head = hd
def tail = if(tl==null) this else tl // hack
- override def isEmpty: boolean = false
+ override def isEmpty: Boolean = false
}
case object Nil extends List[Nothing] {
@@ -140,4 +140,4 @@ trait HOSeq {
def tail: List[Nothing] =
throw new NoSuchElementException("tail of empty list")
}
-} \ No newline at end of file
+}