Support type inference for coroutines.

This commit is contained in:
Stanislav Erokhin
2016-12-08 13:49:30 +03:00
committed by Stanislav Erokhin
parent 509a504318
commit 55983a7808
29 changed files with 848 additions and 3 deletions
@@ -0,0 +1,20 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
interface Controller<T> {
suspend fun yield(t: T) {}
fun justString(): String = ""
fun <Z> generidFun(t: Z) = t
}
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
val test1 = generate {
yield(justString())
}
val test2 = generate {
yield(generidFun(2))
}
@@ -0,0 +1,14 @@
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 interface Controller</*0*/ T> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open fun </*0*/ Z> generidFun(/*0*/ t: Z): Z
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open fun justString(): kotlin.String
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public open suspend fun yield(/*0*/ t: T): kotlin.Unit
}
@@ -0,0 +1,21 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
class GenericController<T>
suspend fun <S> GenericController<S>.yieldAll(s: Collection<S>): String = ""
suspend fun <S> GenericController<S>.yieldAll(s: Set<S>): Int = 4
fun <T, R> generate(g: suspend GenericController<T>.() -> R): Pair<T, R> = TODO()
val test1 = generate {
yieldAll(setOf(4))
}
val test2 = generate {
yieldAll(listOf(4))
}
// Util function
fun <X> setOf(vararg x: X): Set<X> = TODO()
fun <X> listOf(vararg x: X): List<X> = TODO()
class Pair<T, S>
@@ -0,0 +1,23 @@
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*/ 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
public final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Pair</*0*/ T, /*1*/ S> {
public constructor Pair</*0*/ T, /*1*/ S>()
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
}
@@ -0,0 +1,37 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
class GenericController<T> {
suspend fun yield(t: T) {}
}
suspend fun <S> GenericController<S>.yieldAll(s: Collection<S>) {}
fun <S> generate(g: suspend GenericController<S>.() -> Unit): S = TODO()
val test1 = generate {
yield(4)
yieldAll(setOf(4, 5))
}
val test2 = generate {
yieldAll(setOf(B))
}
val test3 = generate {
yieldAll(setOf(B, C))
}
val test4 = generate {
yieldAll(setOf(B))
yield(C)
}
// Utils
fun <X> setOf(vararg x: X): Set<X> = TODO()
interface A
object B : A
object C : A
@@ -0,0 +1,37 @@
package
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*/ 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.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public object B : A {
private constructor B()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public object C : A {
private constructor C()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final suspend fun yield(/*0*/ t: T): kotlin.Unit
}
@@ -0,0 +1,30 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
class GenericController<T> {
suspend fun yield(t: T) {}
fun notYield(t: T) {}
suspend fun yieldBarReturnType(t: T) = t
fun barReturnType(): T = TODO()
}
fun <S> generate(g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
val test1 = generate {
yield(3)
}
val test2 = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
yield(3)
notYield(3)
}
val test3 = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
yield(3)
yieldBarReturnType(3)
}
val test4 = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
yield(3)
barReturnType()
}
@@ -0,0 +1,27 @@
package
public val test1: kotlin.collections.List<kotlin.Int>
public val test2: [ERROR : Type for generate {
yield(3)
notYield(3)
}]
public val test3: [ERROR : Type for generate {
yield(3)
yieldBarReturnType(3)
}]
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 final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
public final fun barReturnType(): T
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 notYield(/*0*/ t: T): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final suspend fun yield(/*0*/ t: T): kotlin.Unit
public final suspend fun yieldBarReturnType(/*0*/ t: T): T
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
class GenericController<T> {
suspend fun yield(t: T) {}
}
fun <S> generate(g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
val test1 = generate {
yield(generate {
yield(generate {
yield(generate {
yield(3)
})
})
})
}
@@ -0,0 +1,12 @@
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 final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final suspend fun yield(/*0*/ t: T): kotlin.Unit
}
@@ -0,0 +1,16 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
class GenericController<T> {
suspend fun yield(t: T) {}
}
fun <S> generate(g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
suspend fun <S> GenericController<List<S>>.yieldGenerate(g: suspend GenericController<S>.() -> Unit): Unit = TODO()
val test1 = generate {
// TODO: KT-15185
<!TYPE_MISMATCH, TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR!>yieldGenerate<!> {
yield(4)
}
}
@@ -0,0 +1,13 @@
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 final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final suspend fun yield(/*0*/ t: T): kotlin.Unit
}
@@ -0,0 +1,9 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
class Controller
fun <R> generate(g: suspend Controller.() -> R): R = TODO()
val test1 = generate {
3
}
@@ -0,0 +1,11 @@
package
public val test1: kotlin.Int
public fun </*0*/ R> generate(/*0*/ g: suspend Controller.() -> R): R
public final class Controller {
public constructor Controller()
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
}
@@ -0,0 +1,14 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
class Controller<T> {
suspend fun yield(t: T) {}
}
fun <T, R> generate(g: suspend Controller<T>.() -> R): Pair<T, R> = TODO()
val test1 = generate {
yield("")
3
}
class Pair<T, R>
@@ -0,0 +1,19 @@
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 final class Controller</*0*/ T> {
public constructor Controller</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final suspend fun yield(/*0*/ t: T): kotlin.Unit
}
public final class Pair</*0*/ T, /*1*/ R> {
public constructor Pair</*0*/ T, /*1*/ R>()
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
}
@@ -0,0 +1,29 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
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()
val test1 = generate {
yield(4)
}
val test2 = generate {
yieldSet(setOf(1, 2, 3))
}
val test3 = generate {
yieldVararg(1, 2, 3)
}
val test4 = generate {
yieldVararg(1, 2, "")
}
// Util function
fun <X> setOf(vararg x: X): Set<X> = TODO()
@@ -0,0 +1,18 @@
package
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*/ X> setOf(/*0*/ vararg x: X /*kotlin.Array<out X>*/): kotlin.collections.Set<X>
public final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final suspend fun yield(/*0*/ t: T): kotlin.Unit
public final suspend fun yieldSet(/*0*/ t: kotlin.collections.Set<T>): kotlin.Unit
public final suspend fun yieldVararg(/*0*/ vararg t: T /*kotlin.Array<out T>*/): kotlin.Unit
}
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
class GenericController<T>
fun <S> generate(g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
suspend fun GenericController<List<String>>.test() {}
val test1 = generate {
test()
}
@@ -0,0 +1,12 @@
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 final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
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
}
@@ -0,0 +1,16 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
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()
val test1 = generate(1, listOf("")) { p1, p2 ->
yield(p1)
p2
}
fun <X> listOf(vararg x: X): List<X> = TODO()
class Four<X, Y, Z, T>
@@ -0,0 +1,20 @@
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*/ 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> {
public constructor Four</*0*/ X, /*1*/ Y, /*2*/ Z, /*3*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final suspend fun yield(/*0*/ t: T): kotlin.Unit
}
@@ -0,0 +1,19 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
class GenericController<T> {
suspend fun yield(t: T) {}
}
fun <S> generate(g: suspend GenericController<S>.(S) -> Unit): S = TODO()
val test1 = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
yield(4)
}
val test2 = generate<Int> {
yield(4)
}
val test3 = generate { bar: Int ->
yield(4)
}
@@ -0,0 +1,16 @@
package
public val test1: [ERROR : Type for generate {
yield(4)
}]
public val test2: kotlin.Int
public val test3: kotlin.Int
public fun </*0*/ S> generate(/*0*/ g: suspend GenericController<S>.(S) -> kotlin.Unit): S
public final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final suspend fun yield(/*0*/ t: T): kotlin.Unit
}