Merge branch 'master' of github.com:JetBrains/kotlin

This commit is contained in:
James Strachan
2012-04-19 09:52:11 +01:00
61 changed files with 468 additions and 202 deletions
+2 -2
View File
@@ -25,7 +25,7 @@ public inline fun <T> java.util.Iterator<T>.iterator() : java.util.Iterator<T> =
Helper to make java.util.Enumeration usable in for
*/
public fun <erased T> java.util.Enumeration<T>.iterator(): Iterator<T> = object: Iterator<T> {
public override val hasNext: Boolean
override val hasNext: Boolean
get() = hasMoreElements()
public override fun next() : T = nextElement().sure()
@@ -114,4 +114,4 @@ public inline fun Throwable.printStackTrace(writer: PrintWriter): Unit {
public inline fun Throwable.printStackTrace(stream: PrintStream): Unit {
val jlt = this as java.lang.Throwable
jlt.printStackTrace(stream)
}
}
@@ -35,15 +35,15 @@ abstract class FunctionalList<T>(public val size: Int) {
return head
}
public override val hasNext: Boolean
override val hasNext: Boolean
get() = !cur.empty
}
class object {
class Empty<T>() : FunctionalList<T>(0) {
public override val head: T
override val head: T
get() = throw java.util.NoSuchElementException()
public override val tail: FunctionalList<T>
override val tail: FunctionalList<T>
get() = throw java.util.NoSuchElementException()
}
+6 -6
View File
@@ -201,7 +201,7 @@ fun Node.nextSiblings() : Iterator<Node> = NextSiblingIterator(this)
class NextSiblingIterator(var node: Node) : AbstractIterator<Node>() {
protected override fun computeNext(): Unit {
override fun computeNext(): Unit {
val next = node.getNextSibling()
if (next != null) {
setNext(next)
@@ -215,7 +215,7 @@ fun Node.previousSiblings() : Iterator<Node> = PreviousSiblingIterator(this)
class PreviousSiblingIterator(var node: Node) : AbstractIterator<Node>() {
protected override fun computeNext(): Unit {
override fun computeNext(): Unit {
val next = node.getPreviousSibling()
if (next != null) {
setNext(next)
@@ -323,7 +323,7 @@ fun NodeList?.toXmlString(xmlDeclaration: Boolean = false): String {
}
class NodeListAsList(val nodeList: NodeList): AbstractList<Node>() {
public override fun get(index: Int): Node {
override fun get(index: Int): Node {
val node = nodeList.item(index)
if (node == null) {
throw IndexOutOfBoundsException("NodeList does not contain a node at index: " + index)
@@ -332,11 +332,11 @@ class NodeListAsList(val nodeList: NodeList): AbstractList<Node>() {
}
}
public override fun size(): Int = nodeList.getLength()
override fun size(): Int = nodeList.getLength()
}
class ElementListAsList(val nodeList: NodeList): AbstractList<Element>() {
public override fun get(index: Int): Element {
override fun get(index: Int): Element {
val node = nodeList.item(index)
if (node is Element) {
return node
@@ -349,7 +349,7 @@ class ElementListAsList(val nodeList: NodeList): AbstractList<Element>() {
}
}
public override fun size(): Int = nodeList.getLength()
override fun size(): Int = nodeList.getLength()
}
+2 -2
View File
@@ -172,7 +172,7 @@ public inline fun <T: Closeable, R> T.use(block: (T)-> R) : R {
/** Returns an [Iterator] of bytes over an input stream */
public fun InputStream.iterator() : ByteIterator =
object: ByteIterator() {
public override val hasNext : Boolean
override val hasNext : Boolean
get() = available() > 0
public override fun nextByte() : Byte = read().toByte()
@@ -238,7 +238,7 @@ class LineIterator(val reader: BufferedReader) : Iterator<String> {
private var nextValue: String? = null
private var done = false
public override val hasNext: Boolean
override val hasNext: Boolean
get() {
if (nextValue == null && !done) {
nextValue = reader.readLine()
@@ -17,7 +17,7 @@ public abstract class AbstractIterator<T>: java.util.Iterator<T> {
private var state: State = State.NotReady
private var next: T? = null
public override fun hasNext(): Boolean {
override fun hasNext(): Boolean {
require(state != State.Failed)
return when (state) {
State.Done -> false
@@ -26,13 +26,13 @@ public abstract class AbstractIterator<T>: java.util.Iterator<T> {
}
}
public override fun next(): T {
override fun next(): T {
if (!hasNext()) throw NoSuchElementException()
state = State.NotReady
return next.sure()
}
public override fun remove() {
override fun remove() {
throw UnsupportedOperationException()
}
+1 -1
View File
@@ -389,7 +389,7 @@ class CollectionTest {
class IterableWrapper<T>(collection : java.lang.Iterable<T>) : java.lang.Iterable<T> {
private val collection = collection
public override fun iterator(): java.util.Iterator<T> {
override fun iterator(): java.util.Iterator<T> {
return collection.iterator().sure()
}
}
+2 -2
View File
@@ -43,10 +43,10 @@ class CompareTest {
Test fun sortUsingCustomComparator() {
val c = object : Comparator<Item>{
public override fun compare(o1: Item?, o2: Item?): Int {
override fun compare(o1: Item?, o2: Item?): Int {
return compareBy(o1, o2, {(it: Item) -> it.name}, {(it: Item) -> it.rating})
}
public override fun equals(obj: Any?): Boolean {
override fun equals(obj: Any?): Boolean {
return this == obj
}
}
+4 -4
View File
@@ -17,13 +17,13 @@ class TestBuilt<T>(name: String, val builder: TestBuilder<T>, val test: TestBuil
get() = myState.sure()
set(newState: T) { myState = newState }
public override fun countTestCases(): Int = 1
override fun countTestCases(): Int = 1
protected override fun setUp() = this.(builder.setUp)()
override fun setUp() = this.(builder.setUp)()
protected override fun tearDown() = this.(builder.tearDown)()
override fun tearDown() = this.(builder.tearDown)()
protected override fun runTest() = this.(test)()
override fun runTest() = this.(test)()
}
open class TestBuilder<T>(name: String) {
@@ -10,7 +10,7 @@ import junit.framework.TestCase
import junit.framework.Assert
class Serial(val a : String) : java.lang.Object(), Serializable {
public override fun toString() = a
override fun toString() = a
}
class SerialTest() : TestCase() {
@@ -28,7 +28,7 @@ class Customer() : ChangeSupport() {
class MyChangeListener() : ChangeListener {
val events = ArrayList<ChangeEvent>()
public override fun onPropertyChange(event: ChangeEvent): Unit {
override fun onPropertyChange(event: ChangeEvent): Unit {
println("Property changed: $event")
events.add(event)
}