diff --git a/backend.native/tests/external/codegen/box/annotations/wrongAnnotationArgumentInCtor.kt b/backend.native/tests/external/codegen/box/annotations/wrongAnnotationArgumentInCtor.kt new file mode 100644 index 00000000000..e76d099ca05 --- /dev/null +++ b/backend.native/tests/external/codegen/box/annotations/wrongAnnotationArgumentInCtor.kt @@ -0,0 +1,17 @@ +// IGNORE_BACKEND: JVM, JS, NATIVE + +// Here we check that there is compilation error, so ignore_backend directive is actual + +@Target(AnnotationTarget.FIELD, AnnotationTarget.CLASS) +annotation class Anno + +class UnresolvedArgument(@Anno(BLA) val s: Int) + +class WithoutArguments(@Deprecated val s: Int) + +fun box(): String { + UnresolvedArgument(3) + WithoutArguments(0) + + return "OK" +} diff --git a/backend.native/tests/external/codegen/box/arrays/arrayInstanceOf.kt b/backend.native/tests/external/codegen/box/arrays/arrayInstanceOf.kt index d5323fbbdbb..406b97e57a4 100644 --- a/backend.native/tests/external/codegen/box/arrays/arrayInstanceOf.kt +++ b/backend.native/tests/external/codegen/box/arrays/arrayInstanceOf.kt @@ -1,6 +1,3 @@ -// TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS - //test [], get and iterator calls fun test(createIntNotLong: Boolean): String { val a = if (createIntNotLong) IntArray(5) else LongArray(5) @@ -25,5 +22,8 @@ fun test(createIntNotLong: Boolean): String { } fun box(): String { + // Only run this test if primitive array `is` checks work (KT-17137) + if ((intArrayOf() as Any) is Array<*>) return "OK" + return test(true) + test(false) } \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/arrays/iteratorByteArrayNextByte.kt b/backend.native/tests/external/codegen/box/arrays/iteratorByteArrayNextByte.kt index 19bf8463026..61c458433a7 100644 --- a/backend.native/tests/external/codegen/box/arrays/iteratorByteArrayNextByte.kt +++ b/backend.native/tests/external/codegen/box/arrays/iteratorByteArrayNextByte.kt @@ -1,6 +1,3 @@ -// TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS - fun box(): String { val a = ByteArray(5) val x = a.iterator() diff --git a/backend.native/tests/external/codegen/box/arrays/iteratorLongArrayNextLong.kt b/backend.native/tests/external/codegen/box/arrays/iteratorLongArrayNextLong.kt index 74bf8c9f4a4..cc9cec5d570 100644 --- a/backend.native/tests/external/codegen/box/arrays/iteratorLongArrayNextLong.kt +++ b/backend.native/tests/external/codegen/box/arrays/iteratorLongArrayNextLong.kt @@ -1,6 +1,3 @@ -// TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS - fun box(): String { val a = LongArray(5) val x = a.iterator() diff --git a/backend.native/tests/external/codegen/box/arrays/kt17134.kt b/backend.native/tests/external/codegen/box/arrays/kt17134.kt new file mode 100644 index 00000000000..515d0aceeb9 --- /dev/null +++ b/backend.native/tests/external/codegen/box/arrays/kt17134.kt @@ -0,0 +1,17 @@ +//WITH_RUNTIME +// IGNORE_BACKEND: JS +// IGNORE_BACKEND: NATIVE + +object A { + @JvmStatic fun main(args: Array) { + val b = arrayOf(arrayOf("")) + object { + val c = b[0] + } + } +} + +fun box(): String { + A.main(emptyArray()) + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/arrays/kt2997.kt b/backend.native/tests/external/codegen/box/arrays/kt2997.kt index 6ccce13d01d..ac70c009a2d 100644 --- a/backend.native/tests/external/codegen/box/arrays/kt2997.kt +++ b/backend.native/tests/external/codegen/box/arrays/kt2997.kt @@ -1,6 +1,4 @@ //KT-2997 Automatically cast error (Array) -// IGNORE_BACKEND: JS -// Unmute when JS implements primitive arrays via TypeArray fun foo(a: Any): Int { if (a is IntArray) { @@ -55,6 +53,9 @@ fun foo(a: Any): Int { } fun box(): String { + // Only run this test if primitive array `is` checks work (KT-17137) + if ((intArrayOf() as Any) is Array<*>) return "OK" + val iA = IntArray(1) if (foo(iA) != 1) return "fail int[]" val sA = ShortArray(1) diff --git a/backend.native/tests/external/codegen/box/arrays/kt7288.kt b/backend.native/tests/external/codegen/box/arrays/kt7288.kt index 12cd2e6c591..2c387e56cf9 100644 --- a/backend.native/tests/external/codegen/box/arrays/kt7288.kt +++ b/backend.native/tests/external/codegen/box/arrays/kt7288.kt @@ -21,6 +21,9 @@ fun test(b: Boolean): String { } fun box(): String { + // Only run this test if primitive array `is` checks work (KT-17137) + if ((intArrayOf() as Any) is Array<*>) return "OK" + if (test(true) != "OK") return "fail 1: ${test(true)}" if (test(false) != "OK") return "fail 1: ${test(false)}" diff --git a/backend.native/tests/external/codegen/box/boxingOptimization/explicitEqualsOnDouble.kt b/backend.native/tests/external/codegen/box/boxingOptimization/explicitEqualsOnDouble.kt new file mode 100644 index 00000000000..ea864337add --- /dev/null +++ b/backend.native/tests/external/codegen/box/boxingOptimization/explicitEqualsOnDouble.kt @@ -0,0 +1,8 @@ +// IGNORE_BACKEND: JS + +fun equals1(a: Double, b: Double) = a.equals(b) + +fun box(): String { + if ((-0.0).equals(0.0)) return "fail 0" + return "OK" +} diff --git a/backend.native/tests/external/codegen/box/boxingOptimization/kt15871.kt b/backend.native/tests/external/codegen/box/boxingOptimization/kt15871.kt new file mode 100644 index 00000000000..f41df27c983 --- /dev/null +++ b/backend.native/tests/external/codegen/box/boxingOptimization/kt15871.kt @@ -0,0 +1,5 @@ +fun box() = + if (getAndCheck({ 42 }, { 42 })) "OK" else "fail" + +inline fun getAndCheck(getFirst: () -> T, getSecond: () -> T) = + getFirst() == getSecond() \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/builtinStubMethods/immutableRemove.kt b/backend.native/tests/external/codegen/box/builtinStubMethods/immutableRemove.kt deleted file mode 100644 index 2710f121246..00000000000 --- a/backend.native/tests/external/codegen/box/builtinStubMethods/immutableRemove.kt +++ /dev/null @@ -1,53 +0,0 @@ -// TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE - -// FULL_JDK -// WITH_RUNTIME -interface ImmutableCollection : Collection { - fun add(element: @UnsafeVariance E): ImmutableCollection - fun addAll(elements: Collection<@UnsafeVariance E>): ImmutableCollection - fun remove(element: @UnsafeVariance E): ImmutableCollection -} - -class ImmutableCollectionmpl : ImmutableCollection { - override val size: Int - get() = throw UnsupportedOperationException() - - override fun contains(element: E): Boolean { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun containsAll(elements: Collection): Boolean { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun isEmpty(): Boolean { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun iterator(): Iterator { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun add(element: E): ImmutableCollection = this - override fun addAll(elements: Collection): ImmutableCollection = this - override fun remove(element: E): ImmutableCollection = this -} - -fun box(): String { - val c = ImmutableCollectionmpl() - if (c.remove("") !== c) return "fail 1" - if (c.add("") !== c) return "fail 2" - if (c.addAll(java.util.ArrayList()) !== c) return "fail 3" - - val method = c.javaClass.methods.single { it.name == "remove" && it.returnType == Boolean::class.javaPrimitiveType } - - try { - method.invoke(c, "") - return "fail 4" - } catch (e: java.lang.reflect.InvocationTargetException) { - if (e.cause!!.message != "Operation is not supported for read-only collection") return "fail 5: ${e.cause!!.message}" - } - - return "OK" -} diff --git a/backend.native/tests/external/codegen/box/callableReference/bound/genericValOnLHS.kt b/backend.native/tests/external/codegen/box/callableReference/bound/genericValOnLHS.kt new file mode 100644 index 00000000000..e3a16aa52ae --- /dev/null +++ b/backend.native/tests/external/codegen/box/callableReference/bound/genericValOnLHS.kt @@ -0,0 +1,14 @@ +// IGNORE_BACKEND: NATIVE + +class Generic

