@@ -21,40 +21,40 @@ import kotlin.reflect.KFunction0
2121
2222class Overloading {
2323
24- // inline fun <reified T> test(kFunction: KFunction0<Unit>, test: T.() -> Unit) {
25- // val annotation = kFunction.annotations.single() as T
26- // annotation.test()
27- // }
28- //
29- // fun check(b: Boolean, message: String) {
30- // if (!b) throw RuntimeException(message)
31- // }
32- //
33- // annotation class Foo(val a: FloatArray = [], val b: Array<String> = [], val c: Array<KClass<*>> = [])
34- //
35- // @Foo(a = [1f, 2f, 1 / 0f])
36- // fun test1() {}
37- //
38- // @Foo(b = ["Hello", ", ", "Kot" + "lin"])
39- // fun test2() {}
40- //
41- // @Foo(c = [Int::class, Array<Short>::class, Foo::class])
42- // fun test3() {}
43- //
44- // fun box(): String {
45- // test<Foo>(::test1) {
46- // check(a.contentEquals(floatArrayOf(1f, 2f, Float.POSITIVE_INFINITY)), "Fail 1: ${a.joinToString()}")
47- // }
48- //
49- // test<Foo>(::test2) {
50- // check(b.contentEquals(arrayOf("Hello", ", ", "Kotlin")), "Fail 2: ${b.joinToString()}")
51- // }
52- //
53- // test<Foo>(::test3) {
54- // check(c.contentEquals(arrayOf(Int::class, Array<Short>::class, Foo::class)), "Fail 3: ${c.joinToString()}")
55- // }
56- //
57- // return "OK"
58- // }
24+ inline fun <reified T > test (kFunction : KFunction0 <Unit >, test : T .() -> Unit ) {
25+ val annotation = kFunction.annotations.single() as T
26+ annotation.test()
27+ }
28+
29+ fun check (b : Boolean , message : String ) {
30+ if (! b) throw RuntimeException (message)
31+ }
32+
33+ annotation class Foo (val a : FloatArray = [], val b : Array <String > = [], val c : Array <KClass <* >> = [])
34+
35+ @Foo(a = [1f , 2f , 1 / 0f ])
36+ fun test1 () {}
37+
38+ @Foo(b = [" Hello" , " , " , " Kot" + " lin" ])
39+ fun test2 () {}
40+
41+ @Foo(c = [Int ::class , Array <Short >::class , Foo ::class ])
42+ fun test3 () {}
43+
44+ fun box (): String {
45+ test<Foo >(::test1) {
46+ check(a.contentEquals(floatArrayOf(1f , 2f , Float .POSITIVE_INFINITY )), " Fail 1: ${a.joinToString()} " )
47+ }
48+
49+ test<Foo >(::test2) {
50+ check(b.contentEquals(arrayOf(" Hello" , " , " , " Kotlin" )), " Fail 2: ${b.joinToString()} " )
51+ }
52+
53+ test<Foo >(::test3) {
54+ check(c.contentEquals(arrayOf(Int ::class , Array <Short >::class , Foo ::class )), " Fail 3: ${c.joinToString()} " )
55+ }
56+
57+ return " OK"
58+ }
5959
6060}
0 commit comments