diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 20b53b5787d..563b3a5018d 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -41013,6 +41013,82 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suspendConversion") + @TestDataPath("$PROJECT_ROOT") + public class SuspendConversion { + @Test + public void testAllFilesPresentInSuspendConversion() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suspendConversion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("basicSuspendConversion.kt") + public void testBasicSuspendConversion() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.kt"); + } + + @Test + @TestMetadata("basicSuspendConversionForCallableReference.kt") + public void testBasicSuspendConversionForCallableReference() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.kt"); + } + + @Test + @TestMetadata("basicSuspendConversionGenerics.kt") + public void testBasicSuspendConversionGenerics() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.kt"); + } + + @Test + @TestMetadata("chainedFunSuspendConversionForSimpleExpression.kt") + public void testChainedFunSuspendConversionForSimpleExpression() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt"); + } + + @Test + @TestMetadata("overloadResolutionBySuspendModifier.kt") + public void testOverloadResolutionBySuspendModifier() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt"); + } + + @Test + @TestMetadata("severalConversionsInOneCall.kt") + public void testSeveralConversionsInOneCall() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.kt"); + } + + @Test + @TestMetadata("suspendAndFunConversionInDisabledMode.kt") + public void testSuspendAndFunConversionInDisabledMode() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.kt"); + } + + @Test + @TestMetadata("suspendConversionCompatibility.kt") + public void testSuspendConversionCompatibility() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.kt"); + } + + @Test + @TestMetadata("suspendConversionOnVarargElements.kt") + public void testSuspendConversionOnVarargElements() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.kt"); + } + + @Test + @TestMetadata("suspendConversionWithFunInterfaces.kt") + public void testSuspendConversionWithFunInterfaces() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.kt"); + } + + @Test + @TestMetadata("suspendConversionWithReferenceAdaptation.kt") + public void testSuspendConversionWithReferenceAdaptation() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/synchronized") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.kt b/compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.kt new file mode 100644 index 00000000000..04edc8571cd --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.kt @@ -0,0 +1,25 @@ +// !LANGUAGE: +SuspendConversion +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun foo1(f: suspend () -> String) {} +fun foo2(f: suspend (Int) -> String) {} +fun foo3(f: suspend () -> Unit) {} + +fun test( + f0: suspend () -> String, + f1: () -> String, + f2: (Int) -> String, + f3: () -> Unit, +) { + foo1 { "str" } + foo1(f0) + + foo1(f1) + foo2(f2) + foo3(f3) +} + +fun box(): String { + test({ "" }, { "" }, { it.toString() }, {}) + return "OK" +} diff --git a/compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.txt b/compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.txt new file mode 100644 index 00000000000..7abf5398088 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.txt @@ -0,0 +1,6 @@ +package + +public fun foo1(/*0*/ f: suspend () -> kotlin.String): kotlin.Unit +public fun foo2(/*0*/ f: suspend (kotlin.Int) -> kotlin.String): kotlin.Unit +public fun foo3(/*0*/ f: suspend () -> kotlin.Unit): kotlin.Unit +public fun test(/*0*/ f0: suspend () -> kotlin.String, /*1*/ f1: () -> kotlin.String, /*2*/ f2: (kotlin.Int) -> kotlin.String, /*3*/ f3: () -> kotlin.Unit): kotlin.Unit diff --git a/compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.kt b/compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.kt new file mode 100644 index 00000000000..4c3a81696eb --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +SuspendConversion +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun foo1(f: suspend () -> Unit) {} +fun bar1() {} + +fun foo2(e: T, f: suspend (T) -> Unit) {} +fun bar2(x: Int) {} +fun bar2(s: String) {} + +fun box(): String { + foo1(::bar1) + + foo2(42, ::bar2) + foo2("str", ::bar2) + + return "OK" +} diff --git a/compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.txt b/compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.txt new file mode 100644 index 00000000000..93d0d2da1dd --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.txt @@ -0,0 +1,8 @@ +package + +public fun bar1(): kotlin.Unit +public fun bar2(/*0*/ x: kotlin.Int): kotlin.Unit +public fun bar2(/*0*/ s: kotlin.String): kotlin.Unit +public fun foo1(/*0*/ f: suspend () -> kotlin.Unit): kotlin.Unit +public fun foo2(/*0*/ e: T, /*1*/ f: suspend (T) -> kotlin.Unit): kotlin.Unit +public fun test(): kotlin.Unit diff --git a/compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.kt b/compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.kt new file mode 100644 index 00000000000..13ef6707a8f --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.kt @@ -0,0 +1,54 @@ +// !LANGUAGE: +SuspendConversion +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// WITH_RUNTIME + +class Inv2 + +inline fun materialize(): T = T::class.java.newInstance() + +inline fun foo1(crossinline f: suspend (T) -> String): T = materialize() +inline fun foo2(crossinline f: suspend () -> T): T = materialize() +inline fun foo3(crossinline f: suspend (T) -> K): Inv2 = Inv2() + +fun foo11(f: suspend (T) -> String): T = 1 as T +fun foo21(f: suspend () -> T): T = "" as T +fun foo31(f: suspend (T) -> K): Inv2 = Inv2() + +fun id(e: I): I = e + +fun test(f: (Int) -> String, g: () -> String) { + val a0 = foo1(f) + val a01 = foo11(f) + a0 + a01 + + val a1 = foo2(g) + val a11 = foo21(g) + a1 + a11 + + val a2 = foo3(f) + val a21 = foo31(f) + ")!>a2 + ")!>a21 + + val a3 = foo1(id(f)) + val a31 = foo11(id(f)) + a3 + a31 + + val a4 = foo2(id(g)) + val a41 = foo21(id(g)) + a4 + a41 + + val a5 = foo3(id(f)) + val a51 = foo31(id(f)) + ")!>a5 + ")!>a51 +} + +fun box(): String { + test({ it.toString() }, { "" }) + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.txt b/compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.txt new file mode 100644 index 00000000000..260f7221920 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.txt @@ -0,0 +1,14 @@ +package + +public fun foo1(/*0*/ f: suspend (T) -> kotlin.String): T +public fun foo2(/*0*/ f: suspend () -> T): T +public fun foo3(/*0*/ f: suspend (T) -> K): Inv2 +public fun id(/*0*/ e: I): I +public fun test(/*0*/ f: (kotlin.Int) -> kotlin.String, /*1*/ g: () -> kotlin.String): kotlin.Unit + +public final class Inv2 { + public constructor Inv2() + 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 +} diff --git a/compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt b/compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt new file mode 100644 index 00000000000..31c9923c99b --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt @@ -0,0 +1,19 @@ +// FIR_IDENTICAL +// !LANGUAGE: +SuspendConversion +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun interface SuspendRunnable { + suspend fun invoke() +} + +fun foo(s: SuspendRunnable) {} + +fun test(f: () -> Unit) { + foo { } + foo(f) +} + +fun box(): String { + test({ "" }) + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.txt b/compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.txt new file mode 100644 index 00000000000..2a0041e2544 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.txt @@ -0,0 +1,11 @@ +package + +public fun foo(/*0*/ s: SuspendRunnable): kotlin.Unit +public fun test(/*0*/ f: () -> kotlin.Unit): kotlin.Unit + +public fun interface SuspendRunnable { + 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 abstract suspend fun invoke(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt b/compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt new file mode 100644 index 00000000000..1d371fb3127 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt @@ -0,0 +1,19 @@ +// !LANGUAGE: +SuspendConversion +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun foo(x: () -> Int) {} +fun foo(x: suspend () -> Int) {} + +fun usualCall(): Int = 42 +suspend fun suspendCall(): Int = 42 + +// candidate without suspend conversions is more specific +fun test2(f: () -> Int, g: suspend () -> Int) { + foo(f) + foo(g) +} + +fun box(): String { + test2({ 1 }, { 2 }) + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.txt b/compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.txt new file mode 100644 index 00000000000..6ffdb905ef2 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.txt @@ -0,0 +1,8 @@ +package + +public fun foo(/*0*/ x: () -> kotlin.Int): kotlin.Unit +public fun foo(/*0*/ x: suspend () -> kotlin.Int): kotlin.Unit +public suspend fun suspendCall(): kotlin.Int +public fun test1(): kotlin.Unit +public fun test2(/*0*/ f: () -> kotlin.Int, /*1*/ g: suspend () -> kotlin.Int): kotlin.Unit +public fun usualCall(): kotlin.Int diff --git a/compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.kt b/compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.kt new file mode 100644 index 00000000000..fde0ad8dc59 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.kt @@ -0,0 +1,17 @@ +// FIR_IDENTICAL +// !LANGUAGE: +SuspendConversion +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun foo(f: () -> String, g: suspend () -> String, h: suspend () -> String) {} + +fun test(f: () -> String, g: suspend () -> String) { + foo(f, f, f) + foo(f, { "str" }, f) + foo(f, f, g) + foo(f, g, g) +} + +fun box(): String { + test({ "1" }, { "2" }) + return "OK" +} diff --git a/compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.txt b/compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.txt new file mode 100644 index 00000000000..be200b8eadc --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.txt @@ -0,0 +1,4 @@ +package + +public fun foo(/*0*/ f: () -> kotlin.String, /*1*/ g: suspend () -> kotlin.String, /*2*/ h: suspend () -> kotlin.String): kotlin.Unit +public fun test(/*0*/ f: () -> kotlin.String, /*1*/ g: suspend () -> kotlin.String): kotlin.Unit diff --git a/compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.kt b/compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.kt new file mode 100644 index 00000000000..6bfe53909dd --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.kt @@ -0,0 +1,36 @@ +// !LANGUAGE: +SuspendConversion +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION + +fun interface SuspendRunnable { + suspend fun run() +} + +object Test1 { + fun call(r: () -> Unit) {} + + object Scope { + fun call(r: SuspendRunnable) {} + + fun bar(f: () -> Unit) { + call(f) + } + } +} + +object Test2 { + fun call(r: Runnable) {} + + object Scope { + fun call(r: SuspendRunnable) {} + + fun bar(f: () -> Unit) { + call(f) + } + } +} + +fun box(): String { + Test2.Scope.bar { } + Test1.Scope.bar { } + return "OK" +} diff --git a/compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.txt b/compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.txt new file mode 100644 index 00000000000..2e7066b7f5b --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.txt @@ -0,0 +1,42 @@ +package + +public fun interface SuspendRunnable { + 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 abstract suspend fun run(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object Test1 { + private constructor Test1() + public final fun call(/*0*/ r: () -> kotlin.Unit): kotlin.Unit + 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 object Scope { + private constructor Scope() + public final fun bar(/*0*/ f: () -> kotlin.Unit): kotlin.Unit + public final fun call(/*0*/ r: SuspendRunnable): kotlin.Unit + 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 object Test2 { + private constructor Test2() + public final fun call(/*0*/ r: java.lang.Runnable): kotlin.Unit + 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 object Scope { + private constructor Scope() + public final fun bar(/*0*/ f: () -> kotlin.Unit): kotlin.Unit + public final fun call(/*0*/ r: SuspendRunnable): kotlin.Unit + 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 + } +} diff --git a/compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.kt b/compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.kt new file mode 100644 index 00000000000..fec6f3d6cf4 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.kt @@ -0,0 +1,57 @@ +// !LANGUAGE: +SuspendConversion +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION +// WITH_RUNTIME + +object Test1 { + fun foo(f: () -> Unit) {} + + object Scope { + fun foo(f: suspend () -> Unit) {} + + fun test(g: () -> Unit) { + foo(g) + } + } +} + +object Test2 { + inline fun foo(crossinline f: suspend () -> T): T = 1 as T + fun foo2(f: suspend () -> T): T = 1 as T + suspend fun bar(): Int = 0 + + object Scope { + fun bar(): String = "" + + fun test() { + val result = foo(::bar) + val result2 = foo2(::bar) + result + result2 + } + } +} + +object Test3 { + inline fun foo(crossinline f: suspend () -> T): T = "" as T + fun foo2(f: suspend () -> T): T = "" as T + + suspend fun bar(x: Int = 42): Int = 0 + + object Scope { + fun bar(x: Int = 42): String = "" + + fun test() { + val result = foo(::bar) + val result2 = foo2(::bar) + result + result2 + } + } +} + +fun box(): String { + Test1.Scope.test {} + Test2.Scope.test() + Test3.Scope.test() + return "OK" +} diff --git a/compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.txt b/compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.txt new file mode 100644 index 00000000000..0cb22c2e490 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.txt @@ -0,0 +1,54 @@ +package + +public object Test1 { + private constructor Test1() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(/*0*/ f: () -> kotlin.Unit): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public object Scope { + private constructor Scope() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(/*0*/ f: suspend () -> kotlin.Unit): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun test(/*0*/ g: () -> kotlin.Unit): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public object Test2 { + private constructor Test2() + public final suspend fun bar(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(/*0*/ f: suspend () -> T): T + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public object Scope { + private constructor Scope() + public final fun bar(): kotlin.String + 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 fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public object Test3 { + private constructor Test3() + public final suspend fun bar(/*0*/ x: kotlin.Int = ...): kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(/*0*/ f: suspend () -> T): T + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public object Scope { + private constructor Scope() + public final fun bar(/*0*/ x: kotlin.Int = ...): kotlin.String + 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 fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.kt b/compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.kt new file mode 100644 index 00000000000..e5756d9ae53 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.kt @@ -0,0 +1,27 @@ +// FIR_IDENTICAL +// !LANGUAGE: +SuspendConversion +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun useSuspendVararg(vararg sfn: suspend () -> Unit) {} + +fun testSuspendConversionInVarargElementsSome( + sf1: suspend () -> Unit, + f2: () -> Unit, + sf3: suspend () -> Unit +) { + useSuspendVararg(sf1, f2, sf3) +} + +fun testSuspendConversionInVarargElementsAll( + f1: () -> Unit, + f2: () -> Unit, + f3: () -> Unit +) { + useSuspendVararg(f1, f2, f3) +} + +fun box(): String { + testSuspendConversionInVarargElementsSome({}, {}, {}) + testSuspendConversionInVarargElementsAll({}, {}, {}) + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.txt b/compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.txt new file mode 100644 index 00000000000..7762406fa30 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.txt @@ -0,0 +1,5 @@ +package + +public fun testSuspendConversionInVarargElementsAll(/*0*/ f1: () -> kotlin.Unit, /*1*/ f2: () -> kotlin.Unit, /*2*/ f3: () -> kotlin.Unit): kotlin.Unit +public fun testSuspendConversionInVarargElementsSome(/*0*/ sf1: suspend () -> kotlin.Unit, /*1*/ f2: () -> kotlin.Unit, /*2*/ sf3: suspend () -> kotlin.Unit): kotlin.Unit +public fun useSuspendVararg(/*0*/ vararg sfn: suspend () -> kotlin.Unit /*kotlin.Array kotlin.Unit>*/): kotlin.Unit diff --git a/compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.kt b/compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.kt new file mode 100644 index 00000000000..d220a8989e8 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.kt @@ -0,0 +1,24 @@ +// FIR_IDENTICAL +// !LANGUAGE: +SuspendConversion +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun interface SuspendRunnable { + suspend fun invoke() +} + +fun foo1(s: SuspendRunnable) {} +fun bar1() {} + +fun bar2(s: String = ""): Int = 0 + +fun bar3() {} +suspend fun bar3(s: String = ""): Int = 0 + +fun box(): String { + foo1(::bar1) + foo1(::bar2) + + foo1(::bar3) // Should be ambiguity + + return "OK" +} diff --git a/compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.txt b/compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.txt new file mode 100644 index 00000000000..e3c1c2274da --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.txt @@ -0,0 +1,15 @@ +package + +public fun bar1(): kotlin.Unit +public fun bar2(/*0*/ s: kotlin.String = ...): kotlin.Int +public fun bar3(): kotlin.Unit +public suspend fun bar3(/*0*/ s: kotlin.String = ...): kotlin.Int +public fun foo1(/*0*/ s: SuspendRunnable): kotlin.Unit +public fun test(): kotlin.Unit + +public fun interface SuspendRunnable { + 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 abstract suspend fun invoke(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.kt b/compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.kt new file mode 100644 index 00000000000..8c0e29359c6 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.kt @@ -0,0 +1,23 @@ +// FIR_IDENTICAL +// !LANGUAGE: +SuspendConversion +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun unitCoercion(f: suspend () -> Unit) {} +fun foo(): Int = 0 + +fun defaults(f: suspend (Int) -> String) {} +fun bar(i: Int, l: Long = 42L): String = "" + +fun varargs(f: suspend (Int, Int, Int) -> String) {} +fun baz(vararg ints: Int): String = "" + +fun unitCoercionAndDefaults(f: suspend () -> Unit) {} +fun all(s: String = ""): Int = 0 + +fun box(): String { + unitCoercion(::foo) + defaults(::bar) + varargs(::baz) + unitCoercionAndDefaults(::all) + return "OK" +} diff --git a/compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.txt b/compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.txt new file mode 100644 index 00000000000..391ad648b99 --- /dev/null +++ b/compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.txt @@ -0,0 +1,11 @@ +package + +public fun all(/*0*/ s: kotlin.String = ...): kotlin.Int +public fun bar(/*0*/ i: kotlin.Int, /*1*/ l: kotlin.Long = ...): kotlin.String +public fun baz(/*0*/ vararg ints: kotlin.Int /*kotlin.IntArray*/): kotlin.String +public fun defaults(/*0*/ f: suspend (kotlin.Int) -> kotlin.String): kotlin.Unit +public fun foo(): kotlin.Int +public fun test(): kotlin.Unit +public fun unitCoercion(/*0*/ f: suspend () -> kotlin.Unit): kotlin.Unit +public fun unitCoercionAndDefaults(/*0*/ f: suspend () -> kotlin.Unit): kotlin.Unit +public fun varargs(/*0*/ f: suspend (kotlin.Int, kotlin.Int, kotlin.Int) -> kotlin.String): kotlin.Unit diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 7baf9347cbe..0d5d6658304 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -40971,6 +40971,82 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suspendConversion") + @TestDataPath("$PROJECT_ROOT") + public class SuspendConversion { + @Test + public void testAllFilesPresentInSuspendConversion() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suspendConversion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("basicSuspendConversion.kt") + public void testBasicSuspendConversion() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.kt"); + } + + @Test + @TestMetadata("basicSuspendConversionForCallableReference.kt") + public void testBasicSuspendConversionForCallableReference() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.kt"); + } + + @Test + @TestMetadata("basicSuspendConversionGenerics.kt") + public void testBasicSuspendConversionGenerics() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.kt"); + } + + @Test + @TestMetadata("chainedFunSuspendConversionForSimpleExpression.kt") + public void testChainedFunSuspendConversionForSimpleExpression() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt"); + } + + @Test + @TestMetadata("overloadResolutionBySuspendModifier.kt") + public void testOverloadResolutionBySuspendModifier() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt"); + } + + @Test + @TestMetadata("severalConversionsInOneCall.kt") + public void testSeveralConversionsInOneCall() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.kt"); + } + + @Test + @TestMetadata("suspendAndFunConversionInDisabledMode.kt") + public void testSuspendAndFunConversionInDisabledMode() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.kt"); + } + + @Test + @TestMetadata("suspendConversionCompatibility.kt") + public void testSuspendConversionCompatibility() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.kt"); + } + + @Test + @TestMetadata("suspendConversionOnVarargElements.kt") + public void testSuspendConversionOnVarargElements() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.kt"); + } + + @Test + @TestMetadata("suspendConversionWithFunInterfaces.kt") + public void testSuspendConversionWithFunInterfaces() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.kt"); + } + + @Test + @TestMetadata("suspendConversionWithReferenceAdaptation.kt") + public void testSuspendConversionWithReferenceAdaptation() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/synchronized") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index ee415eac978..71bef270ae0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -41013,6 +41013,82 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suspendConversion") + @TestDataPath("$PROJECT_ROOT") + public class SuspendConversion { + @Test + public void testAllFilesPresentInSuspendConversion() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suspendConversion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("basicSuspendConversion.kt") + public void testBasicSuspendConversion() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.kt"); + } + + @Test + @TestMetadata("basicSuspendConversionForCallableReference.kt") + public void testBasicSuspendConversionForCallableReference() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.kt"); + } + + @Test + @TestMetadata("basicSuspendConversionGenerics.kt") + public void testBasicSuspendConversionGenerics() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.kt"); + } + + @Test + @TestMetadata("chainedFunSuspendConversionForSimpleExpression.kt") + public void testChainedFunSuspendConversionForSimpleExpression() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt"); + } + + @Test + @TestMetadata("overloadResolutionBySuspendModifier.kt") + public void testOverloadResolutionBySuspendModifier() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt"); + } + + @Test + @TestMetadata("severalConversionsInOneCall.kt") + public void testSeveralConversionsInOneCall() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.kt"); + } + + @Test + @TestMetadata("suspendAndFunConversionInDisabledMode.kt") + public void testSuspendAndFunConversionInDisabledMode() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.kt"); + } + + @Test + @TestMetadata("suspendConversionCompatibility.kt") + public void testSuspendConversionCompatibility() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.kt"); + } + + @Test + @TestMetadata("suspendConversionOnVarargElements.kt") + public void testSuspendConversionOnVarargElements() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.kt"); + } + + @Test + @TestMetadata("suspendConversionWithFunInterfaces.kt") + public void testSuspendConversionWithFunInterfaces() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.kt"); + } + + @Test + @TestMetadata("suspendConversionWithReferenceAdaptation.kt") + public void testSuspendConversionWithReferenceAdaptation() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/synchronized") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index eef49e8409e..b8cb728f6af 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -32895,6 +32895,74 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/suspendConversion") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SuspendConversion extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInSuspendConversion() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suspendConversion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("basicSuspendConversion.kt") + public void testBasicSuspendConversion() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.kt"); + } + + @TestMetadata("basicSuspendConversionForCallableReference.kt") + public void testBasicSuspendConversionForCallableReference() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.kt"); + } + + @TestMetadata("basicSuspendConversionGenerics.kt") + public void testBasicSuspendConversionGenerics() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.kt"); + } + + @TestMetadata("chainedFunSuspendConversionForSimpleExpression.kt") + public void testChainedFunSuspendConversionForSimpleExpression() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt"); + } + + @TestMetadata("overloadResolutionBySuspendModifier.kt") + public void testOverloadResolutionBySuspendModifier() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt"); + } + + @TestMetadata("severalConversionsInOneCall.kt") + public void testSeveralConversionsInOneCall() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.kt"); + } + + @TestMetadata("suspendAndFunConversionInDisabledMode.kt") + public void testSuspendAndFunConversionInDisabledMode() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.kt"); + } + + @TestMetadata("suspendConversionCompatibility.kt") + public void testSuspendConversionCompatibility() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.kt"); + } + + @TestMetadata("suspendConversionOnVarargElements.kt") + public void testSuspendConversionOnVarargElements() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.kt"); + } + + @TestMetadata("suspendConversionWithFunInterfaces.kt") + public void testSuspendConversionWithFunInterfaces() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.kt"); + } + + @TestMetadata("suspendConversionWithReferenceAdaptation.kt") + public void testSuspendConversionWithReferenceAdaptation() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/synchronized") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 09168c3e313..5ed187b418c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -27510,6 +27510,74 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes } } + @TestMetadata("compiler/testData/codegen/box/suspendConversion") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SuspendConversion extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInSuspendConversion() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suspendConversion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + + @TestMetadata("basicSuspendConversion.kt") + public void testBasicSuspendConversion() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.kt"); + } + + @TestMetadata("basicSuspendConversionForCallableReference.kt") + public void testBasicSuspendConversionForCallableReference() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.kt"); + } + + @TestMetadata("basicSuspendConversionGenerics.kt") + public void testBasicSuspendConversionGenerics() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.kt"); + } + + @TestMetadata("chainedFunSuspendConversionForSimpleExpression.kt") + public void testChainedFunSuspendConversionForSimpleExpression() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt"); + } + + @TestMetadata("overloadResolutionBySuspendModifier.kt") + public void testOverloadResolutionBySuspendModifier() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt"); + } + + @TestMetadata("severalConversionsInOneCall.kt") + public void testSeveralConversionsInOneCall() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.kt"); + } + + @TestMetadata("suspendAndFunConversionInDisabledMode.kt") + public void testSuspendAndFunConversionInDisabledMode() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.kt"); + } + + @TestMetadata("suspendConversionCompatibility.kt") + public void testSuspendConversionCompatibility() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.kt"); + } + + @TestMetadata("suspendConversionOnVarargElements.kt") + public void testSuspendConversionOnVarargElements() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.kt"); + } + + @TestMetadata("suspendConversionWithFunInterfaces.kt") + public void testSuspendConversionWithFunInterfaces() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.kt"); + } + + @TestMetadata("suspendConversionWithReferenceAdaptation.kt") + public void testSuspendConversionWithReferenceAdaptation() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/synchronized") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index f6cad8927c2..293d7a0e57b 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -26916,6 +26916,74 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/suspendConversion") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SuspendConversion extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInSuspendConversion() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suspendConversion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @TestMetadata("basicSuspendConversion.kt") + public void testBasicSuspendConversion() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.kt"); + } + + @TestMetadata("basicSuspendConversionForCallableReference.kt") + public void testBasicSuspendConversionForCallableReference() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.kt"); + } + + @TestMetadata("basicSuspendConversionGenerics.kt") + public void testBasicSuspendConversionGenerics() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.kt"); + } + + @TestMetadata("chainedFunSuspendConversionForSimpleExpression.kt") + public void testChainedFunSuspendConversionForSimpleExpression() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt"); + } + + @TestMetadata("overloadResolutionBySuspendModifier.kt") + public void testOverloadResolutionBySuspendModifier() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt"); + } + + @TestMetadata("severalConversionsInOneCall.kt") + public void testSeveralConversionsInOneCall() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.kt"); + } + + @TestMetadata("suspendAndFunConversionInDisabledMode.kt") + public void testSuspendAndFunConversionInDisabledMode() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.kt"); + } + + @TestMetadata("suspendConversionCompatibility.kt") + public void testSuspendConversionCompatibility() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.kt"); + } + + @TestMetadata("suspendConversionOnVarargElements.kt") + public void testSuspendConversionOnVarargElements() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.kt"); + } + + @TestMetadata("suspendConversionWithFunInterfaces.kt") + public void testSuspendConversionWithFunInterfaces() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.kt"); + } + + @TestMetadata("suspendConversionWithReferenceAdaptation.kt") + public void testSuspendConversionWithReferenceAdaptation() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/synchronized") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 781405f2f1e..84d94cbc1c7 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -26876,6 +26876,74 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/suspendConversion") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SuspendConversion extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInSuspendConversion() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suspendConversion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + + @TestMetadata("basicSuspendConversion.kt") + public void testBasicSuspendConversion() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.kt"); + } + + @TestMetadata("basicSuspendConversionForCallableReference.kt") + public void testBasicSuspendConversionForCallableReference() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.kt"); + } + + @TestMetadata("basicSuspendConversionGenerics.kt") + public void testBasicSuspendConversionGenerics() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.kt"); + } + + @TestMetadata("chainedFunSuspendConversionForSimpleExpression.kt") + public void testChainedFunSuspendConversionForSimpleExpression() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt"); + } + + @TestMetadata("overloadResolutionBySuspendModifier.kt") + public void testOverloadResolutionBySuspendModifier() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt"); + } + + @TestMetadata("severalConversionsInOneCall.kt") + public void testSeveralConversionsInOneCall() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.kt"); + } + + @TestMetadata("suspendAndFunConversionInDisabledMode.kt") + public void testSuspendAndFunConversionInDisabledMode() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.kt"); + } + + @TestMetadata("suspendConversionCompatibility.kt") + public void testSuspendConversionCompatibility() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.kt"); + } + + @TestMetadata("suspendConversionOnVarargElements.kt") + public void testSuspendConversionOnVarargElements() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.kt"); + } + + @TestMetadata("suspendConversionWithFunInterfaces.kt") + public void testSuspendConversionWithFunInterfaces() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.kt"); + } + + @TestMetadata("suspendConversionWithReferenceAdaptation.kt") + public void testSuspendConversionWithReferenceAdaptation() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/synchronized") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 72e81320d72..f16de973deb 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -15037,6 +15037,74 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } + @TestMetadata("compiler/testData/codegen/box/suspendConversion") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SuspendConversion extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInSuspendConversion() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suspendConversion"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @TestMetadata("basicSuspendConversion.kt") + public void testBasicSuspendConversion() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversion.kt"); + } + + @TestMetadata("basicSuspendConversionForCallableReference.kt") + public void testBasicSuspendConversionForCallableReference() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionForCallableReference.kt"); + } + + @TestMetadata("basicSuspendConversionGenerics.kt") + public void testBasicSuspendConversionGenerics() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/basicSuspendConversionGenerics.kt"); + } + + @TestMetadata("chainedFunSuspendConversionForSimpleExpression.kt") + public void testChainedFunSuspendConversionForSimpleExpression() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt"); + } + + @TestMetadata("overloadResolutionBySuspendModifier.kt") + public void testOverloadResolutionBySuspendModifier() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt"); + } + + @TestMetadata("severalConversionsInOneCall.kt") + public void testSeveralConversionsInOneCall() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/severalConversionsInOneCall.kt"); + } + + @TestMetadata("suspendAndFunConversionInDisabledMode.kt") + public void testSuspendAndFunConversionInDisabledMode() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendAndFunConversionInDisabledMode.kt"); + } + + @TestMetadata("suspendConversionCompatibility.kt") + public void testSuspendConversionCompatibility() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.kt"); + } + + @TestMetadata("suspendConversionOnVarargElements.kt") + public void testSuspendConversionOnVarargElements() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionOnVarargElements.kt"); + } + + @TestMetadata("suspendConversionWithFunInterfaces.kt") + public void testSuspendConversionWithFunInterfaces() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithFunInterfaces.kt"); + } + + @TestMetadata("suspendConversionWithReferenceAdaptation.kt") + public void testSuspendConversionWithReferenceAdaptation() throws Exception { + runTest("compiler/testData/codegen/box/suspendConversion/suspendConversionWithReferenceAdaptation.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/synchronized") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)