(val p: P) + +class Host { + fun t() {} + val v = "OK" +} + +fun box(): String { + Generic(Host()).p::class + (Generic(Host()).p::t)() + return (Generic(Host()).p::v)() +} diff --git a/backend.native/tests/external/codegen/box/callableReference/bound/smartCastForExtensionReceiver.kt b/backend.native/tests/external/codegen/box/callableReference/bound/smartCastForExtensionReceiver.kt new file mode 100644 index 00000000000..c48830488c4 --- /dev/null +++ b/backend.native/tests/external/codegen/box/callableReference/bound/smartCastForExtensionReceiver.kt @@ -0,0 +1,15 @@ +class B + +fun B.magic() { +} + +fun boom(a: Any) { + when (a) { + is B -> run(a::magic) + } +} + +fun box(): String { + boom(B()) + return "OK" +} diff --git a/backend.native/tests/external/codegen/box/callableReference/function/getArityViaFunctionImpl.kt b/backend.native/tests/external/codegen/box/callableReference/function/getArityViaFunctionImpl.kt index 775e4a848fb..2ee3d4f4543 100644 --- a/backend.native/tests/external/codegen/box/callableReference/function/getArityViaFunctionImpl.kt +++ b/backend.native/tests/external/codegen/box/callableReference/function/getArityViaFunctionImpl.kt @@ -1,5 +1,6 @@ // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/callableReference/function/local/equalsHashCode.kt b/backend.native/tests/external/codegen/box/callableReference/function/local/equalsHashCode.kt new file mode 100644 index 00000000000..b547cb1ee3f --- /dev/null +++ b/backend.native/tests/external/codegen/box/callableReference/function/local/equalsHashCode.kt @@ -0,0 +1,13 @@ +// IGNORE_BACKEND: JS, NATIVE + +fun box(): String { + fun bar() {} + fun baz() {} + + if (!::bar.equals(::bar)) return "Fail 1" + if (::bar.hashCode() != ::bar.hashCode()) return "Fail 2" + + if (::bar == ::baz) return "Fail 3" + + return "OK" +} diff --git a/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInCrossinline.kt b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInCrossinline.kt new file mode 100644 index 00000000000..0568c83dde4 --- /dev/null +++ b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInCrossinline.kt @@ -0,0 +1,9 @@ +inline fun runCrossInline(crossinline f: () -> Unit) { + f() +} + +fun box(): String { + var x = "" + runCrossInline { x = "OK" } + return x +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyAssign.kt b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyAssign.kt new file mode 100644 index 00000000000..5faf6875838 --- /dev/null +++ b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyAssign.kt @@ -0,0 +1,7 @@ +// WITH_RUNTIME + +fun box(): String { + var x = "" + run { x = "OK" } + return x +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyCAO.kt b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyCAO.kt new file mode 100644 index 00000000000..0f62af3ed4d --- /dev/null +++ b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyCAO.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME + +fun box(): String { + var x = "" + run { + x += "O" + x += "K" + } + return x +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyIncrDecr.kt b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyIncrDecr.kt new file mode 100644 index 00000000000..c8d5c31083e --- /dev/null +++ b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyIncrDecr.kt @@ -0,0 +1,8 @@ +// WITH_RUNTIME + +fun box(): String { + var x = 0 + run { x++ } + run { ++x } + return if (x == 2) "OK" else "Fail: $x" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyIndexedCAO.kt b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyIndexedCAO.kt new file mode 100644 index 00000000000..44e0531c7b7 --- /dev/null +++ b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyIndexedCAO.kt @@ -0,0 +1,18 @@ +// WITH_RUNTIME + +class Host(var value: String) { + operator fun get(i: Int, j: Int, k: Int) = value + + operator fun set(i: Int, j: Int, k: Int, newValue: String) { + value = newValue + } +} + +fun box(): String { + var x = Host("") + run { + x[0, 0, 0] += "O" + x[0, 0, 0] += "K" + } + return x.value +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedVarsOfSize2.kt b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedVarsOfSize2.kt new file mode 100644 index 00000000000..10f31cbc43a --- /dev/null +++ b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/capturedVarsOfSize2.kt @@ -0,0 +1,26 @@ +// WITH_RUNTIME + +fun box(): String { + var xl = 0L // Long, size 2 + var xi = 0 // Int, size 1 + var xd = 0.0 // Double, size 2 + + run { + xl++ + xd += 1.0 + xi++ + } + + run { + run { + xl++ + xd += 1.0 + xi++ + } + } + + if (xi != 2) return "fail: xi=$xi" + if (xl != 2L) return "fail: xl=$xl" + if (xd != 2.0) return "fail: xd=$xd" + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/kt17200.kt b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/kt17200.kt new file mode 100644 index 00000000000..0d223fc9f97 --- /dev/null +++ b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/kt17200.kt @@ -0,0 +1,26 @@ +inline fun inlineCall(action: () -> Unit) { + action() +} + +fun test() { + var width = 1 + inlineCall { + width += width + } +} + +fun test2() { + var width = 1L + val newValue = 1; + val newValue2 = "123"; + val newValue3 = 2.0; + inlineCall { + width += width + } +} + +fun box(): String { + test() + test2() + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/sharedSlotsWithCapturedVars.kt b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/sharedSlotsWithCapturedVars.kt new file mode 100644 index 00000000000..09ed429ede5 --- /dev/null +++ b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/sharedSlotsWithCapturedVars.kt @@ -0,0 +1,19 @@ +// WITH_RUNTIME + +fun box(): String { + run { + run { + var x = 0 + run { ++x } + if (x == 0) return "fail" + } + + run { + var x = 0 + run { x++ } + if (x == 0) return "fail" + } + } + + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/withCoroutines.kt b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/withCoroutines.kt new file mode 100644 index 00000000000..c1bbf1a27d9 --- /dev/null +++ b/backend.native/tests/external/codegen/box/closures/capturedVarsOptimization/withCoroutines.kt @@ -0,0 +1,41 @@ +// WITH_RUNTIME +// WITH_COROUTINES +import kotlin.coroutines.experimental.* +import kotlin.coroutines.experimental.intrinsics.* + + +class Controller { + var result = "" + + suspend fun suspendWithResult(value: T): T = suspendCoroutineOrReturn { c -> + c.resume(value) + COROUTINE_SUSPENDED + } +} + +fun builder(c: suspend Controller.() -> Unit): String { + val controller = Controller() + c.startCoroutine(controller, EmptyContinuation) + return controller.result +} + +fun box(): String { + val value = builder { + var r = "" + + for (x in listOf("O", "$", "K")) { + if (x == "$") continue + run { + r += suspendWithResult(x) + } + } + run { + r += "." + } + result = r + } + + if (value != "OK.") return "fail: suspend in for body: $value" + + return "OK" +} diff --git a/backend.native/tests/external/codegen/box/collectionLiterals/collectionLiteralsInArgumentPosition.kt b/backend.native/tests/external/codegen/box/collectionLiterals/collectionLiteralsInArgumentPosition.kt new file mode 100644 index 00000000000..ccab06759ae --- /dev/null +++ b/backend.native/tests/external/codegen/box/collectionLiterals/collectionLiteralsInArgumentPosition.kt @@ -0,0 +1,45 @@ +// LANGUAGE_VERSION: 1.2 +// WITH_REFLECT + +// IGNORE_BACKEND: JS +// IGNORE_BACKEND: NATIVE + +import java.util.Arrays +import kotlin.reflect.KClass +import kotlin.reflect.KFunction0 + +inline fun test(kFunction: KFunction0, test: T.() -> Unit) { + val annotation = kFunction.annotations.single() as T + annotation.test() +} + +fun check(b: Boolean, message: String) { + if (!b) throw RuntimeException(message) +} + +annotation class Foo(val a: FloatArray = [], val b: Array = [], val c: Array> = []) + +@Foo(a = [1f, 2f, 1 / 0f]) +fun test1() {} + +@Foo(b = ["Hello", ", ", "Kot" + "lin"]) +fun test2() {} + +@Foo(c = [Int::class, Array::class, Foo::class]) +fun test3() {} + +fun box(): String { + test(::test1) { + check(a.contentEquals(floatArrayOf(1f, 2f, Float.POSITIVE_INFINITY)), "Fail 1: ${a.joinToString()}") + } + + test(::test2) { + check(b.contentEquals(arrayOf("Hello", ", ", "Kotlin")), "Fail 2: ${b.joinToString()}") + } + + test(::test3) { + check(c.contentEquals(arrayOf(Int::class, Array::class, Foo::class)), "Fail 3: ${c.joinToString()}") + } + + return "OK" +} diff --git a/backend.native/tests/external/codegen/box/collectionLiterals/collectionLiteralsWithConstants.kt b/backend.native/tests/external/codegen/box/collectionLiterals/collectionLiteralsWithConstants.kt new file mode 100644 index 00000000000..48d382901d4 --- /dev/null +++ b/backend.native/tests/external/codegen/box/collectionLiterals/collectionLiteralsWithConstants.kt @@ -0,0 +1,38 @@ +// LANGUAGE_VERSION: 1.2 +// WITH_REFLECT + +// IGNORE_BACKEND: JS +// IGNORE_BACKEND: NATIVE + +import java.util.Arrays +import kotlin.reflect.KFunction0 + +inline fun test(kFunction: KFunction0, test: T.() -> Unit) { + val annotation = kFunction.annotations.single() as T + annotation.test() +} + +fun check(b: Boolean, message: String) { + if (!b) throw RuntimeException(message) +} + +annotation class Foo(val a: IntArray = [], val b: Array = []) + +const val ONE_INT = 1 +const val ONE_FLOAT = 1f +const val HELLO = "hello" +const val C_CHAR = 'c' + +@Foo( + a = [ONE_INT, ONE_INT + ONE_FLOAT.toInt(), ONE_INT + 10, (ONE_INT % 1.0).toInt()], + b = [HELLO, HELLO + C_CHAR, HELLO + ", Kotlin", C_CHAR.toString() + C_CHAR]) +fun test1() {} + +fun box(): String { + test(::test1) { + check(a.contentEquals(intArrayOf(1, 2, 11, 0)), "Fail 1: ${a.joinToString()}") + check(b.contentEquals(arrayOf("hello", "helloc", "hello, Kotlin", "cc")), "Fail 2: ${b.joinToString()}") + } + + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/collectionLiterals/collectionLiteralsWithVarargs.kt b/backend.native/tests/external/codegen/box/collectionLiterals/collectionLiteralsWithVarargs.kt new file mode 100644 index 00000000000..fb8982083db --- /dev/null +++ b/backend.native/tests/external/codegen/box/collectionLiterals/collectionLiteralsWithVarargs.kt @@ -0,0 +1,40 @@ +// LANGUAGE_VERSION: 1.2 +// WITH_REFLECT + +// IGNORE_BACKEND: JS +// IGNORE_BACKEND: NATIVE + +import java.util.Arrays +import kotlin.reflect.KClass +import kotlin.reflect.KFunction0 + +inline fun test(kFunction: KFunction0, test: T.() -> Unit) { + val annotation = kFunction.annotations.single() as T + annotation.test() +} + +fun check(b: Boolean, message: String) { + if (!b) throw RuntimeException(message) +} + +annotation class Foo(vararg val a: String = ["a", "b"]) + +annotation class Bar(vararg val a: KClass<*> = [Int::class]) + +@Foo(*["/"]) +fun test1() {} + +@Bar(*[Long::class, String::class]) +fun test2() {} + +fun box(): String { + test(::test1) { + check(a.contentEquals(arrayOf("/")), "Fail 1: ${a.joinToString()}") + } + + test(::test2) { + check(a.contentEquals(arrayOf(Long::class, String::class)), "Fail 2: ${a.joinToString()}") + } + + return "OK" +} diff --git a/backend.native/tests/external/codegen/box/collectionLiterals/defaultAnnotationParameterValues.kt b/backend.native/tests/external/codegen/box/collectionLiterals/defaultAnnotationParameterValues.kt new file mode 100644 index 00000000000..644243153a2 --- /dev/null +++ b/backend.native/tests/external/codegen/box/collectionLiterals/defaultAnnotationParameterValues.kt @@ -0,0 +1,40 @@ +// LANGUAGE_VERSION: 1.2 +// WITH_REFLECT + +// IGNORE_BACKEND: JS +// IGNORE_BACKEND: NATIVE + +import java.util.Arrays +import kotlin.reflect.KClass +import kotlin.reflect.KFunction0 + +inline fun test(kFunction: KFunction0, test: T.() -> String): String { + val annotation = kFunction.annotations.single() as T + return annotation.test() +} + +fun check(b: Boolean, message: String) { + if (!b) throw RuntimeException(message) +} + +annotation class Foo( + val a: IntArray = [], + val b: IntArray = [1, 2, 3], + val c: Array = ["/"], + val d: Array> = [Int::class, Array::class], + val e: DoubleArray = [1.0] +) + +@Foo +fun withAnn() {} + +fun box(): String { + return test(::withAnn) { + check(a.contentEquals(intArrayOf()), "Fail 1: ${a.joinToString()}") + check(b.contentEquals(intArrayOf(1, 2, 3)), "Fail 2: ${b.joinToString()}") + check(c.contentEquals(arrayOf("/")), "Fail 3: ${c.joinToString()}") + check(d.contentEquals(arrayOf(Int::class, Array::class)), "Fail 4: ${d.joinToString()}") + check(e.contentEquals(doubleArrayOf(1.0)), "Fail 5: ${e.joinToString()}") + "OK" + } +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/coroutines/featureIntersection/tailrec.kt b/backend.native/tests/external/codegen/box/coroutines/featureIntersection/tailrec.kt index 44170511eb6..8c0cd42e2f1 100644 --- a/backend.native/tests/external/codegen/box/coroutines/featureIntersection/tailrec.kt +++ b/backend.native/tests/external/codegen/box/coroutines/featureIntersection/tailrec.kt @@ -1,6 +1,6 @@ // WITH_RUNTIME // WITH_COROUTINES -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: NATIVE import kotlin.coroutines.experimental.* import kotlin.coroutines.experimental.intrinsics.* import kotlin.test.assertEquals diff --git a/backend.native/tests/external/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt b/backend.native/tests/external/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt index ac80967bc34..acf58ce553e 100644 --- a/backend.native/tests/external/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt +++ b/backend.native/tests/external/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt @@ -1,6 +1,6 @@ // WITH_RUNTIME // WITH_COROUTINES -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: NATIVE import kotlin.coroutines.experimental.* import kotlin.coroutines.experimental.intrinsics.* import kotlin.test.assertEquals diff --git a/backend.native/tests/external/codegen/box/coroutines/overrideDefaultArgument.kt b/backend.native/tests/external/codegen/box/coroutines/overrideDefaultArgument.kt new file mode 100644 index 00000000000..f248d0181de --- /dev/null +++ b/backend.native/tests/external/codegen/box/coroutines/overrideDefaultArgument.kt @@ -0,0 +1,78 @@ +// IGNORE_BACKEND: NATIVE +// WITH_RUNTIME +// WITH_COROUTINES +import kotlin.coroutines.experimental.* +import kotlin.coroutines.experimental.intrinsics.* + +fun box(): String { + async { + O.foo() + O.foo("second") + } + while (!finished) { + result += "--;" + proceed() + } + + finished = false + asyncSuspend { + O.foo() + O.foo("second") + } + while (!finished) { + result += "--;" + proceed() + } + + val expected = "before(first);--;after(first);before(second);--;after(second);--;done;" + if (result != expected + expected) return "fail: $result" + + return "OK" +} + +interface I { + suspend fun foo(x: String = "first") +} + +object O : I { + override suspend fun foo(x: String) { + result += "before($x);" + sleep() + result += "after($x);" + } +} + +suspend fun sleep(): Unit = suspendCoroutine { c -> + proceed = { c.resume(Unit) } +} + +fun async(f: suspend () -> Unit) { + f.startCoroutine(object : Continuation { + override fun resume(x: Unit) { + proceed = { + result += "done;" + finished = true + } + } + override fun resumeWithException(x: Throwable) {} + override val context = EmptyCoroutineContext + }) +} + +fun asyncSuspend(f: suspend () -> Unit) { + val coroutine = f.createCoroutine(object : Continuation { + override fun resume(x: Unit) { + proceed = { + result += "done;" + finished = true + } + } + override fun resumeWithException(x: Throwable) {} + override val context = EmptyCoroutineContext + }) + coroutine.resume(Unit) +} + +var result = "" +var proceed: () -> Unit = { } +var finished = false \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/coroutines/recursiveSuspend.kt b/backend.native/tests/external/codegen/box/coroutines/recursiveSuspend.kt new file mode 100644 index 00000000000..099cbb57781 --- /dev/null +++ b/backend.native/tests/external/codegen/box/coroutines/recursiveSuspend.kt @@ -0,0 +1,42 @@ +// IGNORE_BACKEND: NATIVE +// WITH_RUNTIME +// WITH_COROUTINES +import kotlin.coroutines.experimental.* +import kotlin.coroutines.experimental.intrinsics.* + +fun box(): String { + var result = 0 + + builder { + result = factorial(4) + } + + while (postponed != null) { + postponed!!() + } + + if (result != 24) return "fail1: $result" + if (log != "1;1;2;6;24;") return "fail2: $log" + + return "OK" +} + +suspend fun factorial(a: Int): Int = if (a > 0) suspendHere(factorial(a - 1) * a) else suspendHere(1) + +suspend fun suspendHere(value: Int): Int = suspendCoroutineOrReturn { x -> + postponed = { + log += "$value;" + x.resume(value) + } + COROUTINE_SUSPENDED +} + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(handleResultContinuation { + postponed = null + }) +} + +var postponed: (() -> Unit)? = { } + +var log = "" \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/coroutines/suspendCoroutineFromStateMachine.kt b/backend.native/tests/external/codegen/box/coroutines/suspendCoroutineFromStateMachine.kt new file mode 100644 index 00000000000..650eb832356 --- /dev/null +++ b/backend.native/tests/external/codegen/box/coroutines/suspendCoroutineFromStateMachine.kt @@ -0,0 +1,48 @@ +// IGNORE_BACKEND: NATIVE +// WITH_RUNTIME +// WITH_COROUTINES +import kotlin.coroutines.experimental.* +import kotlin.coroutines.experimental.intrinsics.suspendCoroutineOrReturn +import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED + +fun box(): String { + async { + log += "1;" + wait() + log += "2;" + } + + while (postponed != null) { + log += "suspended;" + postponed!!() + } + + if (log != "1;wait2;suspended;wait;suspended;2;") return "fail: $log" + + return "OK" +} + +fun async(f: suspend () -> Unit) { + f.startCoroutine(handleResultContinuation { + postponed = null + }) +} + +suspend fun wait(): Unit { + wait2() + log += "wait;" + return suspendCoroutineOrReturn { c -> + postponed = { c.resume(Unit) } + COROUTINE_SUSPENDED + } +} + +suspend fun wait2(): Unit = suspendCoroutineOrReturn { c -> + log += "wait2;" + postponed = { c.resume(Unit) } + COROUTINE_SUSPENDED +} + +var postponed: (() -> Unit)? = { } + +var log = "" \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/coroutines/suspendFunctionAsCoroutine/dispatchResume.kt b/backend.native/tests/external/codegen/box/coroutines/suspendFunctionAsCoroutine/dispatchResume.kt index 46a70de7856..0037fcda1dc 100644 --- a/backend.native/tests/external/codegen/box/coroutines/suspendFunctionAsCoroutine/dispatchResume.kt +++ b/backend.native/tests/external/codegen/box/coroutines/suspendFunctionAsCoroutine/dispatchResume.kt @@ -1,4 +1,4 @@ -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: NATIVE // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.experimental.* diff --git a/backend.native/tests/external/codegen/box/coroutines/tailOperations/tailInlining.kt b/backend.native/tests/external/codegen/box/coroutines/tailOperations/tailInlining.kt new file mode 100644 index 00000000000..ac9cce596d1 --- /dev/null +++ b/backend.native/tests/external/codegen/box/coroutines/tailOperations/tailInlining.kt @@ -0,0 +1,53 @@ +// IGNORE_BACKEND: NATIVE +// WITH_RUNTIME +// WITH_COROUTINES +import kotlin.coroutines.experimental.* + +fun box(): String { + async { + val a = foo(23) + log(a) + val b = foo(42) + log(b) + } + while (!finished) { + log("--") + proceed() + } + + if (result != "suspend:23;--;23;suspend:42;--;42;--;done;") return "fail: $result" + + return "OK" +} + +var result = "" + +fun log(message: Any) { + result += "$message;" +} + +var proceed: () -> Unit = { } +var finished = false + +suspend fun bar(x: Int): Int = suspendCoroutine { c -> + log("suspend:$x") + proceed = { c.resume(x) } +} + +inline suspend fun foo(x: Int) = bar(x) + +fun async(a: suspend () -> Unit) { + a.startCoroutine(object : Continuation { + override fun resume(value: Unit) { + proceed = { + log("done") + finished = true + } + } + + override fun resumeWithException(e: Throwable) { + } + + override val context = EmptyCoroutineContext + }) +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/dataClasses/copy/withSecondaryConstructor.kt b/backend.native/tests/external/codegen/box/dataClasses/copy/withSecondaryConstructor.kt new file mode 100644 index 00000000000..f997cea7708 --- /dev/null +++ b/backend.native/tests/external/codegen/box/dataClasses/copy/withSecondaryConstructor.kt @@ -0,0 +1,9 @@ +data class A(val o: String, val k: String) { + constructor() : this("O", "k") +} + +fun box(): String { + val a = A().copy(k = "K") + return a.o + a.k +} + diff --git a/backend.native/tests/external/codegen/box/delegatedProperty/getDelegateWithoutReflection.kt b/backend.native/tests/external/codegen/box/delegatedProperty/getDelegateWithoutReflection.kt index 5e8026a79a0..d897d52b0b4 100644 --- a/backend.native/tests/external/codegen/box/delegatedProperty/getDelegateWithoutReflection.kt +++ b/backend.native/tests/external/codegen/box/delegatedProperty/getDelegateWithoutReflection.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JS +// IGNORE_BACKEND: NATIVE // No kotlin-reflect.jar in this test // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/enum/enumCompanionInit.kt b/backend.native/tests/external/codegen/box/enum/enumCompanionInit.kt new file mode 100644 index 00000000000..e45b666ec6f --- /dev/null +++ b/backend.native/tests/external/codegen/box/enum/enumCompanionInit.kt @@ -0,0 +1,46 @@ +var result = "" + +enum class E(a: String) { + X("x"), + Y("y"); + + init { + result += "E.init($a);" + } + + companion object { + init { + result += "E.companion.init;" + val value = E.values()[0].name + result += "$value;" + } + } +} + +enum class F(a: String) { + X("x"), + Y("y"); + + init { + result += "F.init($a);" + } + + companion object { + init { + result += "F.companion.init;" + } + + fun foo() { + result += "F.foo();$X;" + } + } +} + +fun box(): String { + val y = E.Y + result += "${y.name};" + F.foo() + if (result != "E.init(x);E.init(y);E.companion.init;X;Y;F.init(x);F.init(y);F.companion.init;F.foo();X;") return "fail: $result" + + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/fullJdk/regressions/kt1770.kt b/backend.native/tests/external/codegen/box/fullJdk/regressions/kt1770.kt index aceeec091bb..be5c7263878 100644 --- a/backend.native/tests/external/codegen/box/fullJdk/regressions/kt1770.kt +++ b/backend.native/tests/external/codegen/box/fullJdk/regressions/kt1770.kt @@ -2,21 +2,16 @@ // IGNORE_BACKEND: JS, NATIVE // FULL_JDK +// WITH_RUNTIME +//This front-end problem test added to box ones only cause of FULL_JDK support import org.w3c.dom.Element -import org.xml.sax.InputSource -import javax.xml.parsers.DocumentBuilderFactory -import java.io.StringReader class MyElement(e: Element): Element by e { fun bar() = "OK" } fun box() : String { - val factory = DocumentBuilderFactory.newInstance()!!; - val builder = factory.newDocumentBuilder()!!; - val source = InputSource(StringReader("")); - val doc = builder.parse(source)!!; - val myElement = MyElement(doc.getDocumentElement()!!) - return myElement.getTagName()!! + val touch = MyElement::class.java + return "OK" } diff --git a/backend.native/tests/external/codegen/box/ieee754/safeCall.kt b/backend.native/tests/external/codegen/box/ieee754/safeCall.kt index 06160ead6c5..5133ddaef43 100644 --- a/backend.native/tests/external/codegen/box/ieee754/safeCall.kt +++ b/backend.native/tests/external/codegen/box/ieee754/safeCall.kt @@ -2,6 +2,9 @@ fun box(): String { val plusZero: Double? = 0.0 val minusZero: Double = -0.0 + + useBoxed(plusZero) + if (plusZero?.equals(minusZero) ?: null!!) { return "fail 1" } @@ -11,4 +14,6 @@ fun box(): String { } return "OK" -} \ No newline at end of file +} + +fun useBoxed(a: Any?) {} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/labels/controlLabelClashesWithFuncitonName.kt b/backend.native/tests/external/codegen/box/labels/controlLabelClashesWithFuncitonName.kt new file mode 100644 index 00000000000..ae2f251cc2c --- /dev/null +++ b/backend.native/tests/external/codegen/box/labels/controlLabelClashesWithFuncitonName.kt @@ -0,0 +1,22 @@ +fun test1(): Boolean { + test1@ for(i in 1..2) { + continue@test1 + return false + } + + return true +} + +fun test2(): Boolean { + test2@ while (true) { + break@test2 + } + + return true +} + +fun box(): String { + if (!test1()) return "fail test1" + if (!test2()) return "fail test2" + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/labels/infixCallLabelling.kt b/backend.native/tests/external/codegen/box/labels/infixCallLabelling.kt new file mode 100644 index 00000000000..720f0cf5f70 --- /dev/null +++ b/backend.native/tests/external/codegen/box/labels/infixCallLabelling.kt @@ -0,0 +1,24 @@ +fun test(x: Int): Int { + x myMap { + return@myMap + } + + return 0 +} + +fun myMap(x: Int): Int { + x myMap { + return@myMap + } + + return 0 +} + +infix fun Int.myMap(x: () -> Unit) {} + +fun box(): String { + test(0) + myMap(0) + + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/localFunctions/parameterAsDefaultValue.kt b/backend.native/tests/external/codegen/box/localFunctions/parameterAsDefaultValue.kt new file mode 100644 index 00000000000..e90fe97fede --- /dev/null +++ b/backend.native/tests/external/codegen/box/localFunctions/parameterAsDefaultValue.kt @@ -0,0 +1,11 @@ +fun foo(): String { + fun bar(x: String, y: String = x): String { + return y + } + + return bar("OK") +} + +fun box(): String { + return foo() +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/multiDecl/UnderscoreNames.kt b/backend.native/tests/external/codegen/box/multiDecl/UnderscoreNames.kt index 12dfc941fb6..3d38c505f6a 100644 --- a/backend.native/tests/external/codegen/box/multiDecl/UnderscoreNames.kt +++ b/backend.native/tests/external/codegen/box/multiDecl/UnderscoreNames.kt @@ -10,5 +10,5 @@ fun box() : String { val (`_`, c) = A() - return if (a == 1 && b == 2 && _ == 1 && c == 2) "OK" else "fail" + return if (a == 1 && b == 2 && `_` == 1 && c == 2) "OK" else "fail" } diff --git a/backend.native/tests/external/codegen/box/multiDecl/forRange/UnderscoreNames.kt b/backend.native/tests/external/codegen/box/multiDecl/forRange/UnderscoreNames.kt index ff9d07f1f46..9139c8cd549 100644 --- a/backend.native/tests/external/codegen/box/multiDecl/forRange/UnderscoreNames.kt +++ b/backend.native/tests/external/codegen/box/multiDecl/forRange/UnderscoreNames.kt @@ -31,7 +31,7 @@ fun doTest(): String { } for ((_, `_`) in C(2)..C(4)) { - s += "$_;" + s += "$`_`;" } return s diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToFun.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToFun.kt index 8ca3d4a6111..d145418ecd8 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToFun.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToFun.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToInternalValInline.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToInternalValInline.kt index 40ecbe291ec..336a84e7a87 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToInternalValInline.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToInternalValInline.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToPrivateVal.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToPrivateVal.kt index 2508df7124f..a9784f16796 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToPrivateVal.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToPrivateVal.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToVal.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToVal.kt index 97ac95dc8e3..bd037033d92 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToVal.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/callableRefToVal.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/calls.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/calls.kt index cc6e1229fb0..a142522a53d 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/calls.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/calls.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: Baz.java diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/deferredStaticInitialization.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/deferredStaticInitialization.kt index 4e1bb13453b..8316d0390f6 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/deferredStaticInitialization.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/deferredStaticInitialization.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/delegatedVal.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/delegatedVal.kt index 0cb65cbb05b..21b17c432ba 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/delegatedVal.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/delegatedVal.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/initializePrivateVal.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/initializePrivateVal.kt index e0b5cd48c21..601c1929f2c 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/initializePrivateVal.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/initializePrivateVal.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/initializePublicVal.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/initializePublicVal.kt index 17dbf683865..94d55afdad7 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/initializePublicVal.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/initializePublicVal.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/overlappingFuns.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/overlappingFuns.kt index 1265f6b8069..e2c9f9d6770 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/overlappingFuns.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/overlappingFuns.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/overlappingVals.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/overlappingVals.kt index 877336e30b7..3c94dafbbf4 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/overlappingVals.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/overlappingVals.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/valAccessFromInlineFunCalledFromJava.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/valAccessFromInlineFunCalledFromJava.kt index dd69ed228d3..86c3c944093 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/valAccessFromInlineFunCalledFromJava.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/valAccessFromInlineFunCalledFromJava.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/valAccessFromInlinedToDifferentPackage.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/valAccessFromInlinedToDifferentPackage.kt index ca6abf2a25a..49194fc6205 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/valAccessFromInlinedToDifferentPackage.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/valAccessFromInlinedToDifferentPackage.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/multifileClasses/optimized/valWithAccessor.kt b/backend.native/tests/external/codegen/box/multifileClasses/optimized/valWithAccessor.kt index 3fe62893d0f..e47c2a619c8 100644 --- a/backend.native/tests/external/codegen/box/multifileClasses/optimized/valWithAccessor.kt +++ b/backend.native/tests/external/codegen/box/multifileClasses/optimized/valWithAccessor.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS // WITH_RUNTIME // KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS // FILE: box.kt diff --git a/backend.native/tests/external/codegen/box/nonLocalReturns/localReturnInsideProperty.kt b/backend.native/tests/external/codegen/box/nonLocalReturns/localReturnInsideProperty.kt new file mode 100644 index 00000000000..7808b367f3e --- /dev/null +++ b/backend.native/tests/external/codegen/box/nonLocalReturns/localReturnInsideProperty.kt @@ -0,0 +1,13 @@ +interface ClassData + +fun f() = object : ClassData { + val someInt: Int + get() { + return 5 + } +} + +fun box(): String{ + f() + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/nullCheckOptimization/isNullable.kt b/backend.native/tests/external/codegen/box/nullCheckOptimization/isNullable.kt new file mode 100644 index 00000000000..750f01972a0 --- /dev/null +++ b/backend.native/tests/external/codegen/box/nullCheckOptimization/isNullable.kt @@ -0,0 +1,4 @@ +inline fun isNullable() = null is T + +fun box(): String = + if (isNullable()) "OK" else "Fail" \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/nullCheckOptimization/kt7774.kt b/backend.native/tests/external/codegen/box/nullCheckOptimization/kt7774.kt new file mode 100644 index 00000000000..ce35467e7d7 --- /dev/null +++ b/backend.native/tests/external/codegen/box/nullCheckOptimization/kt7774.kt @@ -0,0 +1,12 @@ +var flag = false + +inline fun foo(c: String? = null) { + if (c != null) { + flag = true + } +} + +fun box(): String { + foo() + return if (flag) "fail" else "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/objects/anonymousObjectReturnsFromTopLevelFun.kt b/backend.native/tests/external/codegen/box/objects/anonymousObjectReturnsFromTopLevelFun.kt new file mode 100644 index 00000000000..c2f14068bfe --- /dev/null +++ b/backend.native/tests/external/codegen/box/objects/anonymousObjectReturnsFromTopLevelFun.kt @@ -0,0 +1,22 @@ +interface IFoo { + fun foo(): String +} + +interface IBar + +private fun createAnonObject() = + object : IFoo, IBar { + override fun foo() = "foo" + fun qux(): String = "qux" + } + +fun useAnonObject() { + createAnonObject().foo() + createAnonObject().qux() +} + +fun box(): String { + if (createAnonObject().foo() != "foo") return "fail 1" + if (createAnonObject().qux() != "qux") return "fail 2" + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/package/privateMembersInImportList.kt b/backend.native/tests/external/codegen/box/package/privateMembersInImportList.kt new file mode 100644 index 00000000000..e7009753efa --- /dev/null +++ b/backend.native/tests/external/codegen/box/package/privateMembersInImportList.kt @@ -0,0 +1,40 @@ +package test + +import test.C.E1 +import test.A.B.* +import test.Obj.CInObj.Tt +import test.Obj.foo + +private enum class C { + E1 +} + +class A { + private class B { + object C + class D + } + + fun test() { + C + D() + } +} + +private object Obj { + private class CInObj { + class Tt + } + + fun foo() { + Tt() + } +} + +fun box(): String { + E1 + A().test() + foo() + + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/publishedApi/noMangling.kt b/backend.native/tests/external/codegen/box/publishedApi/noMangling.kt index 6247ebb880b..8ecfb8a8c04 100644 --- a/backend.native/tests/external/codegen/box/publishedApi/noMangling.kt +++ b/backend.native/tests/external/codegen/box/publishedApi/noMangling.kt @@ -2,14 +2,18 @@ //WITH_REFLECT class A { @PublishedApi - internal fun published() = "OK" + internal fun published() = "O" - inline fun test() = published() + @PublishedApi + internal var publishedProp = "K" + inline fun test() = published() + publishedProp } fun box() : String { val clazz = A::class.java - if (clazz.getDeclaredMethod("published") == null) return "fail" - return "OK" + if (clazz.getDeclaredMethod("published") == null) return "fail 1" + if (clazz.getDeclaredMethod("getPublishedProp") == null) return "fail 2" + if (clazz.getDeclaredMethod("setPublishedProp", String::class.java) == null) return "fail 3" + return A().test() } diff --git a/backend.native/tests/external/codegen/box/ranges/expression/inexactDownToMinValue.kt b/backend.native/tests/external/codegen/box/ranges/expression/inexactDownToMinValue.kt index e0fd14c2983..cd4f47398a1 100644 --- a/backend.native/tests/external/codegen/box/ranges/expression/inexactDownToMinValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/expression/inexactDownToMinValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/expression/inexactToMaxValue.kt b/backend.native/tests/external/codegen/box/ranges/expression/inexactToMaxValue.kt index 74712e4df72..6181201dc99 100644 --- a/backend.native/tests/external/codegen/box/ranges/expression/inexactToMaxValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/expression/inexactToMaxValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/expression/maxValueMinusTwoToMaxValue.kt b/backend.native/tests/external/codegen/box/ranges/expression/maxValueMinusTwoToMaxValue.kt index 0cc89f13224..57ef91abc6b 100644 --- a/backend.native/tests/external/codegen/box/ranges/expression/maxValueMinusTwoToMaxValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/expression/maxValueMinusTwoToMaxValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/expression/maxValueToMaxValue.kt b/backend.native/tests/external/codegen/box/ranges/expression/maxValueToMaxValue.kt index c60b83b3d93..67a34700482 100644 --- a/backend.native/tests/external/codegen/box/ranges/expression/maxValueToMaxValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/expression/maxValueToMaxValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/expression/maxValueToMinValue.kt b/backend.native/tests/external/codegen/box/ranges/expression/maxValueToMinValue.kt index d7e7f98a24a..b636e72842a 100644 --- a/backend.native/tests/external/codegen/box/ranges/expression/maxValueToMinValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/expression/maxValueToMinValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/expression/progressionDownToMinValue.kt b/backend.native/tests/external/codegen/box/ranges/expression/progressionDownToMinValue.kt index 20ef6402572..bda317415de 100644 --- a/backend.native/tests/external/codegen/box/ranges/expression/progressionDownToMinValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/expression/progressionDownToMinValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt b/backend.native/tests/external/codegen/box/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt index cd579903938..3f8621c2fca 100644 --- a/backend.native/tests/external/codegen/box/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/expression/progressionMaxValueToMaxValue.kt b/backend.native/tests/external/codegen/box/ranges/expression/progressionMaxValueToMaxValue.kt index 691b83d6f48..48a8af62402 100644 --- a/backend.native/tests/external/codegen/box/ranges/expression/progressionMaxValueToMaxValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/expression/progressionMaxValueToMaxValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/expression/progressionMaxValueToMinValue.kt b/backend.native/tests/external/codegen/box/ranges/expression/progressionMaxValueToMinValue.kt index 1083ef991a2..86eb6031690 100644 --- a/backend.native/tests/external/codegen/box/ranges/expression/progressionMaxValueToMinValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/expression/progressionMaxValueToMinValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/expression/progressionMinValueToMinValue.kt b/backend.native/tests/external/codegen/box/ranges/expression/progressionMinValueToMinValue.kt index c85495c3743..fee9a5f92c7 100644 --- a/backend.native/tests/external/codegen/box/ranges/expression/progressionMinValueToMinValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/expression/progressionMinValueToMinValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/forInIndices/kt13241_Array.kt b/backend.native/tests/external/codegen/box/ranges/forInIndices/kt13241_Array.kt index fdabe3cc1e6..47b299b9a5c 100644 --- a/backend.native/tests/external/codegen/box/ranges/forInIndices/kt13241_Array.kt +++ b/backend.native/tests/external/codegen/box/ranges/forInIndices/kt13241_Array.kt @@ -13,6 +13,9 @@ fun test(x: Any): Int { } fun box(): String { + // Only run this test if primitive array `is` checks work (KT-17137) + if ((intArrayOf() as Any) is Array<*>) return "OK" + assertEquals(123, test(intArrayOf(0, 0, 0, 0))) return "OK" } \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/ranges/literal/inexactDownToMinValue.kt b/backend.native/tests/external/codegen/box/ranges/literal/inexactDownToMinValue.kt index a66daa50878..72d497bb477 100644 --- a/backend.native/tests/external/codegen/box/ranges/literal/inexactDownToMinValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/literal/inexactDownToMinValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/literal/inexactToMaxValue.kt b/backend.native/tests/external/codegen/box/ranges/literal/inexactToMaxValue.kt index a55c76920aa..9de5402fe11 100644 --- a/backend.native/tests/external/codegen/box/ranges/literal/inexactToMaxValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/literal/inexactToMaxValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/literal/maxValueMinusTwoToMaxValue.kt b/backend.native/tests/external/codegen/box/ranges/literal/maxValueMinusTwoToMaxValue.kt index 1c76fabe3cc..dabb4b7eec1 100644 --- a/backend.native/tests/external/codegen/box/ranges/literal/maxValueMinusTwoToMaxValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/literal/maxValueMinusTwoToMaxValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/literal/maxValueToMaxValue.kt b/backend.native/tests/external/codegen/box/ranges/literal/maxValueToMaxValue.kt index cdedbbb8c7b..5c174a24557 100644 --- a/backend.native/tests/external/codegen/box/ranges/literal/maxValueToMaxValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/literal/maxValueToMaxValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/literal/maxValueToMinValue.kt b/backend.native/tests/external/codegen/box/ranges/literal/maxValueToMinValue.kt index 2439eab980c..bfb2f4c0d39 100644 --- a/backend.native/tests/external/codegen/box/ranges/literal/maxValueToMinValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/literal/maxValueToMinValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/literal/progressionDownToMinValue.kt b/backend.native/tests/external/codegen/box/ranges/literal/progressionDownToMinValue.kt index fccb2044c9f..a62ca845133 100644 --- a/backend.native/tests/external/codegen/box/ranges/literal/progressionDownToMinValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/literal/progressionDownToMinValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt b/backend.native/tests/external/codegen/box/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt index 7c81034ef7a..ed239fc2925 100644 --- a/backend.native/tests/external/codegen/box/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/literal/progressionMaxValueToMaxValue.kt b/backend.native/tests/external/codegen/box/ranges/literal/progressionMaxValueToMaxValue.kt index 4c4555326fc..af2334ee40b 100644 --- a/backend.native/tests/external/codegen/box/ranges/literal/progressionMaxValueToMaxValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/literal/progressionMaxValueToMaxValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/literal/progressionMaxValueToMinValue.kt b/backend.native/tests/external/codegen/box/ranges/literal/progressionMaxValueToMinValue.kt index cd29a83cb6f..7a8a189025d 100644 --- a/backend.native/tests/external/codegen/box/ranges/literal/progressionMaxValueToMinValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/literal/progressionMaxValueToMinValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/ranges/literal/progressionMinValueToMinValue.kt b/backend.native/tests/external/codegen/box/ranges/literal/progressionMinValueToMinValue.kt index f0b5a5a9041..b0f74526ec6 100644 --- a/backend.native/tests/external/codegen/box/ranges/literal/progressionMinValueToMinValue.kt +++ b/backend.native/tests/external/codegen/box/ranges/literal/progressionMinValueToMinValue.kt @@ -1,5 +1,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS + +// TODO: muted automatically, investigate should it be ran for NATIVE or not +// IGNORE_BACKEND: NATIVE // Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! // WITH_RUNTIME diff --git a/backend.native/tests/external/codegen/box/reflection/classes/nestedClasses.kt b/backend.native/tests/external/codegen/box/reflection/classes/nestedClasses.kt index ee73af820f8..603c4b0433b 100644 --- a/backend.native/tests/external/codegen/box/reflection/classes/nestedClasses.kt +++ b/backend.native/tests/external/codegen/box/reflection/classes/nestedClasses.kt @@ -25,8 +25,10 @@ fun box(): String { // Java class without nested classes assertEquals(emptyList(), nestedNames(Error::class)) + // Java interface with nested classes + assertEquals(listOf("Entry"), nestedNames(java.util.Map::class)) // Java class with nested classes - assertEquals(listOf("State", "UncaughtExceptionHandler"), nestedNames(Thread::class)) + assertEquals(listOf("SimpleEntry", "SimpleImmutableEntry"), nestedNames(java.util.AbstractMap::class)) // Built-ins assertEquals(emptyList(), nestedNames(Array::class)) diff --git a/backend.native/tests/external/codegen/box/reflection/parameters/javaParametersHaveNoNames.kt b/backend.native/tests/external/codegen/box/reflection/parameters/javaParametersHaveNoNames.kt deleted file mode 100644 index 0ae71fbf586..00000000000 --- a/backend.native/tests/external/codegen/box/reflection/parameters/javaParametersHaveNoNames.kt +++ /dev/null @@ -1,22 +0,0 @@ -// TODO: muted automatically, investigate should it be ran for JS or not -// IGNORE_BACKEND: JS, NATIVE - -// WITH_REFLECT -// FILE: J.java - -public class J { - void foo(String s, int i) {} - - static void bar(J j) {} -} - -// FILE: K.kt - -import kotlin.test.assertEquals - -fun box(): String { - assertEquals(listOf(null, null, null), J::foo.parameters.map { it.name }) - assertEquals(listOf(null), J::bar.parameters.map { it.name }) - - return "OK" -} diff --git a/backend.native/tests/external/codegen/box/reflection/specialBuiltIns/getMembersOfStandardJavaClasses.kt b/backend.native/tests/external/codegen/box/reflection/specialBuiltIns/getMembersOfStandardJavaClasses.kt index d1ae9ba0f8d..0927f54846d 100644 --- a/backend.native/tests/external/codegen/box/reflection/specialBuiltIns/getMembersOfStandardJavaClasses.kt +++ b/backend.native/tests/external/codegen/box/reflection/specialBuiltIns/getMembersOfStandardJavaClasses.kt @@ -5,6 +5,9 @@ // FULL_JDK // See KT-11258 Incorrect resolution sequence for Java field +// TODO: enable this test on JVM, see KT-16616 +// IGNORE_BACKEND_WITHOUT_CHECK: JVM + import java.util.* fun box(): String { diff --git a/backend.native/tests/external/codegen/box/regressions/kt6485.kt b/backend.native/tests/external/codegen/box/regressions/kt6485.kt index 01977c6cf72..563ed276949 100644 --- a/backend.native/tests/external/codegen/box/regressions/kt6485.kt +++ b/backend.native/tests/external/codegen/box/regressions/kt6485.kt @@ -16,10 +16,10 @@ open class TypeLiteral { inline fun typeLiteral(): TypeLiteral = object : TypeLiteral() {} fun box(): String { - assertEquals("class java.lang.String", typeLiteral().type.toString()) + assertEquals("java.lang.String", (typeLiteral().type as Class<*>).canonicalName) assertEquals("java.util.List", typeLiteral>().type.toString()) - assertEquals("java.lang.String[]", typeLiteral>().type.toString()) - assertEquals("java.lang.Integer[]", typeLiteral>().type.toString()) - assertEquals("java.lang.String[][]", typeLiteral>>().type.toString()) + assertEquals("java.lang.String[]", (typeLiteral>().type as Class<*>).canonicalName) + assertEquals("java.lang.Integer[]", (typeLiteral>().type as Class<*>).canonicalName) + assertEquals("java.lang.String[][]", (typeLiteral>>().type as Class<*>).canonicalName) return "OK" -} +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/box/smap/simpleCallWithParams.kt b/backend.native/tests/external/codegen/box/smap/simpleCallWithParams.kt index 8c0830bc26e..473fa927e1b 100644 --- a/backend.native/tests/external/codegen/box/smap/simpleCallWithParams.kt +++ b/backend.native/tests/external/codegen/box/smap/simpleCallWithParams.kt @@ -5,8 +5,8 @@ package test fun testProperLineNumberAfterInline(): String { var exceptionCount = 0; try { - checkEquals(test(), - "12") + fail(inlineFun(), + "12") } catch(e: AssertionError) { val entry = (e as java.lang.Throwable).getStackTrace()!!.get(1) @@ -18,8 +18,8 @@ fun testProperLineNumberAfterInline(): String { } try { - checkEquals("12", - test()) + fail("12", + inlineFun()) } catch(e: AssertionError) { val entry = e.stackTrace!![1] @@ -36,13 +36,13 @@ fun testProperLineNumberAfterInline(): String { fun testProperLineForOtherParameters(): String { var exceptionCount = 0; try { - checkEquals(test(), - fail()) + fail(inlineFun(), + fail()) } catch(e: AssertionError) { val entry = e.stackTrace!![1] val actual = "${entry.getFileName()}:${entry.getLineNumber()}" - if ("simpleCallWithParams.kt:39" != actual) { + if ("simpleCallWithParams.kt:40" != actual) { return "fail 3: ${actual}" } exceptionCount++ @@ -50,8 +50,8 @@ fun testProperLineForOtherParameters(): String { } try { - checkEquals(fail(), - test()) + fail(fail(), + inlineFun()) } catch(e: AssertionError) { val entry = e.stackTrace!![1] @@ -63,7 +63,7 @@ fun testProperLineForOtherParameters(): String { } try { - checkEquals(fail(), test()) + fail(fail(), inlineFun()) } catch(e: AssertionError) { val entry = e.stackTrace!![1] @@ -75,7 +75,7 @@ fun testProperLineForOtherParameters(): String { } try { - checkEquals(fail(), test()) + fail(fail(), inlineFun()) } catch(e: AssertionError) { val entry = e.stackTrace!![1] @@ -97,11 +97,11 @@ fun box(): String { return testProperLineForOtherParameters() } -public fun checkEquals(p1: String, p2: String) { +public fun fail(p1: String, p2: String) { throw AssertionError("fail") } -inline fun test(): String { +inline fun inlineFun(): String { return "123" } diff --git a/backend.native/tests/external/codegen/box/toArray/toArrayShouldBePublicWithJava.kt b/backend.native/tests/external/codegen/box/toArray/toArrayShouldBePublicWithJava.kt index 097d62f3907..8e170ae174a 100644 --- a/backend.native/tests/external/codegen/box/toArray/toArrayShouldBePublicWithJava.kt +++ b/backend.native/tests/external/codegen/box/toArray/toArrayShouldBePublicWithJava.kt @@ -1,5 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME +// IGNORE_LIGHT_ANALYSIS // FILE: SingletonCollection.kt package test diff --git a/backend.native/tests/external/codegen/boxInline/nonLocalReturns/tryFinally/nonLocalReturnFromCatchBlock.kt b/backend.native/tests/external/codegen/boxInline/nonLocalReturns/tryFinally/nonLocalReturnFromCatchBlock.kt new file mode 100644 index 00000000000..240ec77b316 --- /dev/null +++ b/backend.native/tests/external/codegen/boxInline/nonLocalReturns/tryFinally/nonLocalReturnFromCatchBlock.kt @@ -0,0 +1,54 @@ +// MODULE: lib +// FILE: lib.kt + +package utils + +inline fun foo(a: Int) { + bar(a) +} + +inline fun bar(a: Int) { + try { + if (a > 0) throw Exception() + log("foo($a) #1") + } + catch (e: Exception) { + myRun { + log("foo($a) #2") + if (a > 1) return + log("foo($a) #3") + } + } + log("foo($a) #4") +} + +var LOG: String = "" + +fun log(s: String): String { + LOG += s + ";" + return LOG +} + +inline fun myRun(f: () -> Unit) = f() + + +// MODULE: main(lib) +// FILE: main.kt + +import utils.* + +fun box(): String { + foo(0) + if (LOG != "foo(0) #1;foo(0) #4;") return "fail1: $LOG" + LOG = "" + + foo(1) + if (LOG != "foo(1) #2;foo(1) #3;foo(1) #4;") return "fail2: $LOG" + LOG = "" + + foo(2) + if (LOG != "foo(2) #2;") return "fail3: $LOG" + LOG = "" + + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/boxInline/nonLocalReturns/tryFinally/nonLocalReturnToCatchBlock.kt b/backend.native/tests/external/codegen/boxInline/nonLocalReturns/tryFinally/nonLocalReturnToCatchBlock.kt new file mode 100644 index 00000000000..319213c08c8 --- /dev/null +++ b/backend.native/tests/external/codegen/boxInline/nonLocalReturns/tryFinally/nonLocalReturnToCatchBlock.kt @@ -0,0 +1,51 @@ +// MODULE: lib +// FILE: lib.kt + +package utils + +inline fun foo(a: Int) { + try { + if (a > 0) throw Exception() + log("foo($a)") + } + catch (e: Exception) { + bar(a) + } +} + +inline fun bar(a: Int) { + myRun { + log("bar($a) #1") + if (a == 2) return + log("bar($a) #2") + } +} + +var LOG: String = "" + +fun log(s: String): String { + LOG += s + ";" + return LOG +} + +inline fun myRun(f: () -> Unit) = f() + +// MODULE: main(lib) +// FILE: main.kt + +import utils.* + +fun box(): String { + foo(0) + if (LOG != "foo(0);") return "fail1: $LOG" + LOG = "" + + foo(1) + if (LOG != "bar(1) #1;bar(1) #2;") return "fail2: $LOG" + LOG = "" + + foo(2) + if (LOG != "bar(2) #1;") return "fail3: $LOG" + + return "OK" +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/boxInline/reified/kt15997.kt b/backend.native/tests/external/codegen/boxInline/reified/kt15997.kt new file mode 100644 index 00000000000..ec3b3ce6ec6 --- /dev/null +++ b/backend.native/tests/external/codegen/boxInline/reified/kt15997.kt @@ -0,0 +1,27 @@ +// FILE: 1.kt +// FULL_JDK +// WITH_REFLECT +package test + +import kotlin.properties.Delegates +import kotlin.properties.ReadWriteProperty + +var result = "fail" + +inline fun crashMe(): ReadWriteProperty { + return Delegates.observable(Unit, { a, b, c -> result = T::class.java.simpleName }) +} + + +// FILE: 2.kt +import test.* + + +class OK { + var value by crashMe() +} + +fun box(): String { + OK().value = Unit + return result +} \ No newline at end of file diff --git a/backend.native/tests/external/codegen/boxInline/reified/kt15997_2.kt b/backend.native/tests/external/codegen/boxInline/reified/kt15997_2.kt new file mode 100644 index 00000000000..e953b847f29 --- /dev/null +++ b/backend.native/tests/external/codegen/boxInline/reified/kt15997_2.kt @@ -0,0 +1,36 @@ +// FILE: 1.kt +// FULL_JDK +// WITH_REFLECT +package test + +import kotlin.properties.Delegates +import kotlin.properties.ReadWriteProperty +import kotlin.properties.ObservableProperty +import kotlin.reflect.KProperty + +var result = "fail" + +public inline fun myObservable(initialValue: T, crossinline onChange: (property: KProperty<*>, oldValue: T, newValue: T) -> Unit): + ReadWriteProperty = object : ObservableProperty(initialValue) { + override fun afterChange(property: KProperty<*>, oldValue: T, newValue: T) = onChange(property, oldValue, newValue) +} + + +//samely named reified parameter (T) as in myObservable +inline fun crashMe(): ReadWriteProperty { + return myObservable(Unit, { a, b, c -> result = T::class.java.simpleName }) +} + + +// FILE: 2.kt +import test.* + + +class OK { + var value by crashMe() +} + +fun box(): String { + OK().value = Unit + return result +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index fabf97b46ab..7e22afdd4ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,6 +20,6 @@ minMacOsVersion = 10.11 remoteRoot=konan_tests #kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-SNAPSHOT # Download artifacts of https://teamcity.jetbrains.com/viewType.html?buildTypeId=bt345 -testDataVersion=1009012:id +testDataVersion=1050294:id kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-20170424.172927-491 konanVersion=0.1