From 6aad3b266227ffc64b1a5300df7dcb03133d4a36 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 20 Dec 2011 22:56:13 +0400 Subject: [PATCH] GreatSyntacticShift: Codegen testdata fixed --- compiler/testData/codegen/PSVM.jet | 2 +- .../codegen/classes/closureWithParameter.jet | 4 ++-- .../classes/closureWithParameterAndBoxing.jet | 4 ++-- .../classes/doubleEnclosedLocalVariable.jet | 2 +- .../classes/enclosingLocalVariable.jet | 2 +- .../codegen/classes/enclosingThis.jet | 6 ++--- .../codegen/classes/extensionClosure.jet | 4 ++-- .../codegen/classes/simplestClosure.jet | 2 +- .../classes/simplestClosureAndBoxing.jet | 2 +- .../codegen/controlStructures/sync.jet | 2 +- .../codegen/extensionFunctions/generic.jet | 4 ++-- .../codegen/extensionFunctions/shared.kt | 2 +- .../codegen/extensionFunctions/virtual.jet | 2 +- .../codegen/extensionFunctions/whenFail.jet | 4 ++-- .../codegen/functions/defaultargs.jet | 4 ++-- .../codegen/functions/functionExpression.jet | 16 +++++++------- .../codegen/functions/nothisnoclosure.jet | 2 +- .../codegen/functions/withtypeparams.jet | 2 +- .../codegen/namespaceQualifiedMethod.jet | 2 +- .../codegen/patternMatching/constant.jet | 4 ++-- .../patternMatching/exceptionOnNoMatch.jet | 2 +- .../testData/codegen/patternMatching/is.jet | 4 ++-- .../codegen/patternMatching/pattern.jet | 4 ++-- .../codegen/patternMatching/range.jet | 8 +++---- .../codegen/patternMatching/rangeChar.jet | 4 ++-- .../testData/codegen/regressions/kt237.jet | 16 +++++++------- .../testData/codegen/regressions/kt249.jet | 2 +- .../testData/codegen/regressions/kt326.jet | 2 +- .../testData/codegen/regressions/kt343.jet | 4 ++-- .../testData/codegen/regressions/kt344.jet | 18 +++++++-------- .../testData/codegen/regressions/kt395.jet | 4 ++-- .../testData/codegen/regressions/kt508.jet | 2 +- .../testData/codegen/regressions/kt511.jet | 2 +- .../testData/codegen/regressions/kt528.kt | 10 ++++----- .../testData/codegen/regressions/kt529.kt | 8 +++---- .../testData/codegen/regressions/kt533.kt | 8 +++---- .../testData/codegen/regressions/kt560.jet | 2 +- .../testData/codegen/regressions/kt581.jet | 2 +- .../testData/codegen/regressions/kt594.jet | 2 +- .../testData/codegen/regressions/kt613.jet | 2 +- .../testData/codegen/regressions/kt640.jet | 2 +- .../testData/codegen/regressions/kt684.jet | 8 +++---- .../testData/codegen/regressions/kt694.jet | 2 +- .../testData/codegen/regressions/kt707.jet | 2 +- .../testData/codegen/regressions/kt752.jet | 2 +- .../testData/codegen/regressions/kt753.jet | 2 +- .../testData/codegen/regressions/kt756.jet | 2 +- .../testData/codegen/regressions/kt757.jet | 2 +- .../testData/codegen/regressions/kt769.jet | 6 ++--- .../testData/codegen/regressions/kt772.jet | 6 ++--- .../testData/codegen/regressions/kt773.jet | 6 ++--- .../testData/codegen/regressions/kt785.jet | 2 +- .../testData/codegen/regressions/kt789.jet | 2 +- .../testData/codegen/regressions/kt828.kt | 2 +- compiler/testData/codegen/traits/stdlib.jet | 2 +- .../diagnostics/checkerTestUtil/test.jet | 2 +- .../jet/codegen/NamespaceGenTest.java | 4 ++-- .../jet/codegen/PatternMatchingTest.java | 10 ++++----- stdlib/ktSrc/Arrays.kt | 2 +- stdlib/ktSrc/Filter.kt | 12 +++++----- stdlib/ktSrc/Iterators.kt | 2 +- stdlib/ktSrc/JavaIo.kt | 4 ++-- stdlib/ktSrc/JavaUtil.kt | 22 +++++++++---------- stdlib/ktSrc/ModuleBuilder.kt | 6 ++--- stdlib/ktSrc/String.kt | 2 +- stdlib/ktSrc/System.kt | 6 ++--- stdlib/ktSrc/Thread.kt | 4 ++-- 67 files changed, 151 insertions(+), 151 deletions(-) diff --git a/compiler/testData/codegen/PSVM.jet b/compiler/testData/codegen/PSVM.jet index dcef3d78bf1..a53f9b5a26f 100644 --- a/compiler/testData/codegen/PSVM.jet +++ b/compiler/testData/codegen/PSVM.jet @@ -1,4 +1,4 @@ -namespace foo; +package foo; fun main(args : Array) { diff --git a/compiler/testData/codegen/classes/closureWithParameter.jet b/compiler/testData/codegen/classes/closureWithParameter.jet index 0c556d628c1..e0b5d616951 100644 --- a/compiler/testData/codegen/classes/closureWithParameter.jet +++ b/compiler/testData/codegen/classes/closureWithParameter.jet @@ -1,7 +1,7 @@ fun box() : String { - return apply( "OK", {(arg: String) => arg } ) + return apply( "OK", {(arg: String) -> arg } ) } -fun apply(arg : String, f : fun (p:String) : String) : String { +fun apply(arg : String, f : (p:String) -> String) : String { return f(arg) } diff --git a/compiler/testData/codegen/classes/closureWithParameterAndBoxing.jet b/compiler/testData/codegen/classes/closureWithParameterAndBoxing.jet index 6d0a4ffa658..2b64a547d29 100644 --- a/compiler/testData/codegen/classes/closureWithParameterAndBoxing.jet +++ b/compiler/testData/codegen/classes/closureWithParameterAndBoxing.jet @@ -1,7 +1,7 @@ fun box() : String { - return if (apply( 5, {(arg: Int) => arg + 13 } ) == 18) "OK" else "fail" + return if (apply( 5, {(arg: Int) -> arg + 13 } ) == 18) "OK" else "fail" } -fun apply(arg : Int, f : fun (p:Int) : Int) : Int { +fun apply(arg : Int, f : (p:Int) -> Int) : Int { return f(arg) } diff --git a/compiler/testData/codegen/classes/doubleEnclosedLocalVariable.jet b/compiler/testData/codegen/classes/doubleEnclosedLocalVariable.jet index d8e5ea789f2..96ac7f2ef19 100644 --- a/compiler/testData/codegen/classes/doubleEnclosedLocalVariable.jet +++ b/compiler/testData/codegen/classes/doubleEnclosedLocalVariable.jet @@ -3,6 +3,6 @@ fun box() : String { return if (sum(200, { val ff = {cl}; ff() }) == 239) "OK" else "FAIL" } -fun sum(arg:Int, f : fun () : Int) : Int { +fun sum(arg:Int, f : () -> Int) : Int { return arg + f() } diff --git a/compiler/testData/codegen/classes/enclosingLocalVariable.jet b/compiler/testData/codegen/classes/enclosingLocalVariable.jet index d2dbe243469..01e1a103ff2 100644 --- a/compiler/testData/codegen/classes/enclosingLocalVariable.jet +++ b/compiler/testData/codegen/classes/enclosingLocalVariable.jet @@ -3,6 +3,6 @@ fun box() : String { return if (sum(200, { val m = { val r = { cl }; r() }; m() }) == 239) "OK" else "FAIL" } -fun sum(arg:Int, f : fun () : Int) : Int { +fun sum(arg:Int, f : () -> Int) : Int { return arg + f() } diff --git a/compiler/testData/codegen/classes/enclosingThis.jet b/compiler/testData/codegen/classes/enclosingThis.jet index 93ae48c580f..d227b3a2cc9 100644 --- a/compiler/testData/codegen/classes/enclosingThis.jet +++ b/compiler/testData/codegen/classes/enclosingThis.jet @@ -1,10 +1,10 @@ class Point(val x:Int, val y:Int) { - fun mul() : fun (scalar:Int):Point { - return { (scalar:Int):Point => Point(x * scalar, y * scalar) } + fun mul() : (scalar:Int)->Point { + return { (scalar:Int):Point -> Point(x * scalar, y * scalar) } } } -val m = Point(2, 3).mul() : fun (scalar:Int):Point +val m = Point(2, 3).mul() : (scalar:Int)->Point fun box() : String { val answer = m(5) diff --git a/compiler/testData/codegen/classes/extensionClosure.jet b/compiler/testData/codegen/classes/extensionClosure.jet index 11fd11b3816..21307ea42ab 100644 --- a/compiler/testData/codegen/classes/extensionClosure.jet +++ b/compiler/testData/codegen/classes/extensionClosure.jet @@ -1,13 +1,13 @@ class Point(val x : Int, val y : Int) fun box() : String { - val answer = apply(Point(3, 5), { Point.(scalar : Int) : Point => + val answer = apply(Point(3, 5), { Point.(scalar : Int) : Point -> Point(x * scalar, y * scalar) }) return if (answer.x == 6 && answer.y == 10) "OK" else "FAIL" } -fun apply(arg:Point, f : fun Point.(scalar : Int) : Point) : Point { +fun apply(arg:Point, f : Point.(scalar : Int) -> Point) : Point { return arg.f(2) } diff --git a/compiler/testData/codegen/classes/simplestClosure.jet b/compiler/testData/codegen/classes/simplestClosure.jet index c851416e4f1..7a9f3b439cf 100644 --- a/compiler/testData/codegen/classes/simplestClosure.jet +++ b/compiler/testData/codegen/classes/simplestClosure.jet @@ -2,6 +2,6 @@ fun box() : String { return invoker( {"OK"} ) } -fun invoker(gen : fun () : String) : String { +fun invoker(gen : () -> String) : String { return gen() } diff --git a/compiler/testData/codegen/classes/simplestClosureAndBoxing.jet b/compiler/testData/codegen/classes/simplestClosureAndBoxing.jet index 8e3bedb2f37..50f22fbeb8d 100644 --- a/compiler/testData/codegen/classes/simplestClosureAndBoxing.jet +++ b/compiler/testData/codegen/classes/simplestClosureAndBoxing.jet @@ -2,6 +2,6 @@ fun box() : String { return if (int_invoker( { 7 } ) == 7) "OK" else "fail" } -fun int_invoker(gen : fun () : Int) : Int { +fun int_invoker(gen : () -> Int) : Int { return gen() } diff --git a/compiler/testData/codegen/controlStructures/sync.jet b/compiler/testData/codegen/controlStructures/sync.jet index 408db40ca36..6af5e9af150 100644 --- a/compiler/testData/codegen/controlStructures/sync.jet +++ b/compiler/testData/codegen/controlStructures/sync.jet @@ -1,7 +1,7 @@ import java.util.concurrent.* import java.util.concurrent.atomic.* -fun thread(block: fun():Unit ) { +fun thread(block: ()->Unit ) { val thread = object: Thread() { override fun run() { block() diff --git a/compiler/testData/codegen/extensionFunctions/generic.jet b/compiler/testData/codegen/extensionFunctions/generic.jet index fdc73cc4e0e..5b27d7fb271 100644 --- a/compiler/testData/codegen/extensionFunctions/generic.jet +++ b/compiler/testData/codegen/extensionFunctions/generic.jet @@ -1,6 +1,6 @@ import java.util.* -fun ArrayList.findAll(predicate: fun (T) : Boolean): ArrayList { +fun ArrayList.findAll(predicate: (T) -> Boolean): ArrayList { val result = ArrayList() for(val t in this) { if (predicate(t)) result.add(t) @@ -16,6 +16,6 @@ fun box(): String { list.add("Moscow") list.add("Munich") - val m: ArrayList = list.findAll({(name: String) => name.startsWith("M")}) + val m: ArrayList = list.findAll({(name: String) -> name.startsWith("M")}) return if (m.size() == 2) "OK" else "fail" } diff --git a/compiler/testData/codegen/extensionFunctions/shared.kt b/compiler/testData/codegen/extensionFunctions/shared.kt index 216ba549ba3..977376ca391 100644 --- a/compiler/testData/codegen/extensionFunctions/shared.kt +++ b/compiler/testData/codegen/extensionFunctions/shared.kt @@ -2,7 +2,7 @@ fun T.mustBe(t : T) { assert("$this must be $t") {this == t} } -inline fun assert(message : String, condition : fun() : Boolean) { +inline fun assert(message : String, condition : () -> Boolean) { if (!condition()) throw AssertionError(message) } diff --git a/compiler/testData/codegen/extensionFunctions/virtual.jet b/compiler/testData/codegen/extensionFunctions/virtual.jet index 18a774867ac..cc8a6a72f1a 100644 --- a/compiler/testData/codegen/extensionFunctions/virtual.jet +++ b/compiler/testData/codegen/extensionFunctions/virtual.jet @@ -3,7 +3,7 @@ class Request(val path: String) { } class Handler() { - fun Int.times(op: fun(): Unit) { + fun Int.times(op: ()-> Unit) { for(i in 0..this) op() } diff --git a/compiler/testData/codegen/extensionFunctions/whenFail.jet b/compiler/testData/codegen/extensionFunctions/whenFail.jet index 94f1e1492e4..bc38886f110 100644 --- a/compiler/testData/codegen/extensionFunctions/whenFail.jet +++ b/compiler/testData/codegen/extensionFunctions/whenFail.jet @@ -8,7 +8,7 @@ fun StringBuilder.takeFirst(): Char { fun foo(expr: StringBuilder): Int { val c = expr.takeFirst() when(c) { - 0.chr => throw Exception("zero") - else => throw Exception("nonzero" + c) + 0.chr -> throw Exception("zero") + else -> throw Exception("nonzero" + c) } } diff --git a/compiler/testData/codegen/functions/defaultargs.jet b/compiler/testData/codegen/functions/defaultargs.jet index 137e1b3be9e..4278ca81773 100644 --- a/compiler/testData/codegen/functions/defaultargs.jet +++ b/compiler/testData/codegen/functions/defaultargs.jet @@ -5,7 +5,7 @@ fun reformat( divideByCamelHumps : Boolean = true, wordSeparator : String = " " ) = - (normalizeCase, uppercaseFirstLetter, divideByCamelHumps, wordSeparator) + #(normalizeCase, uppercaseFirstLetter, divideByCamelHumps, wordSeparator) trait A { fun bar2(arg: Int = 239) : Int @@ -38,7 +38,7 @@ class C() : B() { fun T.toPrefixedString(prefix: String = "", suffix: String="") = prefix + (this as java.lang.Object).toString() + suffix fun box() : String { - val expected = (true, true, true, " ") + val expected = #(true, true, true, " ") if("mama".toPrefixedString(suffix="321", prefix="papa") != "papamama321") return "fail" if("mama".toPrefixedString(prefix="papa") != "papamama") return "fail" diff --git a/compiler/testData/codegen/functions/functionExpression.jet b/compiler/testData/codegen/functions/functionExpression.jet index 6e9611f2441..aaeadaf0c56 100644 --- a/compiler/testData/codegen/functions/functionExpression.jet +++ b/compiler/testData/codegen/functions/functionExpression.jet @@ -1,24 +1,24 @@ -fun Any.foo1() : fun(): String { +fun Any.foo1() : ()-> String { return { "239" + this } } -fun Int.foo2() : fun(i : Int) : Int { - return { x => x + this } +fun Int.foo2() : (i : Int) -> Int { + return { x -> x + this } } fun fooT1(t : T) = { t.toString() } -fun fooT2(t: T) = { (x:T) => t.toString() + x.toString() } +fun fooT2(t: T) = { (x:T) -> t.toString() + x.toString() } fun box() : String { if( (10.foo1())() != "23910") return "foo1 fail" if( (10.foo2())(1) != 11 ) return "foo2 fail" - if(1.{Int.() => this + 1}() != 2) return "test 3 failed"; + if(1.{Int.() -> this + 1}() != 2) return "test 3 failed"; if( {1}() != 1) return "test 4 failed"; - if( {(x : Int) => x}(1) != 1) return "test 5 failed"; - if( 1.{Int.(x : Int) => x + this}(1) != 2) return "test 6 failed"; - if( 1.({Int.() => this})() != 1) return "test 7 failed"; + if( {(x : Int) -> x}(1) != 1) return "test 5 failed"; + if( 1.{Int.(x : Int) -> x + this}(1) != 2) return "test 6 failed"; + if( 1.({Int.() -> this})() != 1) return "test 7 failed"; if( (fooT1("mama"))() != "mama") return "test 8 failed"; if( (fooT2("mama"))("papa") != "mamapapa") return "test 9 failed"; return "OK" diff --git a/compiler/testData/codegen/functions/nothisnoclosure.jet b/compiler/testData/codegen/functions/nothisnoclosure.jet index a53afefb72e..3c7b59679f2 100644 --- a/compiler/testData/codegen/functions/nothisnoclosure.jet +++ b/compiler/testData/codegen/functions/nothisnoclosure.jet @@ -1,6 +1,6 @@ fun loop(var times : Int) { while(times > 0) { - val u : fun(value : Int) : Unit = { + val u : (value : Int) -> Unit = { System.out?.println(it) } u(times--) diff --git a/compiler/testData/codegen/functions/withtypeparams.jet b/compiler/testData/codegen/functions/withtypeparams.jet index 291ebe1c04b..b88aad83cfb 100644 --- a/compiler/testData/codegen/functions/withtypeparams.jet +++ b/compiler/testData/codegen/functions/withtypeparams.jet @@ -1,5 +1,5 @@ class X () { - fun getTypeChecker() = { (a : Any) => a is T } + fun getTypeChecker() = { (a : Any) -> a is T } } fun box() : String { diff --git a/compiler/testData/codegen/namespaceQualifiedMethod.jet b/compiler/testData/codegen/namespaceQualifiedMethod.jet index b532836e3e2..0a8dd2c6f87 100644 --- a/compiler/testData/codegen/namespaceQualifiedMethod.jet +++ b/compiler/testData/codegen/namespaceQualifiedMethod.jet @@ -1,4 +1,4 @@ -namespace Foo { +package Foo { fun bar() = 610 } diff --git a/compiler/testData/codegen/patternMatching/constant.jet b/compiler/testData/codegen/patternMatching/constant.jet index a6af8ca9236..e74aa2568a2 100644 --- a/compiler/testData/codegen/patternMatching/constant.jet +++ b/compiler/testData/codegen/patternMatching/constant.jet @@ -1,4 +1,4 @@ fun isZero(x: Int) = when(x) { - 0 => true - else => false + 0 -> true + else -> false } diff --git a/compiler/testData/codegen/patternMatching/exceptionOnNoMatch.jet b/compiler/testData/codegen/patternMatching/exceptionOnNoMatch.jet index b8d62ebe77e..f5e668b9faf 100644 --- a/compiler/testData/codegen/patternMatching/exceptionOnNoMatch.jet +++ b/compiler/testData/codegen/patternMatching/exceptionOnNoMatch.jet @@ -1,3 +1,3 @@ fun isZero(x: Int) = when(x) { - 0 => true + 0 -> true } diff --git a/compiler/testData/codegen/patternMatching/is.jet b/compiler/testData/codegen/patternMatching/is.jet index 9fac50c586b..4c8a88fce5c 100644 --- a/compiler/testData/codegen/patternMatching/is.jet +++ b/compiler/testData/codegen/patternMatching/is.jet @@ -1,7 +1,7 @@ fun typeName(a: Any?) : String { return when(a) { - is java.util.ArrayList<*> => "array list" - else => "no idea" + is java.util.ArrayList<*> -> "array list" + else -> "no idea" } } diff --git a/compiler/testData/codegen/patternMatching/pattern.jet b/compiler/testData/codegen/patternMatching/pattern.jet index 25f8167886a..e87965a0fc8 100644 --- a/compiler/testData/codegen/patternMatching/pattern.jet +++ b/compiler/testData/codegen/patternMatching/pattern.jet @@ -1,4 +1,4 @@ fun isString(x: Any) = when(x) { - is String => "string" - else => "something" + is String -> "string" + else -> "something" } diff --git a/compiler/testData/codegen/patternMatching/range.jet b/compiler/testData/codegen/patternMatching/range.jet index 5010f350b68..f1200c681e0 100644 --- a/compiler/testData/codegen/patternMatching/range.jet +++ b/compiler/testData/codegen/patternMatching/range.jet @@ -3,9 +3,9 @@ fun isDigit(a: Int) : String { aa.add(239) return when(a) { - in aa => "array list" - in 0..9 => "digit" - !in 0..100 => "not small" - else => "something" + in aa -> "array list" + in 0..9 -> "digit" + !in 0..100 -> "not small" + else -> "something" } } diff --git a/compiler/testData/codegen/patternMatching/rangeChar.jet b/compiler/testData/codegen/patternMatching/rangeChar.jet index 744855a20eb..7ab6b77512f 100644 --- a/compiler/testData/codegen/patternMatching/rangeChar.jet +++ b/compiler/testData/codegen/patternMatching/rangeChar.jet @@ -1,4 +1,4 @@ fun isDigit(a: Char) = when(a) { - in '0'..'9' => "digit" - else => "something" + in '0'..'9' -> "digit" + else -> "something" } diff --git a/compiler/testData/codegen/regressions/kt237.jet b/compiler/testData/codegen/regressions/kt237.jet index aaa60b5904f..c82ae4277a9 100644 --- a/compiler/testData/codegen/regressions/kt237.jet +++ b/compiler/testData/codegen/regressions/kt237.jet @@ -1,11 +1,11 @@ fun main(args: Array?) { - val y: Unit = () //do not compile + val y: Unit = #() //do not compile A() //do not compile - C(()) //do not compile + C(#()) //do not compile //do not compile - System.out?.println(fff(())) //do not compile + System.out?.println(fff(#())) //do not compile System.out?.println(id(y)) //do not compile - System.out?.println(fff(id(y)) == id(foreach(Array(0,{0}),{(e : Int) : Unit => }))) //do not compile + System.out?.println(fff(id(y)) == id(foreach(Array(0,{0}),{(e : Int) : Unit -> }))) //do not compile } class A() @@ -17,13 +17,13 @@ fun fff(x: T) : T { return x } fun id(value: T): T = value -fun foreach(array: Array?, action: fun(Int): Unit) { +fun foreach(array: Array?, action: (Int)-> Unit) { for (el in array) { action(el) //exception through compilation (see below) } } -fun almostFilter(array: Array, action: fun(Int): Int) { +fun almostFilter(array: Array, action: (Int)-> Int) { for (el in array) { action(el) } @@ -34,8 +34,8 @@ fun box() : String { a[0] = 0 a[1] = 1 a[2] = 2 - foreach(a, { (el : Int) : Unit => System.out?.println(el) }) - almostFilter(a, { (el : Int) : Int => el }) + foreach(a, { (el : Int) : Unit -> System.out?.println(el) }) + almostFilter(a, { (el : Int) : Int -> el }) main(null) return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/regressions/kt249.jet b/compiler/testData/codegen/regressions/kt249.jet index bf15ae39c99..e4906c74b27 100644 --- a/compiler/testData/codegen/regressions/kt249.jet +++ b/compiler/testData/codegen/regressions/kt249.jet @@ -1,4 +1,4 @@ -namespace x +package x class Outer() { class object { diff --git a/compiler/testData/codegen/regressions/kt326.jet b/compiler/testData/codegen/regressions/kt326.jet index 3d9b4ad8e54..09ab793d03c 100644 --- a/compiler/testData/codegen/regressions/kt326.jet +++ b/compiler/testData/codegen/regressions/kt326.jet @@ -1,4 +1,4 @@ -namespace test +package test class List(len: Int) { val a : Array = Array(len) diff --git a/compiler/testData/codegen/regressions/kt343.jet b/compiler/testData/codegen/regressions/kt343.jet index 49a8dc9c487..1820bbe0ffb 100644 --- a/compiler/testData/codegen/regressions/kt343.jet +++ b/compiler/testData/codegen/regressions/kt343.jet @@ -1,12 +1,12 @@ import java.util.ArrayList -fun launch(f : fun() : Unit) { +fun launch(f : () -> Unit) { f() } fun box(): String { val list = ArrayList() - val foo : fun() : Unit = { + val foo : () -> Unit = { list.add(2) //first exception } foo() diff --git a/compiler/testData/codegen/regressions/kt344.jet b/compiler/testData/codegen/regressions/kt344.jet index 39a8f550b74..c48a17af8e2 100644 --- a/compiler/testData/codegen/regressions/kt344.jet +++ b/compiler/testData/codegen/regressions/kt344.jet @@ -27,7 +27,7 @@ fun t1() : Boolean { x = x + "45" + y x = x.substring(3) x += "aaa" - () + #() } foo() @@ -43,7 +43,7 @@ fun t2() : Boolean { x = x + 5 + y x += 5 x++ - () + #() } foo() x -= 55 @@ -55,7 +55,7 @@ fun t3() : Boolean { var x = true val foo = { x = false - () + #() } foo() return !x @@ -67,7 +67,7 @@ fun t4() : Boolean { val foo = { x = x + 200.flt + y x += 18 - () + #() } foo() System.out?.println(x) @@ -80,7 +80,7 @@ fun t5() : Boolean { val foo = { x = x + 200.dbl + y x -= 22 - () + #() } foo() System.out?.println(x) @@ -94,7 +94,7 @@ fun t6() : Boolean { x = (x + 20.byt + y).byt x += 2 x-- - () + #() } foo() System.out?.println(x) @@ -105,7 +105,7 @@ fun t7() : Boolean { var x : Char = 'a' val foo = { x = 'b' - () + #() } foo() System.out?.println(x) @@ -117,10 +117,10 @@ fun t8() : Boolean { val foo = { val bar = { x = 30.sht - () + #() } bar() - () + #() } foo() return x == 30.sht diff --git a/compiler/testData/codegen/regressions/kt395.jet b/compiler/testData/codegen/regressions/kt395.jet index 1febc10ffc5..11f1deb9334 100644 --- a/compiler/testData/codegen/regressions/kt395.jet +++ b/compiler/testData/codegen/regressions/kt395.jet @@ -1,6 +1,6 @@ -fun Any.with(operation : fun Any.() : Any) = operation().toString() +fun Any.with(operation : Any.() -> Any) = operation().toString() -val f = { (a : Int) :Unit => } +val f = { (a : Int) :Unit -> } fun box () : String { return if(20.with { diff --git a/compiler/testData/codegen/regressions/kt508.jet b/compiler/testData/codegen/regressions/kt508.jet index 088bd1fd6bd..134aa72670b 100644 --- a/compiler/testData/codegen/regressions/kt508.jet +++ b/compiler/testData/codegen/regressions/kt508.jet @@ -1,4 +1,4 @@ -namespace mult_constructors_3_bug +package mult_constructors_3_bug public open class Identifier() { private var myNullable : Boolean = true diff --git a/compiler/testData/codegen/regressions/kt511.jet b/compiler/testData/codegen/regressions/kt511.jet index a9bc915346c..0fe6d87cc32 100644 --- a/compiler/testData/codegen/regressions/kt511.jet +++ b/compiler/testData/codegen/regressions/kt511.jet @@ -1,4 +1,4 @@ -namespace one_extends_base +package one_extends_base open class Base(name : T?) { var myName : T? diff --git a/compiler/testData/codegen/regressions/kt528.kt b/compiler/testData/codegen/regressions/kt528.kt index 8cfe1707aee..d656fb2f6f7 100644 --- a/compiler/testData/codegen/regressions/kt528.kt +++ b/compiler/testData/codegen/regressions/kt528.kt @@ -1,4 +1,4 @@ -namespace mask +package mask import std.io.* import java.io.* @@ -52,7 +52,7 @@ class Luhny() { fun check() { if (digits.size() < 14) return print("check") - val sum = digits.sum { i, d => + val sum = digits.sum { i, d -> // println("$i -> $d") if (i % 2 == digits.size()) { val f = d * 2 / 10 @@ -94,12 +94,12 @@ class Luhny() { } } -fun T.pr(f : fun(T) : Unit) : T { +fun T.pr(f : (T) -> Unit) : T { f(this) return this } -fun LinkedList.sum(f : fun(Int, Int ): Int): Int { +fun LinkedList.sum(f : (Int, Int )-> Int): Int { var sum = 0 for (i in 1..size()) { val j = size() - i @@ -120,7 +120,7 @@ fun LinkedList.sum(f : fun(Int, Int ): Int): Int { fun Char.isDigit() = Character.isDigit(this) -fun Reader.forEachChar(body : fun(Char) : Unit) { +fun Reader.forEachChar(body : (Char) -> Unit) { do { var i = read(); if (i == -1) break diff --git a/compiler/testData/codegen/regressions/kt529.kt b/compiler/testData/codegen/regressions/kt529.kt index 84a6d3edc52..546a345b1c7 100644 --- a/compiler/testData/codegen/regressions/kt529.kt +++ b/compiler/testData/codegen/regressions/kt529.kt @@ -1,4 +1,4 @@ -namespace mask +package mask import std.io.* import java.io.* @@ -46,7 +46,7 @@ class Luhny() { private fun check() { val size = digits.size() if (size < 14) return - val sum = digits.sum {i, d => + val sum = digits.sum {i, d -> if (i % 2 == size % 2) double(d) else d } // var sum = 0 @@ -89,7 +89,7 @@ class Luhny() { fun Char.isDigit() = Character.isDigit(this) -fun java.lang.Iterable.sum(f : fun(index : Int, value : Int) : Int) : Int { +fun java.lang.Iterable.sum(f : (index : Int, value : Int) -> Int) : Int { var sum = 0 var i = 0 for (d in this) { @@ -99,7 +99,7 @@ fun java.lang.Iterable.sum(f : fun(index : Int, value : Int) : Int) : Int { return sum } -fun Reader.forEachChar(body : fun(Char) : Unit) { +fun Reader.forEachChar(body : (Char) -> Unit) { do { var i = read(); if (i == -1) break diff --git a/compiler/testData/codegen/regressions/kt533.kt b/compiler/testData/codegen/regressions/kt533.kt index 7e7ef961ffd..3ad813a6e0b 100644 --- a/compiler/testData/codegen/regressions/kt533.kt +++ b/compiler/testData/codegen/regressions/kt533.kt @@ -1,4 +1,4 @@ -namespace mask +package mask import std.io.* import java.io.* @@ -50,7 +50,7 @@ class Luhny() { fun check() { if (digits.size() < 14) return - val sum = digits.sum { i, d => + val sum = digits.sum { i, d -> if (i % 2 != 0) d * 2 / 10 + d * 2 % 10 else d @@ -85,7 +85,7 @@ class Luhny() { } } -fun LinkedList.sum(f : fun(Int, Int) : Int) : Int { +fun LinkedList.sum(f : (Int, Int) -> Int) : Int { var sum = 0 var i = 0 for (d in backwards()) { @@ -136,7 +136,7 @@ fun Char.isDigit() = Character.isDigit(this) // fun clear() {} //} -fun Reader.forEachChar(body : fun(Char) : Unit) { +fun Reader.forEachChar(body : (Char) -> Unit) { do { var i = read(); if (i == -1) break diff --git a/compiler/testData/codegen/regressions/kt560.jet b/compiler/testData/codegen/regressions/kt560.jet index 630cf37d654..cb3944e1f27 100644 --- a/compiler/testData/codegen/regressions/kt560.jet +++ b/compiler/testData/codegen/regressions/kt560.jet @@ -1,4 +1,4 @@ -namespace while_bug_1 +package while_bug_1 import java.io.* diff --git a/compiler/testData/codegen/regressions/kt581.jet b/compiler/testData/codegen/regressions/kt581.jet index 0f8d7162122..4480994e57e 100644 --- a/compiler/testData/codegen/regressions/kt581.jet +++ b/compiler/testData/codegen/regressions/kt581.jet @@ -1,4 +1,4 @@ -namespace whats.the.difference +package whats.the.difference import java.util.HashSet diff --git a/compiler/testData/codegen/regressions/kt594.jet b/compiler/testData/codegen/regressions/kt594.jet index 70d94715100..93c5580e600 100644 --- a/compiler/testData/codegen/regressions/kt594.jet +++ b/compiler/testData/codegen/regressions/kt594.jet @@ -1,4 +1,4 @@ -namespace array_test +package array_test fun box() : String { var array : IntArray? = IntArray(10) diff --git a/compiler/testData/codegen/regressions/kt613.jet b/compiler/testData/codegen/regressions/kt613.jet index 463b77aa909..b35b35959a4 100644 --- a/compiler/testData/codegen/regressions/kt613.jet +++ b/compiler/testData/codegen/regressions/kt613.jet @@ -1,4 +1,4 @@ -namespace name +package name class Test() { var i = 5 diff --git a/compiler/testData/codegen/regressions/kt640.jet b/compiler/testData/codegen/regressions/kt640.jet index 705fc1f338c..4171c7419c5 100644 --- a/compiler/testData/codegen/regressions/kt640.jet +++ b/compiler/testData/codegen/regressions/kt640.jet @@ -1,4 +1,4 @@ -namespace demo +package demo public open class Identifier(myName : T?, myHasDollar : Boolean) { { diff --git a/compiler/testData/codegen/regressions/kt684.jet b/compiler/testData/codegen/regressions/kt684.jet index 41048cec7c5..21fb4860c63 100644 --- a/compiler/testData/codegen/regressions/kt684.jet +++ b/compiler/testData/codegen/regressions/kt684.jet @@ -1,8 +1,8 @@ fun escapeChar(c : Char) : String? = when (c) { - '\\' => "\\\\" - '\n' => "\\n" - '"' => "\\\"" - else => String.valueOf(c) + '\\' -> "\\\\" + '\n' -> "\\n" + '"' -> "\\\"" + else -> String.valueOf(c) } fun String.escape(i : Int = 0, result : String = "") : String = diff --git a/compiler/testData/codegen/regressions/kt694.jet b/compiler/testData/codegen/regressions/kt694.jet index 698558d3642..f45c6815711 100644 --- a/compiler/testData/codegen/regressions/kt694.jet +++ b/compiler/testData/codegen/regressions/kt694.jet @@ -1,4 +1,4 @@ -namespace org2 +package org2 enum class Test { A diff --git a/compiler/testData/codegen/regressions/kt707.jet b/compiler/testData/codegen/regressions/kt707.jet index 47d245455aa..a12afa2b3cd 100644 --- a/compiler/testData/codegen/regressions/kt707.jet +++ b/compiler/testData/codegen/regressions/kt707.jet @@ -1,6 +1,6 @@ class List(val head: T, val tail: List? = null) -fun List.mapHead(f: fun(T): T): List = List(f(head), null) +fun List.mapHead(f: (T)-> T): List = List(f(head), null) fun box() : String { val a: Int = List(1).mapHead{it * 2}.head diff --git a/compiler/testData/codegen/regressions/kt752.jet b/compiler/testData/codegen/regressions/kt752.jet index 20132c9f6a8..2f6ab3d7d69 100644 --- a/compiler/testData/codegen/regressions/kt752.jet +++ b/compiler/testData/codegen/regressions/kt752.jet @@ -1,4 +1,4 @@ -namespace demo_range +package demo_range fun Int?.rangeTo(other : Int?) : IntRange = this.sure().rangeTo(other.sure()) diff --git a/compiler/testData/codegen/regressions/kt753.jet b/compiler/testData/codegen/regressions/kt753.jet index a1b81de8138..75a54b5ca33 100644 --- a/compiler/testData/codegen/regressions/kt753.jet +++ b/compiler/testData/codegen/regressions/kt753.jet @@ -1,4 +1,4 @@ -namespace bitwise_demo +package bitwise_demo fun Long?.shl(bits : Int?) : Long = this.sure().shl(bits.sure()) diff --git a/compiler/testData/codegen/regressions/kt756.jet b/compiler/testData/codegen/regressions/kt756.jet index 4cff1aecd11..e47c2612f1f 100644 --- a/compiler/testData/codegen/regressions/kt756.jet +++ b/compiler/testData/codegen/regressions/kt756.jet @@ -1,4 +1,4 @@ -namespace demo_range +package demo_range fun Int?.plus() : Int = this.sure().plus() fun Int?.dec() : Int = this.sure().dec() diff --git a/compiler/testData/codegen/regressions/kt757.jet b/compiler/testData/codegen/regressions/kt757.jet index 8ddfb3d879a..925391944fb 100644 --- a/compiler/testData/codegen/regressions/kt757.jet +++ b/compiler/testData/codegen/regressions/kt757.jet @@ -1,4 +1,4 @@ -namespace demo_long +package demo_long fun Long?.inv() : Long = this.sure().inv() diff --git a/compiler/testData/codegen/regressions/kt769.jet b/compiler/testData/codegen/regressions/kt769.jet index 266af79d867..0bfe012e7be 100644 --- a/compiler/testData/codegen/regressions/kt769.jet +++ b/compiler/testData/codegen/regressions/kt769.jet @@ -1,10 +1,10 @@ -namespace w_range +package w_range fun box() : String { var i = 0 when (i) { - 1 => i-- - else => { i = 2 } + 1 -> i-- + else -> { i = 2 } } System.out?.println(i) return "OK" diff --git a/compiler/testData/codegen/regressions/kt772.jet b/compiler/testData/codegen/regressions/kt772.jet index 6cad8d6ae03..bb45a0c94d1 100644 --- a/compiler/testData/codegen/regressions/kt772.jet +++ b/compiler/testData/codegen/regressions/kt772.jet @@ -1,18 +1,18 @@ -namespace demo2 +package demo2 fun print(o : Any?) {} fun test(i : Int) { var monthString : String? = "" when (i) { - 1 => { + 1 -> { print(1) print(2) print(3) print(4) print(5) } - else => { + else -> { monthString = "Invalid month" } } diff --git a/compiler/testData/codegen/regressions/kt773.jet b/compiler/testData/codegen/regressions/kt773.jet index 6cad8d6ae03..bb45a0c94d1 100644 --- a/compiler/testData/codegen/regressions/kt773.jet +++ b/compiler/testData/codegen/regressions/kt773.jet @@ -1,18 +1,18 @@ -namespace demo2 +package demo2 fun print(o : Any?) {} fun test(i : Int) { var monthString : String? = "" when (i) { - 1 => { + 1 -> { print(1) print(2) print(3) print(4) print(5) } - else => { + else -> { monthString = "Invalid month" } } diff --git a/compiler/testData/codegen/regressions/kt785.jet b/compiler/testData/codegen/regressions/kt785.jet index 1b10c8c73d7..add8bb72789 100644 --- a/compiler/testData/codegen/regressions/kt785.jet +++ b/compiler/testData/codegen/regressions/kt785.jet @@ -1,7 +1,7 @@ class A() { var x : Int = 0 - var z = { () => + var z = { () -> x++ } } diff --git a/compiler/testData/codegen/regressions/kt789.jet b/compiler/testData/codegen/regressions/kt789.jet index e071cfdf507..79014973767 100644 --- a/compiler/testData/codegen/regressions/kt789.jet +++ b/compiler/testData/codegen/regressions/kt789.jet @@ -1,4 +1,4 @@ -namespace foo +package foo import java.util.*; diff --git a/compiler/testData/codegen/regressions/kt828.kt b/compiler/testData/codegen/regressions/kt828.kt index 34801b54b8d..06e63bec23c 100644 --- a/compiler/testData/codegen/regressions/kt828.kt +++ b/compiler/testData/codegen/regressions/kt828.kt @@ -1,4 +1,4 @@ -namespace demo +package demo fun box() : String { var res : Boolean = true diff --git a/compiler/testData/codegen/traits/stdlib.jet b/compiler/testData/codegen/traits/stdlib.jet index af0db549b40..235263a95eb 100644 --- a/compiler/testData/codegen/traits/stdlib.jet +++ b/compiler/testData/codegen/traits/stdlib.jet @@ -36,7 +36,7 @@ trait WriteOnlyArray : ISized { } } -class MutableArray(length: Int, init : fun(Int) : T) : ReadOnlyArray, WriteOnlyArray { +class MutableArray(length: Int, init : (Int) -> T) : ReadOnlyArray, WriteOnlyArray { private val array = Array(length, init) override fun get(index : Int) : T = array[index] diff --git a/compiler/testData/diagnostics/checkerTestUtil/test.jet b/compiler/testData/diagnostics/checkerTestUtil/test.jet index e78606b8885..699dfbd5ce5 100644 --- a/compiler/testData/diagnostics/checkerTestUtil/test.jet +++ b/compiler/testData/diagnostics/checkerTestUtil/test.jet @@ -2,7 +2,7 @@ fun foo(u : Unit) : Int = 1 fun test() : Int { foo(1) - val a : fun() : Unit = { + val a : () -> Unit = { foo(1) } return 1 - "1" diff --git a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java index 295781b1837..968a5647f20 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java @@ -485,7 +485,7 @@ public class NamespaceGenTest extends CodegenTestCase { } public void testTupleLiteral() throws Exception { - loadText("fun foo() = (1, \"foo\")"); + loadText("fun foo() = #(1, \"foo\")"); // System.out.println(generateToText()); final Method main = generateFunction("foo"); Tuple2 tuple2 = (Tuple2) main.invoke(null); @@ -494,7 +494,7 @@ public class NamespaceGenTest extends CodegenTestCase { } public void testParametrizedTupleLiteral() throws Exception { - loadText("fun E.foo(extra: java.util.List) = (1, \"foo\", this, extra)"); + loadText("fun E.foo(extra: java.util.List) = #(1, \"foo\", this, extra)"); // System.out.println(generateToText()); final Method main = generateFunction(); Tuple4 tuple4 = (Tuple4) main.invoke(null, "aaa", TypeInfo.STRING_TYPE_INFO, TypeInfo.INT_TYPE_INFO, Arrays.asList(10)); diff --git a/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java b/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java index a3fd95c3ab3..3c47ffefd74 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java @@ -74,19 +74,19 @@ public class PatternMatchingTest extends CodegenTestCase { } public void testWildcardPattern() throws Exception { - loadText("fun foo(x: String) = when(x) { is * => \"something\" }"); + loadText("fun foo(x: String) = when(x) { is * -> \"something\" }"); Method foo = generateFunction(); assertEquals("something", foo.invoke(null, "")); } public void testNoReturnType() throws Exception { - loadText("fun foo(x: String) = when(x) { is * => \"x\" }"); + loadText("fun foo(x: String) = when(x) { is * -> \"x\" }"); Method foo = generateFunction(); assertEquals("x", foo.invoke(null, "")); } public void testTuplePattern() throws Exception { - loadText("fun foo(x: (Any, Any)) = when(x) { is (1,2) => \"one,two\"; else => \"something\" }"); + loadText("fun foo(x: (Any, Any)) = when(x) { is #(1,2) -> \"one,two\"; else -> \"something\" }"); Method foo = generateFunction(); final Object result; try { @@ -118,14 +118,14 @@ public class PatternMatchingTest extends CodegenTestCase { } public void testNames() throws Exception { - loadText("fun foo(x: (Any, Any)) = when(x) { is (val a is String, *) => a; else => \"something\" }"); + loadText("fun foo(x: #(Any, Any)) = when(x) { is #(val a is String, *) -> a; else -> \"something\" }"); Method foo = generateFunction(); assertEquals("JetBrains", foo.invoke(null, new Tuple2(null, "JetBrains", "s.r.o."))); assertEquals("something", foo.invoke(null, new Tuple2(null, 1, 2))); } public void testMultipleConditions() throws Exception { - loadText("fun foo(x: Any) = when(x) { is 0, 1 => \"bit\"; else => \"something\" }"); + loadText("fun foo(x: Any) = when(x) { is 0, 1 -> \"bit\"; else -> \"something\" }"); Method foo = generateFunction(); assertEquals("bit", foo.invoke(null, 0)); assertEquals("bit", foo.invoke(null, 1)); diff --git a/stdlib/ktSrc/Arrays.kt b/stdlib/ktSrc/Arrays.kt index 68f2234c716..48e1c8fc595 100644 --- a/stdlib/ktSrc/Arrays.kt +++ b/stdlib/ktSrc/Arrays.kt @@ -1,4 +1,4 @@ -namespace std +package std import java.io.ByteArrayInputStream diff --git a/stdlib/ktSrc/Filter.kt b/stdlib/ktSrc/Filter.kt index 1fa5cb45317..45439740e42 100644 --- a/stdlib/ktSrc/Filter.kt +++ b/stdlib/ktSrc/Filter.kt @@ -1,4 +1,4 @@ -namespace std +package std import java.util.* import java.lang.Iterable @@ -6,7 +6,7 @@ import java.lang.Iterable /* Filters given iterator */ -inline fun java.util.Iterator.filter(f: fun(T): Boolean) : java.util.Iterator = FilterIterator(this, f) +inline fun java.util.Iterator.filter(f: (T)-> Boolean) : java.util.Iterator = FilterIterator(this, f) /* Adds filtered elements in to given container @@ -28,15 +28,15 @@ Create iterator filtering given java.lang.Iterable inline fun java.lang.Iterable.filter(f: fun(T): Boolean) : java.util.Iterator = (iterator() as java.util.Iterator).filter(f) */ -private class FilterIterator(val original: java.util.Iterator, val filter: fun(T): Boolean) : java.util.Iterator { +private class FilterIterator(val original: java.util.Iterator, val filter: (T)-> Boolean) : java.util.Iterator { var state = 0 var nextElement: T? = null override fun hasNext(): Boolean = when(state) { - 1 => true // checked and next present - 2 => false // checked and next not present - else => { + 1 -> true // checked and next present + 2 -> false // checked and next not present + else -> { while(original.hasNext()) { val candidate = original.next() if((filter)(candidate)) { diff --git a/stdlib/ktSrc/Iterators.kt b/stdlib/ktSrc/Iterators.kt index 8a9b592ab26..7b3087e952e 100644 --- a/stdlib/ktSrc/Iterators.kt +++ b/stdlib/ktSrc/Iterators.kt @@ -1,4 +1,4 @@ -namespace std.util +package std.util import java.util.* import java.util.Iterator diff --git a/stdlib/ktSrc/JavaIo.kt b/stdlib/ktSrc/JavaIo.kt index 71ab785f556..a7777529f6a 100644 --- a/stdlib/ktSrc/JavaIo.kt +++ b/stdlib/ktSrc/JavaIo.kt @@ -1,6 +1,6 @@ -namespace std +package std -namespace io { +package io { import java.io.* import java.nio.charset.* diff --git a/stdlib/ktSrc/JavaUtil.kt b/stdlib/ktSrc/JavaUtil.kt index b71427a49e0..0c967f25554 100644 --- a/stdlib/ktSrc/JavaUtil.kt +++ b/stdlib/ktSrc/JavaUtil.kt @@ -1,4 +1,4 @@ -namespace std.util +package std.util import java.util.* @@ -20,7 +20,7 @@ inline fun linkedList(vararg values: T) : LinkedList = values.to(LinkedLi inline fun hashSet(vararg values: T) : HashSet = values.to(HashSet(values.size)) /** Returns true if any elements in the collection match the given predicate */ -inline fun java.lang.Iterable.any(predicate: fun(T): Boolean) : Boolean { +inline fun java.lang.Iterable.any(predicate: (T)-> Boolean) : Boolean { for (elem in this) { if (predicate(elem)) { return true @@ -30,7 +30,7 @@ inline fun java.lang.Iterable.any(predicate: fun(T): Boolean) : Boolean { } /** Returns true if all elements in the collection match the given predicate */ -inline fun java.lang.Iterable.all(predicate: fun(T): Boolean) : Boolean { +inline fun java.lang.Iterable.all(predicate: (T)-> Boolean) : Boolean { for (elem in this) { if (!predicate(elem)) { return false @@ -40,7 +40,7 @@ inline fun java.lang.Iterable.all(predicate: fun(T): Boolean) : Boolean { } /** Returns the first item in the collection which matches the given predicate or null if none matched */ -inline fun java.lang.Iterable.find(predicate: fun(T): Boolean) : T? { +inline fun java.lang.Iterable.find(predicate: (T)-> Boolean) : T? { for (elem in this) { if (predicate(elem)) return elem @@ -49,7 +49,7 @@ inline fun java.lang.Iterable.find(predicate: fun(T): Boolean) : T? { } /** Returns a new collection containing all elements in this collection which match the given predicate */ -inline fun java.lang.Iterable.filter(result: Collection = ArrayList(), predicate: fun(T): Boolean) : Collection { +inline fun java.lang.Iterable.filter(result: Collection = ArrayList(), predicate: (T)-> Boolean) : Collection { for (elem in this) { if (predicate(elem)) result.add(elem) @@ -61,7 +61,7 @@ inline fun java.lang.Iterable.filter(result: Collection = ArrayList * Returns the result of transforming each item in the collection to a one or more values which * are concatenated together into a single collection */ -inline fun java.lang.Iterable.flatMap(result: Collection = ArrayList(), transform: fun(T): Collection) : Collection { +inline fun java.lang.Iterable.flatMap(result: Collection = ArrayList(), transform: (T)-> Collection) : Collection { for (elem in this) { val coll = transform(elem) if (coll != null) { @@ -74,7 +74,7 @@ inline fun java.lang.Iterable.flatMap(result: Collection = Arra } /** Performs the given operation on each element inside the collection */ -inline fun java.lang.Iterable.foreach(operation: fun(element: T) : Unit) { +inline fun java.lang.Iterable.foreach(operation: (element: T) -> Unit) { for (elem in this) operation(elem) } @@ -95,14 +95,14 @@ inline fun java.lang.Iterable.join(separator: String, prefix: String = "" } /** Returns a new collection containing the results of applying the given function to each element in this collection */ -inline fun java.lang.Iterable.map(result: Collection = ArrayList(), transform : fun(T) : R) : Collection { +inline fun java.lang.Iterable.map(result: Collection = ArrayList(), transform : (T) -> R) : Collection { for (item in this) result.add(transform(item)) return result } /** Returns a new collection containing the results of applying the given function to each element in this collection */ -inline fun java.util.Collection.map(result: Collection = ArrayList(this.size), transform : fun(T) : R) : Collection { +inline fun java.util.Collection.map(result: Collection = ArrayList(this.size), transform : (T) -> R) : Collection { for (item in this) result.add(transform(item)) return result @@ -211,7 +211,7 @@ val Map<*,*>.empty : Boolean */ /** Returns the value for the given key or returns the result of the defaultValue function if there was no entry for the given key */ -inline fun java.util.Map.getOrElse(key: K, defaultValue: fun(): V) : V { +inline fun java.util.Map.getOrElse(key: K, defaultValue: ()-> V) : V { val current = this.get(key) if (current != null) { return current @@ -221,7 +221,7 @@ inline fun java.util.Map.getOrElse(key: K, defaultValue: fun(): V) : } /** Returns the value for the given key or the result of the defaultValue function is put into the map for the given value and returned */ -inline fun java.util.Map.getOrElseUpdate(key: K, defaultValue: fun(): V) : V { +inline fun java.util.Map.getOrElseUpdate(key: K, defaultValue: ()-> V) : V { val current = this.get(key) if (current != null) { return current diff --git a/stdlib/ktSrc/ModuleBuilder.kt b/stdlib/ktSrc/ModuleBuilder.kt index ca94ba92ea1..cf1ffcdd896 100644 --- a/stdlib/ktSrc/ModuleBuilder.kt +++ b/stdlib/ktSrc/ModuleBuilder.kt @@ -1,6 +1,6 @@ -namespace kotlin +package kotlin -namespace modules { +package modules { import java.util.* import jet.modules.* @@ -8,7 +8,7 @@ import jet.modules.* class ModuleSetBuilder(): IModuleSetBuilder { val modules: ArrayList = ArrayList() - fun module(name: String, callback: fun ModuleBuilder.()) { + fun module(name: String, callback: ModuleBuilder.() -> Unit) { val builder = ModuleBuilder(name) builder.callback() modules.add(builder) diff --git a/stdlib/ktSrc/String.kt b/stdlib/ktSrc/String.kt index 4df7c099d29..ad9ec3f66a9 100644 --- a/stdlib/ktSrc/String.kt +++ b/stdlib/ktSrc/String.kt @@ -1,4 +1,4 @@ -namespace std +package std import java.io.StringReader diff --git a/stdlib/ktSrc/System.kt b/stdlib/ktSrc/System.kt index 1b5545f0266..3d7b443991d 100644 --- a/stdlib/ktSrc/System.kt +++ b/stdlib/ktSrc/System.kt @@ -1,9 +1,9 @@ -namespace std.util +package std.util /** Executes current block and returns elapsed time in milliseconds */ -fun measureTimeMillis(block: fun() : Unit) : Long { +fun measureTimeMillis(block: () -> Unit) : Long { val start = System.currentTimeMillis() block() return System.currentTimeMillis() - start @@ -12,7 +12,7 @@ fun measureTimeMillis(block: fun() : Unit) : Long { /** Executes current block and returns elapsed time in milliseconds */ -fun measureTimeNano(block: fun() : Unit) : Long { +fun measureTimeNano(block: () -> Unit) : Long { val start = System.nanoTime() block() return System.nanoTime() - start diff --git a/stdlib/ktSrc/Thread.kt b/stdlib/ktSrc/Thread.kt index 637418ea902..e55b77e3a86 100644 --- a/stdlib/ktSrc/Thread.kt +++ b/stdlib/ktSrc/Thread.kt @@ -1,4 +1,4 @@ -namespace std.concurrent +package std.concurrent import java.lang.* @@ -21,7 +21,7 @@ inline var Thread.contextClassLoader : ClassLoader? get() = getContextClassLoader() set(loader: ClassLoader?) { setContextClassLoader(loader) } -fun thread(start: Boolean = true, daemon: Boolean = false, contextClassLoader: ClassLoader? = null, name: String? = null, priority: Int = -1, block: fun():Unit) : Thread { +fun thread(start: Boolean = true, daemon: Boolean = false, contextClassLoader: ClassLoader? = null, name: String? = null, priority: Int = -1, block: ()->Unit) : Thread { val thread = object: Thread() { override fun run() { block()