GreatSyntacticShift: Codegen testdata fixed
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
namespace foo;
|
||||
package foo;
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ fun box() : String {
|
||||
return invoker( {"OK"} )
|
||||
}
|
||||
|
||||
fun invoker(gen : fun () : String) : String {
|
||||
fun invoker(gen : () -> String) : String {
|
||||
return gen()
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import java.util.*
|
||||
|
||||
fun <T> ArrayList<T>.findAll(predicate: fun (T) : Boolean): ArrayList<T> {
|
||||
fun <T> ArrayList<T>.findAll(predicate: (T) -> Boolean): ArrayList<T> {
|
||||
val result = ArrayList<T>()
|
||||
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<String> = list.findAll<String>({(name: String) => name.startsWith("M")})
|
||||
val m: ArrayList<String> = list.findAll<String>({(name: String) -> name.startsWith("M")})
|
||||
return if (m.size() == 2) "OK" else "fail"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ fun <T> 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)
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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> 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"
|
||||
|
||||
@@ -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) = { t.toString() }
|
||||
|
||||
fun fooT2<T>(t: T) = { (x:T) => t.toString() + x.toString() }
|
||||
fun fooT2<T>(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<String>("mama"))() != "mama") return "test 8 failed";
|
||||
if( (fooT2<String>("mama"))("papa") != "mamapapa") return "test 9 failed";
|
||||
return "OK"
|
||||
|
||||
@@ -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--)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class X<T> () {
|
||||
fun getTypeChecker() = { (a : Any) => a is T }
|
||||
fun getTypeChecker() = { (a : Any) -> a is T }
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Foo {
|
||||
package Foo {
|
||||
fun bar() = 610
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fun isZero(x: Int) = when(x) {
|
||||
0 => true
|
||||
else => false
|
||||
0 -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
fun isZero(x: Int) = when(x) {
|
||||
0 => true
|
||||
0 -> true
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fun isString(x: Any) = when(x) {
|
||||
is String => "string"
|
||||
else => "something"
|
||||
is String -> "string"
|
||||
else -> "something"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fun isDigit(a: Char) = when(a) {
|
||||
in '0'..'9' => "digit"
|
||||
else => "something"
|
||||
in '0'..'9' -> "digit"
|
||||
else -> "something"
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
fun main(args: Array<String>?) {
|
||||
val y: Unit = () //do not compile
|
||||
val y: Unit = #() //do not compile
|
||||
A<Unit>() //do not compile
|
||||
C<Unit>(()) //do not compile
|
||||
C<Unit>(#()) //do not compile
|
||||
//do not compile
|
||||
System.out?.println(fff<Unit>(())) //do not compile
|
||||
System.out?.println(fff<Unit>(#())) //do not compile
|
||||
System.out?.println(id<Unit>(y)) //do not compile
|
||||
System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(Array<Int>(0,{0}),{(e : Int) : Unit => }))) //do not compile
|
||||
System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(Array<Int>(0,{0}),{(e : Int) : Unit -> }))) //do not compile
|
||||
}
|
||||
class A<T>()
|
||||
|
||||
@@ -17,13 +17,13 @@ fun <T> fff(x: T) : T { return x }
|
||||
|
||||
fun <T> id(value: T): T = value
|
||||
|
||||
fun foreach(array: Array<Int>?, action: fun(Int): Unit) {
|
||||
fun foreach(array: Array<Int>?, action: (Int)-> Unit) {
|
||||
for (el in array) {
|
||||
action(el) //exception through compilation (see below)
|
||||
}
|
||||
}
|
||||
|
||||
fun almostFilter(array: Array<Int>, action: fun(Int): Int) {
|
||||
fun almostFilter(array: Array<Int>, 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"
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace x
|
||||
package x
|
||||
|
||||
class Outer() {
|
||||
class object {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace test
|
||||
package test
|
||||
|
||||
class List<T>(len: Int) {
|
||||
val a : Array<T?> = Array<T?>(len)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import java.util.ArrayList
|
||||
|
||||
fun launch(f : fun() : Unit) {
|
||||
fun launch(f : () -> Unit) {
|
||||
f()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val list = ArrayList<Int>()
|
||||
val foo : fun() : Unit = {
|
||||
val foo : () -> Unit = {
|
||||
list.add(2) //first exception
|
||||
}
|
||||
foo()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace mult_constructors_3_bug
|
||||
package mult_constructors_3_bug
|
||||
|
||||
public open class Identifier() {
|
||||
private var myNullable : Boolean = true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace one_extends_base
|
||||
package one_extends_base
|
||||
|
||||
open class Base<T>(name : T?) {
|
||||
var myName : T?
|
||||
|
||||
@@ -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> T.pr(f : fun(T) : Unit) : T {
|
||||
fun <T> T.pr(f : (T) -> Unit) : T {
|
||||
f(this)
|
||||
return this
|
||||
}
|
||||
|
||||
fun LinkedList<Int>.sum(f : fun(Int, Int ): Int): Int {
|
||||
fun LinkedList<Int>.sum(f : (Int, Int )-> Int): Int {
|
||||
var sum = 0
|
||||
for (i in 1..size()) {
|
||||
val j = size() - i
|
||||
@@ -120,7 +120,7 @@ fun LinkedList<Int>.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
|
||||
|
||||
@@ -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<Int>.sum(f : fun(index : Int, value : Int) : Int) : Int {
|
||||
fun java.lang.Iterable<Int>.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<Int>.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
|
||||
|
||||
@@ -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<Int>.sum(f : fun(Int, Int) : Int) : Int {
|
||||
fun LinkedList<Int>.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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace while_bug_1
|
||||
package while_bug_1
|
||||
|
||||
import java.io.*
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace whats.the.difference
|
||||
package whats.the.difference
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace array_test
|
||||
package array_test
|
||||
|
||||
fun box() : String {
|
||||
var array : IntArray? = IntArray(10)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace name
|
||||
package name
|
||||
|
||||
class Test() {
|
||||
var i = 5
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace demo
|
||||
package demo
|
||||
|
||||
public open class Identifier<T>(myName : T?, myHasDollar : Boolean) {
|
||||
{
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace org2
|
||||
package org2
|
||||
|
||||
enum class Test {
|
||||
A
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class List<T>(val head: T, val tail: List<T>? = null)
|
||||
|
||||
fun <T> List<T>.mapHead(f: fun(T): T): List<T> = List<T>(f(head), null)
|
||||
fun <T> List<T>.mapHead(f: (T)-> T): List<T> = List<T>(f(head), null)
|
||||
|
||||
fun box() : String {
|
||||
val a: Int = List<Int>(1).mapHead{it * 2}.head
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace demo_range
|
||||
package demo_range
|
||||
|
||||
fun Int?.rangeTo(other : Int?) : IntRange = this.sure().rangeTo(other.sure())
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace bitwise_demo
|
||||
package bitwise_demo
|
||||
|
||||
fun Long?.shl(bits : Int?) : Long = this.sure().shl(bits.sure())
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace demo_range
|
||||
package demo_range
|
||||
|
||||
fun Int?.plus() : Int = this.sure().plus()
|
||||
fun Int?.dec() : Int = this.sure().dec()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace demo_long
|
||||
package demo_long
|
||||
|
||||
fun Long?.inv() : Long = this.sure().inv()
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
namespace demo2
|
||||
package demo2
|
||||
|
||||
fun print(o : Any?) {}
|
||||
|
||||
fun test(i : Int) {
|
||||
var monthString : String? = "<empty>"
|
||||
when (i) {
|
||||
1 => {
|
||||
1 -> {
|
||||
print(1)
|
||||
print(2)
|
||||
print(3)
|
||||
print(4)
|
||||
print(5)
|
||||
}
|
||||
else => {
|
||||
else -> {
|
||||
monthString = "Invalid month"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
namespace demo2
|
||||
package demo2
|
||||
|
||||
fun print(o : Any?) {}
|
||||
|
||||
fun test(i : Int) {
|
||||
var monthString : String? = "<empty>"
|
||||
when (i) {
|
||||
1 => {
|
||||
1 -> {
|
||||
print(1)
|
||||
print(2)
|
||||
print(3)
|
||||
print(4)
|
||||
print(5)
|
||||
}
|
||||
else => {
|
||||
else -> {
|
||||
monthString = "Invalid month"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class A() {
|
||||
var x : Int = 0
|
||||
|
||||
var z = { () =>
|
||||
var z = { () ->
|
||||
x++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace foo
|
||||
package foo
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace demo
|
||||
package demo
|
||||
|
||||
fun box() : String {
|
||||
var res : Boolean = true
|
||||
|
||||
@@ -36,7 +36,7 @@ trait WriteOnlyArray<in T> : ISized {
|
||||
}
|
||||
}
|
||||
|
||||
class MutableArray<T>(length: Int, init : fun(Int) : T) : ReadOnlyArray<T>, WriteOnlyArray<T> {
|
||||
class MutableArray<T>(length: Int, init : (Int) -> T) : ReadOnlyArray<T>, WriteOnlyArray<T> {
|
||||
private val array = Array<T>(length, init)
|
||||
|
||||
override fun get(index : Int) : T = array[index]
|
||||
|
||||
Reference in New Issue
Block a user