backend/tests: Add blackbox tests from Kotlin JVM
Added tests from testData/codegen/box directory. There are blackbox tests in other directories and they are to be added.
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
|
||||
fun <R> foo(f: () -> R): R = f()
|
||||
|
||||
fun <T : Any> some(v: T?, b: T): T {
|
||||
return foo {
|
||||
if (v != null) {
|
||||
v
|
||||
}
|
||||
else {
|
||||
b
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Any> some1(v: T?, b: T): T {
|
||||
return foo { if (v != null) v else b }
|
||||
}
|
||||
|
||||
fun box() = when {
|
||||
some(1, 2) != 1 -> "fail 1"
|
||||
some(null, 2) != 2 -> "fail 2"
|
||||
some1(1, 2) != 1 -> "fail 3"
|
||||
else -> "OK"
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public fun </*0*/ R> foo(/*0*/ f: () -> R): R
|
||||
public fun </*0*/ T : kotlin.Any> some(/*0*/ v: T?, /*1*/ b: T): T
|
||||
public fun </*0*/ T : kotlin.Any> some1(/*0*/ v: T?, /*1*/ b: T): T
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class A {
|
||||
companion object {
|
||||
operator fun invoke(i: Int) = i
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = if (A(42) == 42) "OK" else "fail"
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final operator fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
interface B
|
||||
|
||||
operator fun B.invoke(i: Int) = i
|
||||
|
||||
class A {
|
||||
companion object: B {
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = if (A(42) == 42) "OK" else "fail"
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public operator fun B.invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public companion object Companion : B {
|
||||
private constructor Companion()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public interface B {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class A {
|
||||
class Nested {
|
||||
companion object {
|
||||
operator fun invoke(i: Int) = i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = if (A.Nested(42) == 42) "OK" else "fail"
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final class Nested {
|
||||
public constructor Nested()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final operator fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import A.Nested
|
||||
|
||||
class A {
|
||||
class Nested {
|
||||
companion object {
|
||||
operator fun invoke(i: Int) = i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = if (Nested(42) == 42) "OK" else "fail"
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final class Nested {
|
||||
public constructor Nested()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final operator fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
enum class A {
|
||||
ONE,
|
||||
TWO;
|
||||
|
||||
operator fun invoke(i: Int) = i
|
||||
}
|
||||
|
||||
fun box() = if (A.ONE(42) == 42) "OK" else "fail"
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
|
||||
public final enum class A : kotlin.Enum<A> {
|
||||
enum entry ONE
|
||||
|
||||
enum entry TWO
|
||||
|
||||
private constructor A()
|
||||
public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<A!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final operator fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<A>
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
enum class A {
|
||||
ONE,
|
||||
TWO
|
||||
}
|
||||
|
||||
operator fun A.invoke(i: Int) = i
|
||||
|
||||
fun box() = if (A.ONE(42) == 42) "OK" else "fail"
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public operator fun A.invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
|
||||
public final enum class A : kotlin.Enum<A> {
|
||||
enum entry ONE
|
||||
|
||||
enum entry TWO
|
||||
|
||||
private constructor A()
|
||||
public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<A!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<A>
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import A.ONE
|
||||
|
||||
enum class A {
|
||||
ONE,
|
||||
TWO;
|
||||
|
||||
operator fun invoke(i: Int) = i
|
||||
}
|
||||
|
||||
fun box() = if (ONE(42) == 42) "OK" else "fail"
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
|
||||
public final enum class A : kotlin.Enum<A> {
|
||||
enum entry ONE
|
||||
|
||||
enum entry TWO
|
||||
|
||||
private constructor A()
|
||||
public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<A!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final operator fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<A>
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import A.ONE
|
||||
|
||||
enum class A {
|
||||
ONE,
|
||||
TWO
|
||||
}
|
||||
|
||||
operator fun A.invoke(i: Int) = i
|
||||
|
||||
fun box() = if (ONE(42) == 42) "OK" else "fail"
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public operator fun A.invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
|
||||
public final enum class A : kotlin.Enum<A> {
|
||||
enum entry ONE
|
||||
|
||||
enum entry TWO
|
||||
|
||||
private constructor A()
|
||||
public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<A!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<A>
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
object A
|
||||
|
||||
operator fun A.invoke(i: Int) = i
|
||||
|
||||
fun box() = if (A(42) == 42) "OK" else "fail"
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public operator fun A.invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
|
||||
public object A {
|
||||
private constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
object A {
|
||||
operator fun invoke(i: Int) = i
|
||||
}
|
||||
|
||||
fun box() = if (A(42) == 42) "OK" else "fail"
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
|
||||
public object A {
|
||||
private constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final operator fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun test(x : Int = 0, e : Any = "a") {
|
||||
if (!e.equals("a")) {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
if (x > 0) {
|
||||
test(x - 1)
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
test(100000)
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ x: kotlin.Int = ..., /*1*/ e: kotlin.Any = ...): kotlin.Unit
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
open class A {
|
||||
open fun foo(s: String = "OK") = s
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
<!NO_TAIL_CALLS_FOUND!>override tailrec fun foo(s: String): String<!> {
|
||||
return if (s == "OK") s else foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = B().foo("FAIL")
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun foo(/*0*/ s: kotlin.String = ...): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B : A {
|
||||
public constructor B()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open tailrec override /*1*/ fun foo(/*0*/ s: kotlin.String = ...): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun Int.foo(x: Int) {
|
||||
if (x == 0) return
|
||||
return 1.foo(x - 1)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
1.foo(1000000)
|
||||
return "OK"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun kotlin.Int.foo(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
<!NO_TAIL_CALLS_FOUND!>tailrec fun noTails()<!> {
|
||||
// nothing here
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
noTails()
|
||||
return "OK"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun noTails(): kotlin.Unit
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun badTails(x : Int) : Int {
|
||||
if (x < 50 && x != 10 && x > 0) {
|
||||
return 1 + <!NON_TAIL_RECURSIVE_CALL!>badTails<!>(x - 1)
|
||||
}
|
||||
else if (x == 10) {
|
||||
@Suppress("NON_TAIL_RECURSIVE_CALL")
|
||||
return 1 + badTails(x - 1)
|
||||
} else if (x >= 50) {
|
||||
return badTails(x - 1)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
badTails(1000000)
|
||||
return "OK"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public tailrec fun badTails(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
public fun box(): kotlin.String
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
fun withoutAnnotation(x : Int) : Int {
|
||||
if (x > 0) {
|
||||
return 1 + withoutAnnotation(x - 1)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val r = withoutAnnotation(10)
|
||||
if (r == 10) return "OK"
|
||||
return "Fail $r"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public fun withoutAnnotation(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec infix fun Int.test(x : Int) : Int {
|
||||
if (this > 1) {
|
||||
return (this - 1) test x
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
fun box() : String = if (1000000.test(1000000) == 1) "OK" else "FAIL"
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public infix tailrec fun kotlin.Int.test(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec infix fun Int.foo(x: Int) {
|
||||
if (x == 0) return
|
||||
val xx = x - 1
|
||||
return 1 foo xx
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
1 foo 1000000
|
||||
return "OK"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public infix tailrec fun kotlin.Int.foo(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun test(counter : Int) : Int? {
|
||||
if (counter < 0) return null
|
||||
if (counter == 0) return 777
|
||||
|
||||
return <!NON_TAIL_RECURSIVE_CALL!>test<!>(-1) ?: <!NON_TAIL_RECURSIVE_CALL!>test<!>(-2) ?: test(counter - 1)
|
||||
}
|
||||
|
||||
fun box() : String =
|
||||
if (test(100000) == 777) "OK"
|
||||
else "FAIL"
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ counter: kotlin.Int): kotlin.Int?
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
class B {
|
||||
inner class C {
|
||||
tailrec fun h(counter : Int) {
|
||||
if (counter > 0) {
|
||||
this@C.h(counter - 1)
|
||||
}
|
||||
}
|
||||
|
||||
<!NO_TAIL_CALLS_FOUND!>tailrec fun h2(x : Any)<!> {
|
||||
this@B.h2("no recursion") // keep vigilance
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun makeC() : C = C()
|
||||
|
||||
fun h2(x : Any) {
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
B().makeC().h(1000000)
|
||||
B().makeC().h2(0)
|
||||
return "OK"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
|
||||
public final class B {
|
||||
public constructor B()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun h2(/*0*/ x: kotlin.Any): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun makeC(): B.C
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final inner class C {
|
||||
public constructor C()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final tailrec fun h(/*0*/ counter: kotlin.Int): kotlin.Unit
|
||||
public final tailrec fun h2(/*0*/ x: kotlin.Any): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun test(x : Int) : Int {
|
||||
var z = if (x > 3) 3 else x
|
||||
while (z > 0) {
|
||||
if (z > 10) {
|
||||
return test(x - 1)
|
||||
}
|
||||
<!NON_TAIL_RECURSIVE_CALL!>test<!>(0)
|
||||
z = z - 1
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
fun box() : String = if (test(100000) == 1) "OK" else "FAIL"
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun test(x : Int) : Int {
|
||||
if (x == 1) {
|
||||
if (x != 1) {
|
||||
<!NON_TAIL_RECURSIVE_CALL!>test<!>(0)
|
||||
return test(0)
|
||||
} else {
|
||||
return test(x + <!NON_TAIL_RECURSIVE_CALL!>test<!>(0))
|
||||
}
|
||||
} else if (x > 0) {
|
||||
return test(x - 1)
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
fun box() : String = if (test(1000000) == -1) "OK" else "FAIL"
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun <T, A> Iterator<T>.foldl(acc : A, foldFunction : (e : T, acc : A) -> A) : A =
|
||||
if (!hasNext()) acc
|
||||
else foldl(foldFunction(next(), acc), foldFunction)
|
||||
|
||||
fun box() : String {
|
||||
val sum = (1..1000000).iterator().foldl(0) { e : Int, acc : Long ->
|
||||
acc + e
|
||||
}
|
||||
|
||||
return if (sum == 500000500000) "OK" else "FAIL: $sum"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun </*0*/ T, /*1*/ A> kotlin.collections.Iterator<T>.foldl(/*0*/ acc: A, /*1*/ foldFunction: (e: T, acc: A) -> A): A
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
fun escapeChar(c : Char) : String? = when (c) {
|
||||
'\\' -> "\\\\"
|
||||
'\n' -> "\\n"
|
||||
'"' -> "\\\""
|
||||
else -> "" + c
|
||||
}
|
||||
|
||||
tailrec fun String.escape(i : Int = 0, result : StringBuilder = StringBuilder()) : String =
|
||||
if (i == length) result.toString()
|
||||
else escape(i + 1, result.append(escapeChar(get(i))))
|
||||
|
||||
fun box() : String {
|
||||
"test me not \\".escape()
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public fun escapeChar(/*0*/ c: kotlin.Char): kotlin.String?
|
||||
public tailrec fun kotlin.String.escape(/*0*/ i: kotlin.Int = ..., /*1*/ result: kotlin.text.StringBuilder /* = java.lang.StringBuilder */ = ...): kotlin.String
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun String.repeat(num : Int, acc : StringBuilder = StringBuilder()) : String =
|
||||
if (num == 0) acc.toString()
|
||||
else repeat(num - 1, acc.append(this))
|
||||
|
||||
fun box() : String {
|
||||
val s = "a".repeat(10000)
|
||||
return if (s.length == 10000) "OK" else "FAIL: ${s.length}"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun kotlin.String.repeat(/*0*/ num: kotlin.Int, /*1*/ acc: kotlin.text.StringBuilder /* = java.lang.StringBuilder */ = ...): kotlin.String
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo()<!> {
|
||||
bar {
|
||||
<!NON_TAIL_RECURSIVE_CALL!>foo<!>()
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(a: Any) {}
|
||||
|
||||
fun box(): String {
|
||||
foo()
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ a: kotlin.Any): kotlin.Unit
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun foo(): kotlin.Unit
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo()<!> {
|
||||
fun bar() {
|
||||
<!NON_TAIL_RECURSIVE_CALL!>foo<!>()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
foo()
|
||||
return "OK"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun foo(): kotlin.Unit
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
fun test() {
|
||||
tailrec fun g3(counter : Int) {
|
||||
if (counter > 0) { g3(counter - 1) }
|
||||
}
|
||||
g3(1000000)
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
test()
|
||||
return "OK"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public fun test(): kotlin.Unit
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun test(x : Int) : Int {
|
||||
return if (x == 1) {
|
||||
<!NON_TAIL_RECURSIVE_CALL!>test<!>(x - 1)
|
||||
1 + <!NON_TAIL_RECURSIVE_CALL!>test<!>(x - 1)
|
||||
} else if (x > 0) {
|
||||
test(x - 1)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
<!NO_TAIL_CALLS_FOUND!>tailrec fun test(counter : Int) : Int<!> {
|
||||
if (counter == 0) return 0
|
||||
|
||||
try {
|
||||
throw Exception()
|
||||
} catch (e : Exception) {
|
||||
return <!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>(counter - 1)
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String = if (test(3) == 0) "OK" else "FAIL"
|
||||
backend.native/tests/external/codegen/blackbox/diagnostics/functions/tailRecursion/returnInCatch.txt
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ counter: kotlin.Int): kotlin.Int
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
<!NO_TAIL_CALLS_FOUND!>tailrec fun test(counter : Int) : Int<!> {
|
||||
if (counter == 0) return 0
|
||||
|
||||
try {
|
||||
// do nothing
|
||||
} finally {
|
||||
return <!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>(counter - 1)
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String = if (test(3) == 0) "OK" else "FAIL"
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ counter: kotlin.Int): kotlin.Int
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
<!NO_TAIL_CALLS_FOUND!>tailrec fun test(counter : Int) : Int<!> {
|
||||
if (counter == 0) return 0
|
||||
|
||||
try {
|
||||
// do nothing
|
||||
} finally {
|
||||
if (counter > 0) {
|
||||
return <!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>(counter - 1)
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
fun box() : String = if (test(3) == 0) "OK" else "FAIL"
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ counter: kotlin.Int): kotlin.Int
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun foo(x: Int) {
|
||||
if (x == 0) return
|
||||
(return foo(x - 1))
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
foo(1000000)
|
||||
return "OK"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
<!NO_TAIL_CALLS_FOUND!>tailrec fun test(counter : Int) : Int<!> {
|
||||
if (counter == 0) return 0
|
||||
|
||||
try {
|
||||
return <!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>(counter - 1)
|
||||
} catch (any : Throwable) {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String = if (test(3) == 0) "OK" else "FAIL"
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ counter: kotlin.Int): kotlin.Int
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun test(x : Int) : Int =
|
||||
if (x == 1) {
|
||||
<!NON_TAIL_RECURSIVE_CALL!>test<!>(x - 1)
|
||||
1 + <!NON_TAIL_RECURSIVE_CALL!>test<!>(x - 1)
|
||||
} else if (x > 0) {
|
||||
test(x - 1)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
|
||||
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun test(x : Int) : Int {
|
||||
if (x == 10) {
|
||||
return 1 + <!NON_TAIL_RECURSIVE_CALL!>test<!>(x - 1)
|
||||
}
|
||||
if (x > 0) {
|
||||
return test(x - 1)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun test(x : Int) : Int {
|
||||
if (x == 0) {
|
||||
return 0
|
||||
} else if (x == 10) {
|
||||
<!NON_TAIL_RECURSIVE_CALL!>test<!>(0)
|
||||
return 1 + <!NON_TAIL_RECURSIVE_CALL!>test<!>(x - 1)
|
||||
} else {
|
||||
return test(x - 1)
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun sum(x: Long, sum: Long): Long {
|
||||
if (x == 0.toLong()) return sum
|
||||
return sum(x - 1, sum + x)
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val sum = sum(1000000, 0)
|
||||
if (sum != 500000500000.toLong()) return "Fail $sum"
|
||||
return "OK"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun sum(/*0*/ x: kotlin.Long, /*1*/ sum: kotlin.Long): kotlin.Long
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun foo(x: Int) {
|
||||
return if (x > 0) {
|
||||
(foo(x - 1))
|
||||
}
|
||||
else Unit
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
foo(1000000)
|
||||
return "OK"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun foo(x: Int) {
|
||||
if (x == 0) return
|
||||
return (foo(x - 1))
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
foo(1000000)
|
||||
return "OK"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
<!NO_TAIL_CALLS_FOUND!>tailrec fun test(go: Boolean) : Unit<!> {
|
||||
if (!go) return
|
||||
try {
|
||||
<!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>(false)
|
||||
} catch (any : Exception) {
|
||||
<!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>(false)
|
||||
} finally {
|
||||
<!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>(false)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test(true)
|
||||
return "OK"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ go: kotlin.Boolean): kotlin.Unit
|
||||
backend.native/tests/external/codegen/blackbox/diagnostics/functions/tailRecursion/thisReferences.kt
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
class A {
|
||||
tailrec fun f1(c : Int) {
|
||||
if (c > 0) {
|
||||
this.f1(c - 1)
|
||||
}
|
||||
}
|
||||
|
||||
tailrec fun f2(c : Int) {
|
||||
if (c > 0) {
|
||||
f2(c - 1)
|
||||
}
|
||||
}
|
||||
|
||||
<!NO_TAIL_CALLS_FOUND!>tailrec fun f3(a : A)<!> {
|
||||
a.<!NON_TAIL_RECURSIVE_CALL!>f3<!>(a) // non-tail recursion, could be potentially resolved by condition if (a == this) f3() else a.f3()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
A().f1(1000000)
|
||||
A().f2(1000000)
|
||||
return "OK"
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final tailrec fun f1(/*0*/ c: kotlin.Int): kotlin.Unit
|
||||
public final tailrec fun f2(/*0*/ c: kotlin.Int): kotlin.Unit
|
||||
public final tailrec fun f3(/*0*/ a: A): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun test(x : Int) : Unit {
|
||||
if (x == 1) {
|
||||
test(x - 1)
|
||||
} else if (x == 2) {
|
||||
test(x - 1)
|
||||
return
|
||||
} else if (x == 3) {
|
||||
<!NON_TAIL_RECURSIVE_CALL!>test<!>(x - 1)
|
||||
if (x == 3) {
|
||||
test(x - 1)
|
||||
}
|
||||
return
|
||||
} else if (x > 0) {
|
||||
test(x - 1)
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
test(1000000)
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun withWhen(counter : Int) : Int =
|
||||
when (counter) {
|
||||
0 -> counter
|
||||
50 -> 1 + <!NON_TAIL_RECURSIVE_CALL!>withWhen<!>(counter - 1)
|
||||
else -> withWhen(counter - 1)
|
||||
}
|
||||
|
||||
fun box() : String = if (withWhen(100000) == 1) "OK" else "FAIL"
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun withWhen(/*0*/ counter: kotlin.Int): kotlin.Int
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun withWhen(counter : Int, d : Any) : Int =
|
||||
when (counter) {
|
||||
0 -> counter
|
||||
1, 2 -> withWhen(counter - 1, "1,2")
|
||||
in 3..49 -> withWhen(counter - 1, "3..49")
|
||||
50 -> 1 + <!NON_TAIL_RECURSIVE_CALL!>withWhen<!>(counter - 1, "50")
|
||||
!in 0..50 -> withWhen(counter - 1, "!0..50")
|
||||
else -> withWhen(counter - 1, "else")
|
||||
}
|
||||
|
||||
fun box() : String = if (withWhen(100000, "test") == 1) "OK" else "FAIL"
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun withWhen(/*0*/ counter: kotlin.Int, /*1*/ d: kotlin.Any): kotlin.Int
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun withWhen(counter : Int, d : Any) : Int =
|
||||
if (counter == 0) {
|
||||
0
|
||||
}
|
||||
else if (counter == 5) {
|
||||
withWhen(counter - 1, 999)
|
||||
}
|
||||
else
|
||||
when (d) {
|
||||
is String -> withWhen(counter - 1, "is String")
|
||||
is Number -> withWhen(counter, "is Number")
|
||||
else -> throw IllegalStateException()
|
||||
}
|
||||
|
||||
fun box() : String = if (withWhen(100000, "test") == 0) "OK" else "FAIL"
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun withWhen(/*0*/ counter: kotlin.Int, /*1*/ d: kotlin.Any): kotlin.Int
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
tailrec fun withWhen2(counter : Int) : Int =
|
||||
when {
|
||||
counter == 0 -> counter
|
||||
counter == 50 -> 1 + <!NON_TAIL_RECURSIVE_CALL!>withWhen2<!>(counter - 1)
|
||||
<!NON_TAIL_RECURSIVE_CALL!>withWhen2<!>(0) == 0 -> withWhen2(counter - 1)
|
||||
else -> 1
|
||||
}
|
||||
|
||||
fun box() : String = if (withWhen2(100000) == 1) "OK" else "FAIL"
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun withWhen2(/*0*/ counter: kotlin.Int): kotlin.Int
|
||||
@@ -0,0 +1,15 @@
|
||||
fun box(): String {
|
||||
main(array())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
D.foo(array())
|
||||
}
|
||||
|
||||
object D {
|
||||
fun foo(array: Array<out String>) = array
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
inline fun <reified T> array(vararg t : T) : Array<T> = t as Array<T>
|
||||
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
@kotlin.Suppress(names = {"UNCHECKED_CAST"}) public inline fun </*0*/ reified T> array(/*0*/ vararg t: T /*kotlin.Array<out T>*/): kotlin.Array<T>
|
||||
public fun box(): kotlin.String
|
||||
public fun main(/*0*/ args: kotlin.Array<kotlin.String>): kotlin.Unit
|
||||
|
||||
public object D {
|
||||
private constructor D()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(/*0*/ array: kotlin.Array<out kotlin.String>): kotlin.Array<out kotlin.String>
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user