Move everything under kotlin-native folder

I was forced to manually do update the following files, because otherwise
they would be ignored according .gitignore settings. Probably they
should be deleted from repo.

Interop/.idea/compiler.xml
Interop/.idea/gradle.xml
Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_1_0_3.xml
Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_0_3.xml
Interop/.idea/modules.xml
Interop/.idea/modules/Indexer/Indexer.iml
Interop/.idea/modules/Runtime/Runtime.iml
Interop/.idea/modules/StubGenerator/StubGenerator.iml
backend.native/backend.native.iml
backend.native/bc.frontend/bc.frontend.iml
backend.native/cli.bc/cli.bc.iml
backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt
backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt
backend.native/tests/link/lib/foo.kt
backend.native/tests/link/lib/foo2.kt
backend.native/tests/teamcity-test.property
This commit is contained in:
Stanislav Erokhin
2020-10-27 21:00:28 +03:00
parent 91e4162dad
commit f624800b84
2830 changed files with 0 additions and 0 deletions
@@ -0,0 +1,30 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.changingCapturedLocal
import kotlin.test.*
var log = ""
inline fun foo(x: Int, action: (Int) -> Unit) = action(x)
fun box(): String {
var x = 23
foo(x) {
log += "$it;"
x++
log += "$it;"
}
if (log != "23;23;") return "fail1: $log"
if (x != 24) return "fail2: $x"
return "OK"
}
@Test fun runTest() {
println(box())
}
@@ -0,0 +1,29 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.classDeclarationInsideInline
import kotlin.test.*
fun f() {
run {
class Test1<T : Number, G>(val x: T, val y: G) {
override fun toString() = "test1: ${x.toDouble()}"
}
class Test2<X>(val a: Test1<Int, X>) {
override fun toString() = "test2"
}
val v = Test2(Test1(1, Test2(Test1(1, 3))))
println(v.a)
println(v.a.x)
println(v.a.y)
}
}
@Test fun test() {
f()
}
@@ -0,0 +1,22 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.coercionToUnit
import kotlin.test.*
fun <T> myRun(action: () -> T): T = action()
fun foo(n: Number, b: Boolean) {
n.let {
if (b) return@let
myRun() { 42 }
}
}
@Test fun runTest() {
println(foo(42, false))
}
@@ -0,0 +1,40 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.correctOrderFunctionReference
import kotlin.test.*
class Foo(val a: String) {
fun test() = a
}
inline fun test(a: String, b: () -> String, c: () -> String, d: () -> String, e: String): String {
return a + b() + c() + d() + e
}
var effects = ""
fun create(a: String): Foo {
effects += a
return Foo(a)
}
fun create2(a: String, f: () -> String): Foo {
effects += a
return Foo(a)
}
fun box(): String {
val result = test(create("A").a, create("B")::a, create("C")::test, create2("E", create("D")::test)::test, create("F").a)
if (effects != "ABCDEF") return "fail 1: $effects"
return if (result == "ABCEF") "OK" else "fail 2: $result"
}
@Test fun runTest() {
println(box())
}
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.defaultArgs
import kotlin.test.*
class Z
inline fun Z.foo(x: Int = 42, y: Int = x) {
println(y)
}
@Test fun runTest() {
val z = Z()
z.foo()
}
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package a
inline fun foo(x: Int, y: Int = 117) = x + y
@@ -0,0 +1,11 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import a.*
fun main(args: Array<String>) {
println(foo(5))
println(foo(5, 42))
}
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.genericFunctionReference
import kotlin.test.*
class Z<T>(val x: T)
inline fun<T, R> foo(x: T, f: (T) -> R): R {
return f(x)
}
@Test fun runTest() {
val arr = Array(1) { foo(it, ::Z) }
println(arr[0].x)
}
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.getClass
import kotlin.test.*
fun foo() {
val cls1: Any? = Int
val cls2: Any? = null
cls1?.let {
cls2?.let {
var itClass = it::class
}
}
}
@Test fun runTest() {
println("OK")
}
@@ -0,0 +1,22 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline0
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo(i1: Int, j1: Int): Int {
return i1 + j1
}
fun bar(i: Int, j: Int): Int {
return i + foo(i, j)
}
@Test fun runTest() {
println(bar(41, 2).toString())
}
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline1
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo(s4: String, s5: String): String {
return s4 + s5
}
fun bar(s1: String, s2: String, s3: String): String {
return s1 + foo(s2, s3)
}
@Test fun runTest() {
println(bar("Hello ", "wor", "ld"))
}
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline10
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo(i2: Int, body: () -> Int): Int {
return i2 + body()
}
fun bar(i1: Int): Int {
return foo(i1) { 1 }
}
@Test fun runTest() {
println(bar(1).toString())
}
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline11
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun <reified T> foo (i2: Any): Boolean {
return i2 is T
}
fun bar(i1: Int): Boolean {
return foo<Double>(i1)
}
@Test fun runTest() {
println(bar(1).toString())
}
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline12
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun <T> foo (): Boolean {
return Any() is Any
}
fun bar(i1: Int): Boolean {
return foo<Double>()
}
@Test fun runTest() {
println(bar(1).toString())
}
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline13
import kotlin.test.*
open class A<T1>()
class B<T2>() : A<T2>()
@Suppress("NOTHING_TO_INLINE")
inline fun <reified T: A<*>> foo(f: Any?): Boolean {
return f is T?
}
fun bar(): Boolean {
return foo<B<Int>>(B<Int>())
}
@Test fun runTest() {
println(bar().toString())
}
@@ -0,0 +1,31 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline14
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo3(i3: Int): Int {
return i3 + 3
}
@Suppress("NOTHING_TO_INLINE")
inline fun foo2(i2: Int): Int {
return i2 + 2
}
@Suppress("NOTHING_TO_INLINE")
inline fun foo1(i1: Int): Int {
return foo2(i1)
}
fun bar(i0: Int): Int {
return foo1(i0) + foo3(i0)
}
@Test fun runTest() {
println(bar(2).toString())
}
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline15
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo2(i1: Int): Int {
return i1 + 1
}
@Suppress("NOTHING_TO_INLINE")
inline fun foo1(i1: Int, body: (Int) -> Int): Int {
return body(i1)
}
fun bar(i0: Int): Int {
return foo1(i0) { foo2(it) + 1 }
}
@Test fun runTest() {
println(bar(2).toString())
}
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline16
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun <T, C : MutableCollection<in T>> foo(destination: C, predicate: (T) -> Boolean): C {
for (element in destination) {
val value = element as T
if (!predicate(value)) destination.add(value)
}
return destination
}
fun bar(): Boolean {
val result = foo <Int, MutableList<Int>> (mutableListOf(1, 2, 3)) { true }
return result.isEmpty()
}
@Test fun runTest() {
println(bar().toString())
}
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline17
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun <T> foo(i1: T, i2: T): List<T> {
val j1 = i1
val j2 = i2
return listOf(j1, j2)
}
fun bar(): List<Int> {
return foo <Int> (1, 2)
}
@Test fun runTest() {
println(bar().toString())
}
@@ -0,0 +1,27 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline18
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun <T> foo2(i2: T, j2: T, p2: (T, T) -> Boolean): Boolean {
return p2(i2, j2)
}
@Suppress("NOTHING_TO_INLINE")
inline fun <T> foo1(i1: T, j1: T, p1: (T, T) -> Boolean): Boolean {
return foo2<T>(i1, j1, p1)
}
fun bar(): Boolean {
val result = foo1 <Int> (3, 3) { x1: Int, x2: Int -> x1 == x2 }
return result
}
@Test fun runTest() {
println(bar().toString())
}
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline19
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline private fun foo(i: Int): Int {
val result = i
return result + i
}
fun bar(): Int {
return foo(1) + foo(2)
}
@Test fun runTest() {
println(bar().toString())
}
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline2
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo(i4: Int, i5: Int) {
println("hello $i4 $i5")
}
fun bar(i1: Int, i2: Int) {
foo(i1, i2)
}
@Test fun runTest() {
bar(1, 8)
}
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline20
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun bar(block: () -> String) : String {
return block()
}
fun bar2() : String {
return bar { return "def" }
}
@Test fun runTest() {
println(bar2())
}
@@ -0,0 +1,27 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline21
import kotlin.test.*
inline fun foo2(block2: () -> Int) : Int {
println("foo2")
return block2()
}
inline fun foo1(block1: () -> Int) : Int {
println("foo1")
return foo2(block1)
}
fun bar(block: () -> Int) : Int {
println("bar")
return foo1(block)
}
@Test fun runTest() {
println(bar { 33 })
}
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline22
import kotlin.test.*
inline fun foo2(i2: Int): Int {
return i2 + 3
}
inline fun foo1(i1: Int): Int {
return foo2(i1)
}
fun bar(): Int {
return foo1(11)
}
@Test fun runTest() {
println(bar().toString())
}
@@ -0,0 +1,20 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline23
import kotlin.test.*
inline fun <reified T> foo(i2: Any): T {
return i2 as T
}
fun bar(i1: Int): Int {
return foo<Int>(i1)
}
@Test fun runTest() {
println(bar(33))
}
@@ -0,0 +1,17 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline24
import kotlin.test.*
fun foo() = println("foo")
fun bar() = println("bar")
inline fun baz(x: Unit = foo(), y: Unit) {}
@Test fun runTest() {
baz(y = bar())
}
@@ -0,0 +1,30 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline25
import kotlin.test.*
inline fun foo(block: String.() -> Unit) {
"Ok".block()
}
inline fun bar(block: (String) -> Unit) {
foo(block)
}
inline fun baz(block: String.() -> Unit) {
block("Ok")
}
@Test fun runTest() {
bar {
println(it)
}
baz {
println(this)
}
}
@@ -0,0 +1,18 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline26
import kotlin.test.*
inline fun call(block1: () -> Unit, noinline block2: () -> Int): Int {
block1()
return block2()
}
@Test fun runTest() {
var x = 5
println(call({ x = 7 }, x::toInt))
}
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline3
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo(i4: Int, i5: Int): Int {
try {
return i4 / i5
} catch (e: Throwable) {
return i4
}
}
fun bar(i1: Int, i2: Int, i3: Int): Int {
return i1 + foo(i2, i3)
}
@Test fun runTest() {
println(bar(1, 8, 2).toString())
}
@@ -0,0 +1,22 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline4
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo(i4: Int, i5: Int): Int {
if (i4 > 0) return i4
return i5
}
fun bar(i1: Int, i2: Int): Int {
return foo(i1, i2)
}
@Test fun runTest() {
println(bar(3, 8).toString())
}
@@ -0,0 +1,22 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline5
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo(i2: Int, body: () -> Int): Int {
return i2 + body()
}
fun bar(i1: Int): Int {
return foo(i1) { return 33 }
}
@Test fun runTest() {
println(bar(1).toString())
}
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline6
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo(body: () -> Unit) {
println("hello1")
body()
println("hello4")
}
fun bar() {
foo {
println("hello2")
println("hello3")
}
}
@Test fun runTest() {
bar()
}
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline7
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo(vararg args: Int) {
for (a in args) {
println(a.toString())
}
}
fun bar() {
foo(1, 2, 3)
}
@Test fun runTest() {
bar()
}
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline8
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo(i3: Int, i4: Int) : Int {
return i3 + i3 + i4
}
fun bar(i1: Int, i2: Int) : Int {
return foo(i1 + i2, 2)
}
@Test fun runTest() {
println(bar(1, 2).toString())
}
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.inline9
import kotlin.test.*
@Suppress("NOTHING_TO_INLINE")
inline fun foo(i3: Int, i4: Int): Int {
return i3 + i3 + i4
}
fun quiz(i: Int) : Int {
println("hello")
return i + 1
}
fun bar(i1: Int, i2: Int): Int {
return foo(quiz(i1), i2)
}
@Test fun runTest() {
println(bar(1, 2).toString())
}
@@ -0,0 +1,13 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package a
fun foo(n: Int, block: (Int) -> Int): Int {
val arr = IntArray(n) { block(it) }
var sum = 0
for (x in arr) sum += x
return sum
}
@@ -0,0 +1,11 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import a.*
import kotlin.test.*
fun main() {
assertEquals(42, foo(7) { it * 2 })
}
@@ -0,0 +1,16 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.lambdaAsAny
import kotlin.test.*
inline fun foo(x: Any) {
println(if (x === x) "Ok" else "Fail")
}
@Test fun runTest() {
foo { 42 }
}
@@ -0,0 +1,20 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.lambdaInDefaultValue
import kotlin.test.*
inline fun inlineFun(param: String, lambda: (String) -> String = { it }): String {
return lambda(param)
}
fun box(): String {
return inlineFun("OK")
}
@Test fun runTest() {
println(box())
}
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package a
fun IntArray.forEachNoInline(block: (Int) -> Unit) = this.forEach { block(it) }
inline fun foo(values: IntArray, crossinline block: (Int, Int, Int) -> Int): Int {
val o = object {
lateinit var s: String
var x: Int = 42
}
values.forEachNoInline {
o.x = block(o.x, o.s.length, it)
}
return o.x
}
@@ -0,0 +1,15 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import a.*
fun main() {
try {
val res = foo(intArrayOf(1, 2, 3)) { x, y, z -> x + y - z }
println(res)
} catch (t: UninitializedPropertyAccessException) {
println("OK")
}
}
@@ -0,0 +1,22 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.localFunctionInInitializerBlock
import kotlin.test.*
class Foo {
init {
bar()
}
}
inline fun bar() {
println({ "Ok" }())
}
@Test fun runTest() {
Foo()
}
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.localObjectReturnedFromWhen
import kotlin.test.*
fun foo() {
123?.let {
object : () -> Unit {
override fun invoke() = Unit
}
}
}
@Test fun runTest() {
foo()
println("Ok")
}
@@ -0,0 +1,20 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.returnLocalClassFromBlock
import kotlin.test.*
inline fun <R> call(block: ()->R): R {
try {
return block()
} finally {
println("Zzz")
}
}
@Test fun runTest() {
call { class Z(); Z() }
}
@@ -0,0 +1,16 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package a
fun IntArray.forEachNoInline(block: (Int) -> Unit) = this.forEach { block(it) }
inline fun fold(initial: Int, values: IntArray, crossinline block: (Int, Int) -> Int): Int {
var res = initial
values.forEachNoInline {
res = block(res, it)
}
return res
}
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import a.*
fun main() {
println(fold(0, intArrayOf(1, 2, 3)) { x, y -> x + y })
}
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.statementAsLastExprInBlock
import kotlin.test.*
fun foo() {
val cls1: Any? = Int
val cls2: Any? = null
cls1?.let {
if (cls2 != null) {
val zzz = 42
}
}
}
@Test fun runTest() {
println("OK")
}
@@ -0,0 +1,28 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.twiceInlinedObject
import kotlin.test.*
inline fun exec(f: () -> Unit) = f()
inline fun test2() {
val obj = object {
fun sayOk() = println("Ok")
}
obj.sayOk()
}
inline fun noExec(f: () -> Unit) { }
@Test fun runTest() {
exec {
test2()
}
noExec {
test2()
}
}
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.inline.typeSubstitutionInFakeOverride
import kotlin.test.*
abstract class A {
inline fun <reified T : Any> baz(): String {
return T::class.simpleName!!
}
}
class B : A() {
fun bar(): String {
return baz<OK>()
}
}
class OK
@Test fun runTest() {
println(B().bar())
}