diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt index c2a818befbb..8b6e02cddad 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt @@ -1,5 +1,10 @@ +// !USE_EXPERIMENTAL: kotlin.Experimental // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + interface Controller { suspend fun yield(t: T) {} @@ -8,7 +13,7 @@ interface Controller { fun generidFun(t: Z) = t } -fun generate(g: suspend Controller.() -> Unit): S = TODO() +fun generate(@BuilderInference g: suspend Controller.() -> Unit): S = TODO() val test1 = generate { yield(justString()) diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.txt index 288fb4cac8e..94cf52b9dcf 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.txt @@ -2,7 +2,7 @@ package public val test1: kotlin.String public val test2: kotlin.Int -public fun generate(/*0*/ g: suspend Controller.() -> kotlin.Unit): S +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend Controller.() -> kotlin.Unit): S public interface Controller { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionPriority.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionPriority.kt index 573b7e71b14..55564abcd47 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionPriority.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionPriority.kt @@ -1,11 +1,18 @@ +// !USE_EXPERIMENTAL: kotlin.Experimental // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + class GenericController +@BuilderInference suspend fun GenericController.yieldAll(s: Collection): String = "" +@BuilderInference suspend fun GenericController.yieldAll(s: Set): Int = 4 -fun generate(g: suspend GenericController.() -> R): Pair = TODO() +fun generate(@BuilderInference g: suspend GenericController.() -> R): Pair = TODO() val test1 = generate { yieldAll(setOf(4)) diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionPriority.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionPriority.txt index edf07576028..f7f1c393be5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionPriority.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionPriority.txt @@ -2,11 +2,11 @@ package public val test1: Pair public val test2: Pair -public fun generate(/*0*/ g: suspend GenericController.() -> R): Pair +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController.() -> R): Pair public fun listOf(/*0*/ vararg x: X /*kotlin.Array*/): kotlin.collections.List public fun setOf(/*0*/ vararg x: X /*kotlin.Array*/): kotlin.collections.Set -public suspend fun GenericController.yieldAll(/*0*/ s: kotlin.collections.Collection): kotlin.String -public suspend fun GenericController.yieldAll(/*0*/ s: kotlin.collections.Set): kotlin.Int +@kotlin.BuilderInference public suspend fun GenericController.yieldAll(/*0*/ s: kotlin.collections.Collection): kotlin.String +@kotlin.BuilderInference public suspend fun GenericController.yieldAll(/*0*/ s: kotlin.collections.Set): kotlin.Int public final class GenericController { public constructor GenericController() diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionSuspend.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionSuspend.kt index f23e66ed278..cd532cf8649 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionSuspend.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionSuspend.kt @@ -1,12 +1,18 @@ +// !USE_EXPERIMENTAL: kotlin.Experimental // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + class GenericController { suspend fun yield(t: T) {} } +@BuilderInference suspend fun GenericController.yieldAll(s: Collection) {} -fun generate(g: suspend GenericController.() -> Unit): S = TODO() +fun generate(@BuilderInference g: suspend GenericController.() -> Unit): S = TODO() val test1 = generate { yield(4) diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionSuspend.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionSuspend.txt index b1212a4de77..52a24452e13 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionSuspend.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionSuspend.txt @@ -4,9 +4,9 @@ public val test1: kotlin.Int public val test2: B public val test3: A public val test4: A -public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): S +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController.() -> kotlin.Unit): S public fun setOf(/*0*/ vararg x: X /*kotlin.Array*/): kotlin.collections.Set -public suspend fun GenericController.yieldAll(/*0*/ s: kotlin.collections.Collection): kotlin.Unit +@kotlin.BuilderInference public suspend fun GenericController.yieldAll(/*0*/ s: kotlin.collections.Collection): kotlin.Unit public interface A { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.kt index 473c83cbe73..476d64642db 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.kt @@ -1,7 +1,12 @@ +// !USE_EXPERIMENTAL: kotlin.Experimental // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE // !WITH_NEW_INFERENCE // NI_EXPECTED_FILE +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + class GenericController { suspend fun yield(t: T) {} fun notYield(t: T) {} @@ -10,13 +15,13 @@ class GenericController { fun barReturnType(): T = TODO() } -fun generate(g: suspend GenericController.() -> Unit): List = TODO() +fun generate(@BuilderInference g: suspend GenericController.() -> Unit): List = TODO() val test1 = generate { yield(3) } -val test2 = generate { +val test2 = generate { yield(3) notYield(3) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.txt index 16d4eec468a..a72fa6593da 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.txt @@ -1,10 +1,7 @@ package public val test1: kotlin.collections.List -public val test2: [ERROR : Type for generate { - yield(3) - notYield(3) -}] +public val test2: kotlin.collections.List public val test3: [ERROR : Type for generate { yield(3) yieldBarReturnType(3) @@ -13,7 +10,7 @@ public val test4: [ERROR : Type for generate { yield(3) barReturnType() }] -public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List public final class GenericController { public constructor GenericController() diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators.kt index d7e3fcde878..759478526f2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators.kt @@ -1,10 +1,15 @@ +// !USE_EXPERIMENTAL: kotlin.Experimental // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + class GenericController { suspend fun yield(t: T) {} } -fun generate(g: suspend GenericController.() -> Unit): List = TODO() +fun generate(@BuilderInference g: suspend GenericController.() -> Unit): List = TODO() val test1 = generate { yield(generate { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators.txt index 6018443cfb9..7ff834cbffd 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators.txt @@ -1,7 +1,7 @@ package public val test1: kotlin.collections.List>>> -public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List public final class GenericController { public constructor GenericController() diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators2.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators2.kt index ff7961e7487..b9fc0a49c70 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators2.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators2.kt @@ -1,13 +1,19 @@ +// !USE_EXPERIMENTAL: kotlin.Experimental // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE // !WITH_NEW_INFERENCE // NI_EXPECTED_FILE +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + class GenericController { suspend fun yield(t: T) {} } -fun generate(g: suspend GenericController.() -> Unit): List = TODO() +fun generate(@BuilderInference g: suspend GenericController.() -> Unit): List = TODO() +@BuilderInference suspend fun GenericController>.yieldGenerate(g: suspend GenericController.() -> Unit): Unit = TODO() val test1 = generate { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators2.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators2.txt index e12e02c141c..26da761b461 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators2.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators2.txt @@ -1,8 +1,8 @@ package public val test1: kotlin.collections.List -public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List -public suspend fun GenericController>.yieldGenerate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.Unit +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List +@kotlin.BuilderInference public suspend fun GenericController>.yieldGenerate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.Unit public final class GenericController { public constructor GenericController() diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/returnTypeInference2.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/returnTypeInference2.kt index 7017b3936da..44ad4ad0c4d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/returnTypeInference2.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/returnTypeInference2.kt @@ -1,10 +1,15 @@ +// !USE_EXPERIMENTAL: kotlin.Experimental // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + class Controller { suspend fun yield(t: T) {} } -fun generate(g: suspend Controller.() -> R): Pair = TODO() +fun generate(@BuilderInference g: suspend Controller.() -> R): Pair = TODO() val test1 = generate { yield("") diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/returnTypeInference2.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/returnTypeInference2.txt index 2682b299a82..e2ed19c5b55 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/returnTypeInference2.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/returnTypeInference2.txt @@ -1,7 +1,7 @@ package public val test1: Pair -public fun generate(/*0*/ g: suspend Controller.() -> R): Pair +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend Controller.() -> R): Pair public final class Controller { public constructor Controller() diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/simpleGenerator.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/simpleGenerator.kt index 61fc621ae7e..2af8b1a1f94 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/simpleGenerator.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/simpleGenerator.kt @@ -1,12 +1,17 @@ +// !USE_EXPERIMENTAL: kotlin.Experimental // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + class GenericController { suspend fun yield(t: T) {} suspend fun yieldSet(t: Set) {} suspend fun yieldVararg(vararg t: T) {} } -fun generate(g: suspend GenericController.() -> Unit): S = TODO() +fun generate(@BuilderInference g: suspend GenericController.() -> Unit): S = TODO() val test1 = generate { yield(4) diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/simpleGenerator.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/simpleGenerator.txt index 85d771e19cb..a2fe7f4c928 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/simpleGenerator.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/simpleGenerator.txt @@ -4,7 +4,7 @@ public val test1: kotlin.Int public val test2: kotlin.Int public val test3: kotlin.Int public val test4: kotlin.Any -public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): S +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController.() -> kotlin.Unit): S public fun setOf(/*0*/ vararg x: X /*kotlin.Array*/): kotlin.collections.Set public final class GenericController { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.kt index 1ce0e6a4c8a..76e51ac080c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.kt @@ -1,12 +1,17 @@ +// !USE_EXPERIMENTAL: kotlin.Experimental // !DIAGNOSTICS: -UNUSED_PARAMETER // !WITH_NEW_INFERENCE // NI_EXPECTED_FILE +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + class Controller { suspend fun yield(t: T) {} } -fun generate(g: suspend Controller.() -> Unit): S = TODO() +fun generate(@BuilderInference g: suspend Controller.() -> Unit): S = TODO() class A diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.txt index fa1ec20c49a..e1c830c8f28 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.txt @@ -4,7 +4,7 @@ public val test1: [ERROR : Type for generate { yield(A) }] public val test2: kotlin.Int -public fun generate(/*0*/ g: suspend Controller.() -> kotlin.Unit): S +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend Controller.() -> kotlin.Unit): S public final class A { public constructor A() diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/typeFromReceiver.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/typeFromReceiver.kt index 23d22f03726..46960ae0e1a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/typeFromReceiver.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/typeFromReceiver.kt @@ -1,9 +1,15 @@ +// !USE_EXPERIMENTAL: kotlin.Experimental // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + class GenericController -fun generate(g: suspend GenericController.() -> Unit): List = TODO() +fun generate(@BuilderInference g: suspend GenericController.() -> Unit): List = TODO() +@BuilderInference suspend fun GenericController>.test() {} val test1 = generate { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/typeFromReceiver.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/typeFromReceiver.txt index 60aaa9dcf70..b2128c4125e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/typeFromReceiver.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/typeFromReceiver.txt @@ -1,8 +1,8 @@ package public val test1: kotlin.collections.List> -public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List -public suspend fun GenericController>.test(): kotlin.Unit +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List +@kotlin.BuilderInference public suspend fun GenericController>.test(): kotlin.Unit public final class GenericController { public constructor GenericController() diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withParameter.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withParameter.kt index 4df5fa1a891..6e27d1c2e98 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withParameter.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withParameter.kt @@ -1,10 +1,15 @@ +// !USE_EXPERIMENTAL: kotlin.Experimental // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + class GenericController { suspend fun yield(t: T) {} } -fun generate(p1: P1, p2: List, g: suspend GenericController.(P1, P2) -> R): Four = TODO() +fun generate(p1: P1, p2: List, @BuilderInference g: suspend GenericController.(P1, P2) -> R): Four = TODO() val test1 = generate(1, listOf("")) { p1, p2 -> yield(p1) diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withParameter.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withParameter.txt index 3107d162860..788daae86fc 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withParameter.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withParameter.txt @@ -1,7 +1,7 @@ package public val test1: Four -public fun generate(/*0*/ p1: P1, /*1*/ p2: kotlin.collections.List, /*2*/ g: suspend GenericController.(P1, P2) -> R): Four +public fun generate(/*0*/ p1: P1, /*1*/ p2: kotlin.collections.List, /*2*/ @kotlin.BuilderInference g: suspend GenericController.(P1, P2) -> R): Four public fun listOf(/*0*/ vararg x: X /*kotlin.Array*/): kotlin.collections.List public final class Four { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield_1_2.kt similarity index 94% rename from compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield.kt rename to compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield_1_2.kt index 176544dfabc..eef21a34488 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield_1_2.kt @@ -1,6 +1,7 @@ -// COMMON_COROUTINES_TEST +// !LANGUAGE: -ReleaseCoroutines -ExperimentalBuilderInference +// !DIAGNOSTICS: -EXPERIMENTAL_FEATURE_WARNING // SKIP_TXT -@COROUTINES_PACKAGE.RestrictsSuspension +@kotlin.coroutines.experimental.RestrictsSuspension class RestrictedController { suspend fun yield(x: T) {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield_1_3.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield_1_3.kt new file mode 100644 index 00000000000..78f976ce875 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield_1_3.kt @@ -0,0 +1,99 @@ +// !LANGUAGE: +ReleaseCoroutines +ExperimentalBuilderInference +// !USE_EXPERIMENTAL: kotlin.Experimental +// SKIP_TXT + +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + +@kotlin.coroutines.RestrictsSuspension +class RestrictedController { + suspend fun yield(x: T) {} + + suspend fun anotherYield(x: T) { + yield(x) + this.yield(x) + + yield2(x) + this.yield2(x) + + with(this) { + yield(x) + this@with.yield(x) + + yield2(x) + this@with.yield2(x) + } + } +} + +fun buildSequence(@BuilderInference c: suspend RestrictedController.() -> Unit) {} + +@BuilderInference +suspend fun RestrictedController.yield2(x: T) {} + +fun test() { + buildSequence a@{ + buildSequence b@{ + yield(1) + yield2(1) + this@b.yield(1) + this@b.yield2(1) + + this@a.yield(2) // Should be error + this@a.yield2(2) // Should be error + + with(this) { + yield(3) + this@with.yield(3) + + yield2(3) + this@with.yield2(3) + } + } + } + + buildSequence { + buildSequence { + yield("a") + yield2("a") + this.yield("b") + this.yield2("b") + + yield(1) // Should be error + yield2(1) // Should be error + + with(this) { + yield("") + this@with.yield("") + + yield2("") + this@with.yield2("") + } + } + } + + buildSequence a@{ + yield(1) + yield2(1) + buildSequence { + yield("") + yield2("") + this@a.yield(1) + this@a.yield2(1) + + with(this) { + yield("") + this@with.yield("") + + yield2("") + this@with.yield2("") + } + } + } + + buildSequence { + yield("") + RestrictedController().yield("1") + } +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index 3052ead2857..fe94c34e164 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -2049,14 +2049,14 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/notRelatedFun.kt", "kotlin.coroutines"); } - @TestMetadata("outerYield.kt") + @TestMetadata("outerYield_1_2.kt") public void testOuterYield_1_2() throws Exception { - runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield.kt", "kotlin.coroutines.experimental"); + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield_1_2.kt"); } - @TestMetadata("outerYield.kt") + @TestMetadata("outerYield_1_3.kt") public void testOuterYield_1_3() throws Exception { - runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield.kt", "kotlin.coroutines"); + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield_1_3.kt"); } @TestMetadata("sameInstance.kt") diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index 74577b951f9..d2a121566f0 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -2049,14 +2049,14 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/notRelatedFun.kt", "kotlin.coroutines"); } - @TestMetadata("outerYield.kt") + @TestMetadata("outerYield_1_2.kt") public void testOuterYield_1_2() throws Exception { - runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield.kt", "kotlin.coroutines.experimental"); + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield_1_2.kt"); } - @TestMetadata("outerYield.kt") + @TestMetadata("outerYield_1_3.kt") public void testOuterYield_1_3() throws Exception { - runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield.kt", "kotlin.coroutines"); + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/restrictSuspension/outerYield_1_3.kt"); } @TestMetadata("sameInstance.kt")