FIR: initial support of suspend conversion for function reference
This commit is contained in:
committed by
Mikhail Glukhikh
parent
b9243aad24
commit
5a3367e09c
-1
@@ -1,7 +1,6 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
Vendored
-1
@@ -1,7 +1,6 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
Vendored
-1
@@ -1,7 +1,6 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
Vendored
-1
@@ -1,7 +1,6 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
+3
-3
@@ -9,10 +9,10 @@ fun bar2(x: Int) {}
|
||||
fun bar2(s: String) {}
|
||||
|
||||
fun test() {
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(::bar1)
|
||||
foo1(::bar1)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>foo2<!>(42, <!UNRESOLVED_REFERENCE!>::bar2<!>)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo2<!>("str", <!UNRESOLVED_REFERENCE!>::bar2<!>)
|
||||
foo2(42, ::bar2)
|
||||
foo2("str", ::bar2)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>foo2<!>(42, ::bar1)
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -22,7 +22,7 @@ object Test2 {
|
||||
|
||||
fun test() {
|
||||
val result = foo(::bar)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ object Test1 {
|
||||
|
||||
fun test() {
|
||||
val result = foo(::bar)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ object Test2 {
|
||||
|
||||
fun test() {
|
||||
val result = foo(::bar)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Double")!>result<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ fun test(
|
||||
<!INAPPLICABLE_CANDIDATE!>foo2<!>(f2)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo3<!>(f3)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(::bar)
|
||||
foo1(::bar)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(f2)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(f3)
|
||||
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun interface SuspendRunnable {
|
||||
suspend fun invoke()
|
||||
}
|
||||
|
||||
fun foo1(s: SuspendRunnable) {}
|
||||
fun bar1() {}
|
||||
|
||||
fun bar2(s: String = ""): Int = 0
|
||||
|
||||
fun bar3() {}
|
||||
suspend fun bar3(s: String = ""): Int = 0
|
||||
|
||||
fun test() {
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(::bar1)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(::bar2)
|
||||
|
||||
foo1(::bar3) // Should be ambiguity
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
|
||||
+3
-3
@@ -14,8 +14,8 @@ fun unitCoercionAndDefaults(f: suspend () -> Unit) {}
|
||||
fun all(s: String = ""): Int = 0
|
||||
|
||||
fun test() {
|
||||
<!INAPPLICABLE_CANDIDATE!>unitCoercion<!>(::foo)
|
||||
<!INAPPLICABLE_CANDIDATE!>defaults<!>(::bar)
|
||||
unitCoercion(::foo)
|
||||
defaults(::bar)
|
||||
<!INAPPLICABLE_CANDIDATE!>varargs<!>(::baz)
|
||||
<!INAPPLICABLE_CANDIDATE!>unitCoercionAndDefaults<!>(::all)
|
||||
unitCoercionAndDefaults(::all)
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,5 +14,5 @@ abstract class SubInt : () -> Int
|
||||
fun test(f: () -> String, s: SubInt) {
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(f)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(s)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(::bar)
|
||||
foo(::bar)
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ fun bar(): String = ""
|
||||
abstract class SubInt : () -> Int
|
||||
|
||||
fun test(g: () -> Double, s: SubInt) {
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(::bar)
|
||||
foo(::bar)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(g)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(s)
|
||||
}
|
||||
+33
-13
@@ -59,30 +59,50 @@ FILE fqName:<root> fileName:/suspendConversion.kt
|
||||
fn: FUNCTION_REFERENCE 'public final fun foo0 (): kotlin.Unit [suspend] declared in <root>' type=kotlin.reflect.KSuspendFunction0<kotlin.Unit> origin=null reflectionTarget=<same>
|
||||
FUN name:testSuspendPlain visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [/useSuspend]>#' type=IrErrorType
|
||||
FUNCTION_REFERENCE 'public final fun foo1 (): kotlin.Unit declared in <root>' type=kotlin.reflect.KFunction0<kotlin.Unit> origin=null reflectionTarget=<same>
|
||||
CALL 'public final fun useSuspend (fn: kotlin.coroutines.SuspendFunction0<kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
fn: FUN_EXPR type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
|
||||
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo1 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend]
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun foo1 (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
FUN name:testSuspendWithArgs visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [/useSuspendInt]>#' type=IrErrorType
|
||||
FUNCTION_REFERENCE 'public final fun fooInt (x: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.reflect.KFunction1<kotlin.Int, kotlin.Unit> origin=null reflectionTarget=<same>
|
||||
CALL 'public final fun useSuspendInt (fn: kotlin.coroutines.SuspendFunction1<kotlin.Int, kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
fn: FUN_EXPR type=kotlin.coroutines.SuspendFunction1<kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
|
||||
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fooInt visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit [suspend]
|
||||
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun fooInt (x: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
x: GET_VAR 'p0: kotlin.Int declared in <root>.testSuspendWithArgs.fooInt' type=kotlin.Int origin=null
|
||||
FUN name:testWithVararg visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [/useSuspend]>#' type=IrErrorType
|
||||
FUNCTION_REFERENCE 'public final fun foo2 (vararg xs: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.reflect.KFunction1<kotlin.IntArray, kotlin.Unit> origin=null reflectionTarget=<same>
|
||||
CALL 'public final fun useSuspend (fn: kotlin.coroutines.SuspendFunction0<kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
fn: FUN_EXPR type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
|
||||
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo2 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend]
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun foo2 (vararg xs: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
FUN name:testWithVarargMapped visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [/useSuspendInt]>#' type=IrErrorType
|
||||
FUNCTION_REFERENCE 'public final fun foo2 (vararg xs: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.reflect.KFunction1<kotlin.IntArray, kotlin.Unit> origin=null reflectionTarget=<same>
|
||||
FUN name:testWithCoercionToUnit visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [/useSuspend]>#' type=IrErrorType
|
||||
FUNCTION_REFERENCE 'public final fun foo3 (): kotlin.Int declared in <root>' type=kotlin.reflect.KFunction0<kotlin.Int> origin=null reflectionTarget=<same>
|
||||
CALL 'public final fun useSuspend (fn: kotlin.coroutines.SuspendFunction0<kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
fn: FUN_EXPR type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
|
||||
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo3 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun foo3 (): kotlin.Unit [suspend] declared in <root>.testWithCoercionToUnit'
|
||||
CALL 'public final fun foo3 (): kotlin.Int declared in <root>' type=kotlin.Int origin=null
|
||||
FUN name:testWithDefaults visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [/useSuspend]>#' type=IrErrorType
|
||||
FUNCTION_REFERENCE 'public final fun foo4 (i: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.reflect.KFunction1<kotlin.Int, kotlin.Unit> origin=null reflectionTarget=<same>
|
||||
CALL 'public final fun useSuspend (fn: kotlin.coroutines.SuspendFunction0<kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
fn: FUN_EXPR type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
|
||||
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo4 visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend]
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun foo4 (i: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
FUN name:testWithBoundReceiver visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [/useSuspend]>#' type=IrErrorType
|
||||
FUNCTION_REFERENCE 'public final fun bar (): kotlin.Unit declared in <root>.C' type=kotlin.reflect.KFunction0<kotlin.Unit> origin=null reflectionTarget=<same>
|
||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.C' type=<root>.C origin=null
|
||||
CALL 'public final fun useSuspend (fn: kotlin.coroutines.SuspendFunction0<kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
fn: FUN_EXPR type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
|
||||
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:bar visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend]
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun bar (): kotlin.Unit declared in <root>.C' type=kotlin.Unit origin=null
|
||||
|
||||
Reference in New Issue
Block a user