Replace expected type for coroutine-lambda
Use 'handleResult' method of controller to determine what lambda should return If original declaration was fun builder(coroutine c: Controller.() -> Continuation<Unit>) = 1 and there is 'fun handleResult(x: X, c: Continuation<Nothing>)', then expected type for lambda is 'Controller.() -> X'
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_VARIABLE
|
||||
class IntController {
|
||||
fun handleResult(x: Int, c: Continuation<Nothing>) { }
|
||||
}
|
||||
|
||||
class GenericController<T> {
|
||||
fun handleResult(x: T, c: Continuation<Nothing>) { }
|
||||
}
|
||||
|
||||
class UnitController {
|
||||
fun handleResult(x: Unit, c: Continuation<Nothing>) { }
|
||||
}
|
||||
|
||||
class EmptyController
|
||||
|
||||
fun builder(coroutine c: IntController.() -> Continuation<Unit>) = 1
|
||||
fun <T> genericBuilder(coroutine c: GenericController<T>.() -> Continuation<Unit>): T = null!!
|
||||
fun unitBuilder(coroutine c: UnitController.() -> Continuation<Unit>) = 1
|
||||
fun emptyBuilder(coroutine c: EmptyController.() -> Continuation<Unit>) = 1
|
||||
|
||||
fun <T> manyArgumentsBuilder(
|
||||
coroutine c1: UnitController.() -> Continuation<Unit>,
|
||||
coroutine c2: GenericController<T>.() -> Continuation<Unit>,
|
||||
coroutine c3: IntController.() -> Continuation<Int>
|
||||
):T = null!!
|
||||
|
||||
fun severalParamsInLambda(coroutine c: UnitController.(String, Int) -> Continuation<Unit>) {}
|
||||
|
||||
fun foo() {
|
||||
builder({ 1 })
|
||||
builder { 1 }
|
||||
|
||||
val x = { 1 }
|
||||
builder(<!TYPE_MISMATCH!>x<!>)
|
||||
builder(<!UNCHECKED_CAST!>{1} as (IntController.() -> Continuation<Unit>)<!>)
|
||||
|
||||
var i: Int = 1
|
||||
i = genericBuilder({ 1 })
|
||||
i = genericBuilder { 1 }
|
||||
<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>genericBuilder<!> { 1 }
|
||||
genericBuilder<Int> { 1 }
|
||||
genericBuilder<Int> { <!TYPE_MISMATCH!>""<!> }
|
||||
|
||||
val y = { 1 }
|
||||
<!TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR!>genericBuilder<!>(<!TYPE_MISMATCH!>y<!>)
|
||||
|
||||
unitBuilder {}
|
||||
unitBuilder { <!UNUSED_EXPRESSION!>1<!> }
|
||||
unitBuilder({})
|
||||
unitBuilder({ <!UNUSED_EXPRESSION!>1<!> })
|
||||
|
||||
<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>manyArgumentsBuilder<!>({}, { "" }) { 1 }
|
||||
|
||||
val s: String = manyArgumentsBuilder({}, { "" }) { 1 }
|
||||
|
||||
manyArgumentsBuilder<String>({}, { "" }, { 1 })
|
||||
manyArgumentsBuilder<String>({}, { <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> }, { 2 })
|
||||
|
||||
severalParamsInLambda { x, y ->
|
||||
x checkType { _<String>() }
|
||||
y checkType { _<Int>() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package
|
||||
|
||||
public fun builder(/*0*/ coroutine c: IntController.() -> kotlin.coroutines.Continuation<kotlin.Unit>): kotlin.Int
|
||||
public fun emptyBuilder(/*0*/ coroutine c: EmptyController.() -> kotlin.coroutines.Continuation<kotlin.Unit>): kotlin.Int
|
||||
public fun foo(): kotlin.Unit
|
||||
public fun </*0*/ T> genericBuilder(/*0*/ coroutine c: GenericController<T>.() -> kotlin.coroutines.Continuation<kotlin.Unit>): T
|
||||
public fun </*0*/ T> manyArgumentsBuilder(/*0*/ coroutine c1: UnitController.() -> kotlin.coroutines.Continuation<kotlin.Unit>, /*1*/ coroutine c2: GenericController<T>.() -> kotlin.coroutines.Continuation<kotlin.Unit>, /*2*/ coroutine c3: IntController.() -> kotlin.coroutines.Continuation<kotlin.Int>): T
|
||||
public fun severalParamsInLambda(/*0*/ coroutine c: UnitController.(kotlin.String, kotlin.Int) -> kotlin.coroutines.Continuation<kotlin.Unit>): kotlin.Unit
|
||||
public fun unitBuilder(/*0*/ coroutine c: UnitController.() -> kotlin.coroutines.Continuation<kotlin.Unit>): kotlin.Int
|
||||
|
||||
public final class EmptyController {
|
||||
public constructor EmptyController()
|
||||
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 final fun handleResult(/*0*/ x: T, /*1*/ c: kotlin.coroutines.Continuation<kotlin.Nothing>): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class IntController {
|
||||
public constructor IntController()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun handleResult(/*0*/ x: kotlin.Int, /*1*/ c: kotlin.coroutines.Continuation<kotlin.Nothing>): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class UnitController {
|
||||
public constructor UnitController()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun handleResult(/*0*/ x: kotlin.Unit, /*1*/ c: kotlin.coroutines.Continuation<kotlin.Nothing>): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user