Prohibit using suspend functions as SAM in fun interfaces
#KT-40978 Fixed
This commit is contained in:
+1
-1
@@ -71,7 +71,7 @@ interface BaseWithGeneric {
|
||||
fun interface GoodExtensionGeneric : GoodGeneric<String>
|
||||
|
||||
fun interface GoodSuspend {
|
||||
suspend fun invoke()
|
||||
<!FUN_INTERFACE_WITH_SUSPEND_FUNCTION!>suspend<!> fun invoke()
|
||||
}
|
||||
|
||||
class WithNestedFun<K> {
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// !LANGUAGE: +NewInference +SamConversionForKotlinFunctions +SamConversionPerArgument +FunctionalInterfaceConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -NOTHING_TO_INLINE
|
||||
|
||||
fun interface SuspendRunnable {
|
||||
suspend fun invoke()
|
||||
}
|
||||
|
||||
fun run(r: SuspendRunnable) {}
|
||||
|
||||
suspend fun bar() {}
|
||||
|
||||
fun test() {
|
||||
run(::bar)
|
||||
}
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference +SamConversionForKotlinFunctions +SamConversionPerArgument +FunctionalInterfaceConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -NOTHING_TO_INLINE
|
||||
|
||||
fun interface SuspendRunnable {
|
||||
suspend fun invoke()
|
||||
<!FUN_INTERFACE_WITH_SUSPEND_FUNCTION!>suspend<!> fun invoke()
|
||||
}
|
||||
|
||||
fun run(r: SuspendRunnable) {}
|
||||
|
||||
Reference in New Issue
Block a user