[NI] Commonize type-conversions (SAM/Suspend)
- Allow participating subtypes of functional types in conversions - Fix several subtle inconsistencies - Place logic about conversions at one place Now conversions operations have two stages: before usual subtyping check and after one. This is needed to support conversions of subtypes (of functional types, for example). First, the compiler checks if it possible to resolve an argument without conversion and only then it tries to perform conversion. Note that it'd be incorrect to perform conversion eagerly as it can change resolve (Runnable & () -> Unit <: KRunnable), plus we can't guess whether conversion is needed at all as it's important not to look into supertypes if resolution doesn't actually needed it #KT-36448 Fixed #KT-37574 Fixed #KT-38604 Fixed
This commit is contained in:
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun useSuspendVararg(vararg sfn: suspend () -> Unit) {}
|
||||
|
||||
fun testSuspendConversionInVarargElementsSome(
|
||||
sf1: suspend () -> Unit,
|
||||
f2: () -> Unit,
|
||||
sf3: suspend () -> Unit
|
||||
) {
|
||||
<!INAPPLICABLE_CANDIDATE!>useSuspendVararg<!>(sf1, f2, sf3)
|
||||
}
|
||||
|
||||
fun testSuspendConversionInVarargElementsAll(
|
||||
f1: () -> Unit,
|
||||
f2: () -> Unit,
|
||||
f3: () -> Unit
|
||||
) {
|
||||
<!INAPPLICABLE_CANDIDATE!>useSuspendVararg<!>(f1, f2, f3)
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !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)
|
||||
}
|
||||
Vendored
+5
@@ -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<out suspend () -> kotlin.Unit>*/): kotlin.Unit
|
||||
Reference in New Issue
Block a user