Fix diagnostic tests about coroutine-inference

This commit is contained in:
Mikhail Zarechenskiy
2018-09-24 12:56:52 +03:00
parent 3142627269
commit 7c1d374ed5
26 changed files with 199 additions and 42 deletions
@@ -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<T> {
suspend fun yield(t: T) {}
@@ -8,7 +13,7 @@ interface Controller<T> {
fun <Z> generidFun(t: Z) = t
}
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
fun <S> generate(@BuilderInference g: suspend Controller<S>.() -> Unit): S = TODO()
val test1 = generate {
yield(justString())
@@ -2,7 +2,7 @@ package
public val test1: kotlin.String
public val test2: kotlin.Int
public fun </*0*/ S> generate(/*0*/ g: suspend Controller<S>.() -> kotlin.Unit): S
public fun </*0*/ S> generate(/*0*/ @kotlin.BuilderInference g: suspend Controller<S>.() -> kotlin.Unit): S
public interface Controller</*0*/ T> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@@ -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<T>
@BuilderInference
suspend fun <S> GenericController<S>.yieldAll(s: Collection<S>): String = ""
@BuilderInference
suspend fun <S> GenericController<S>.yieldAll(s: Set<S>): Int = 4
fun <T, R> generate(g: suspend GenericController<T>.() -> R): Pair<T, R> = TODO()
fun <T, R> generate(@BuilderInference g: suspend GenericController<T>.() -> R): Pair<T, R> = TODO()
val test1 = generate {
yieldAll(setOf(4))
@@ -2,11 +2,11 @@ package
public val test1: Pair<kotlin.Int, kotlin.Int>
public val test2: Pair<kotlin.Int, kotlin.String>
public fun </*0*/ T, /*1*/ R> generate(/*0*/ g: suspend GenericController<T>.() -> R): Pair<T, R>
public fun </*0*/ T, /*1*/ R> generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController<T>.() -> R): Pair<T, R>
public fun </*0*/ X> listOf(/*0*/ vararg x: X /*kotlin.Array<out X>*/): kotlin.collections.List<X>
public fun </*0*/ X> setOf(/*0*/ vararg x: X /*kotlin.Array<out X>*/): kotlin.collections.Set<X>
public suspend fun </*0*/ S> GenericController<S>.yieldAll(/*0*/ s: kotlin.collections.Collection<S>): kotlin.String
public suspend fun </*0*/ S> GenericController<S>.yieldAll(/*0*/ s: kotlin.collections.Set<S>): kotlin.Int
@kotlin.BuilderInference public suspend fun </*0*/ S> GenericController<S>.yieldAll(/*0*/ s: kotlin.collections.Collection<S>): kotlin.String
@kotlin.BuilderInference public suspend fun </*0*/ S> GenericController<S>.yieldAll(/*0*/ s: kotlin.collections.Set<S>): kotlin.Int
public final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
@@ -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<T> {
suspend fun yield(t: T) {}
}
@BuilderInference
suspend fun <K> GenericController<K>.yieldAll(s: Collection<K>) {}
fun <S> generate(g: suspend GenericController<S>.() -> Unit): S = TODO()
fun <S> generate(@BuilderInference g: suspend GenericController<S>.() -> Unit): S = TODO()
val test1 = generate {
yield(4)
@@ -4,9 +4,9 @@ public val test1: kotlin.Int
public val test2: B
public val test3: A
public val test4: A
public fun </*0*/ S> generate(/*0*/ g: suspend GenericController<S>.() -> kotlin.Unit): S
public fun </*0*/ S> generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController<S>.() -> kotlin.Unit): S
public fun </*0*/ X> setOf(/*0*/ vararg x: X /*kotlin.Array<out X>*/): kotlin.collections.Set<X>
public suspend fun </*0*/ K> GenericController<K>.yieldAll(/*0*/ s: kotlin.collections.Collection<K>): kotlin.Unit
@kotlin.BuilderInference public suspend fun </*0*/ K> GenericController<K>.yieldAll(/*0*/ s: kotlin.collections.Collection<K>): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@@ -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<T> {
suspend fun yield(t: T) {}
fun notYield(t: T) {}
@@ -10,13 +15,13 @@ class GenericController<T> {
fun barReturnType(): T = TODO()
}
fun <S> generate(g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
fun <S> generate(@BuilderInference g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
val test1 = generate {
yield(3)
}
val test2 = <!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
val test2 = generate {
yield(3)
notYield(3)
}
@@ -1,10 +1,7 @@
package
public val test1: kotlin.collections.List<kotlin.Int>
public val test2: [ERROR : Type for generate {
yield(3)
notYield(3)
}]
public val test2: kotlin.collections.List<kotlin.Int>
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 </*0*/ S> generate(/*0*/ g: suspend GenericController<S>.() -> kotlin.Unit): kotlin.collections.List<S>
public fun </*0*/ S> generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController<S>.() -> kotlin.Unit): kotlin.collections.List<S>
public final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
@@ -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<T> {
suspend fun yield(t: T) {}
}
fun <S> generate(g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
fun <S> generate(@BuilderInference g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
val test1 = generate {
yield(generate {
@@ -1,7 +1,7 @@
package
public val test1: kotlin.collections.List<kotlin.collections.List<kotlin.collections.List<kotlin.collections.List<kotlin.Int>>>>
public fun </*0*/ S> generate(/*0*/ g: suspend GenericController<S>.() -> kotlin.Unit): kotlin.collections.List<S>
public fun </*0*/ S> generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController<S>.() -> kotlin.Unit): kotlin.collections.List<S>
public final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
@@ -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<T> {
suspend fun yield(t: T) {}
}
fun <S> generate(g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
fun <S> generate(@BuilderInference g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
@BuilderInference
suspend fun <S> GenericController<List<S>>.yieldGenerate(g: suspend GenericController<S>.() -> Unit): Unit = TODO()
val test1 = generate {
@@ -1,8 +1,8 @@
package
public val test1: kotlin.collections.List<kotlin.Int>
public fun </*0*/ S> generate(/*0*/ g: suspend GenericController<S>.() -> kotlin.Unit): kotlin.collections.List<S>
public suspend fun </*0*/ S> GenericController<kotlin.collections.List<S>>.yieldGenerate(/*0*/ g: suspend GenericController<S>.() -> kotlin.Unit): kotlin.Unit
public fun </*0*/ S> generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController<S>.() -> kotlin.Unit): kotlin.collections.List<S>
@kotlin.BuilderInference public suspend fun </*0*/ S> GenericController<kotlin.collections.List<S>>.yieldGenerate(/*0*/ g: suspend GenericController<S>.() -> kotlin.Unit): kotlin.Unit
public final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
@@ -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<T> {
suspend fun yield(t: T) {}
}
fun <T, R> generate(g: suspend Controller<T>.() -> R): Pair<T, R> = TODO()
fun <T, R> generate(@BuilderInference g: suspend Controller<T>.() -> R): Pair<T, R> = TODO()
val test1 = generate {
yield("")
@@ -1,7 +1,7 @@
package
public val test1: Pair<kotlin.String, kotlin.Int>
public fun </*0*/ T, /*1*/ R> generate(/*0*/ g: suspend Controller<T>.() -> R): Pair<T, R>
public fun </*0*/ T, /*1*/ R> generate(/*0*/ @kotlin.BuilderInference g: suspend Controller<T>.() -> R): Pair<T, R>
public final class Controller</*0*/ T> {
public constructor Controller</*0*/ T>()
@@ -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<T> {
suspend fun yield(t: T) {}
suspend fun yieldSet(t: Set<T>) {}
suspend fun yieldVararg(vararg t: T) {}
}
fun <S> generate(g: suspend GenericController<S>.() -> Unit): S = TODO()
fun <S> generate(@BuilderInference g: suspend GenericController<S>.() -> Unit): S = TODO()
val test1 = generate {
yield(4)
@@ -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 </*0*/ S> generate(/*0*/ g: suspend GenericController<S>.() -> kotlin.Unit): S
public fun </*0*/ S> generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController<S>.() -> kotlin.Unit): S
public fun </*0*/ X> setOf(/*0*/ vararg x: X /*kotlin.Array<out X>*/): kotlin.collections.Set<X>
public final class GenericController</*0*/ T> {
@@ -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<T> {
suspend fun yield(t: T) {}
}
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
fun <S> generate(@BuilderInference g: suspend Controller<S>.() -> Unit): S = TODO()
class A
@@ -4,7 +4,7 @@ public val test1: [ERROR : Type for generate {
yield(A)
}]
public val test2: kotlin.Int
public fun </*0*/ S> generate(/*0*/ g: suspend Controller<S>.() -> kotlin.Unit): S
public fun </*0*/ S> generate(/*0*/ @kotlin.BuilderInference g: suspend Controller<S>.() -> kotlin.Unit): S
public final class A {
public constructor A()
@@ -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<T>
fun <S> generate(g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
fun <S> generate(@BuilderInference g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
@BuilderInference
suspend fun GenericController<List<String>>.test() {}
val test1 = generate {
@@ -1,8 +1,8 @@
package
public val test1: kotlin.collections.List<kotlin.collections.List<kotlin.String>>
public fun </*0*/ S> generate(/*0*/ g: suspend GenericController<S>.() -> kotlin.Unit): kotlin.collections.List<S>
public suspend fun GenericController<kotlin.collections.List<kotlin.String>>.test(): kotlin.Unit
public fun </*0*/ S> generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController<S>.() -> kotlin.Unit): kotlin.collections.List<S>
@kotlin.BuilderInference public suspend fun GenericController<kotlin.collections.List<kotlin.String>>.test(): kotlin.Unit
public final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
@@ -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<T> {
suspend fun yield(t: T) {}
}
fun <S, P1, P2, R> generate(p1: P1, p2: List<P2>, g: suspend GenericController<S>.(P1, P2) -> R): Four<S, P1, P2, R> = TODO()
fun <S, P1, P2, R> generate(p1: P1, p2: List<P2>, @BuilderInference g: suspend GenericController<S>.(P1, P2) -> R): Four<S, P1, P2, R> = TODO()
val test1 = generate(1, listOf("")) { p1, p2 ->
yield(p1)
@@ -1,7 +1,7 @@
package
public val test1: Four<kotlin.Int, kotlin.Int, kotlin.String, kotlin.String>
public fun </*0*/ S, /*1*/ P1, /*2*/ P2, /*3*/ R> generate(/*0*/ p1: P1, /*1*/ p2: kotlin.collections.List<P2>, /*2*/ g: suspend GenericController<S>.(P1, P2) -> R): Four<S, P1, P2, R>
public fun </*0*/ S, /*1*/ P1, /*2*/ P2, /*3*/ R> generate(/*0*/ p1: P1, /*1*/ p2: kotlin.collections.List<P2>, /*2*/ @kotlin.BuilderInference g: suspend GenericController<S>.(P1, P2) -> R): Four<S, P1, P2, R>
public fun </*0*/ X> listOf(/*0*/ vararg x: X /*kotlin.Array<out X>*/): kotlin.collections.List<X>
public final class Four</*0*/ X, /*1*/ Y, /*2*/ Z, /*3*/ T> {
@@ -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<T> {
suspend fun yield(<!UNUSED_PARAMETER!>x<!>: T) {}
@@ -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<T> {
suspend fun yield(<!UNUSED_PARAMETER!>x<!>: T) {}
suspend fun anotherYield(x: T) {
yield(x)
this.yield(x)
yield2(x)
this.yield2(x)
with(this) {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield<!>(x)
this@with.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield<!>(x)
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield2<!>(x)
this@with.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield2<!>(x)
}
}
}
fun <T> buildSequence(@BuilderInference <!UNUSED_PARAMETER!>c<!>: suspend RestrictedController<T>.() -> Unit) {}
@BuilderInference
suspend fun <T> RestrictedController<T>.yield2(<!UNUSED_PARAMETER!>x<!>: T) {}
fun test() {
buildSequence<Int> a@{
buildSequence<Int> b@{
yield(1)
yield2(1)
this@b.yield(1)
this@b.yield2(1)
this@a.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield<!>(2) // Should be error
this@a.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield2<!>(2) // Should be error
with(this) {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield<!>(3)
this@with.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield<!>(3)
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield2<!>(3)
this@with.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield2<!>(3)
}
}
}
buildSequence<Int> {
buildSequence<String> {
yield("a")
yield2("a")
this.yield("b")
this.yield2("b")
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield<!>(1) // Should be error
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield2<!>(1) // Should be error
with(this) {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield<!>("")
this@with.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield<!>("")
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield2<!>("")
this@with.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield2<!>("")
}
}
}
buildSequence<Int> a@{
yield(1)
yield2(1)
buildSequence {
yield("")
yield2("")
this@a.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield<!>(1)
this@a.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield2<!>(1)
with(this) {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield<!>("")
this@with.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield<!>("")
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield2<!>("")
this@with.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield2<!>("")
}
}
}
buildSequence<String> {
yield("")
RestrictedController<String>().<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>yield<!>("1")
}
}