FIR: Properly build nullable suspend function types, and aggregate
modifiers and annotations within KtTypeReference/REFERENCE_TYPE nodes.
This commit is contained in:
committed by
TeamCityServer
parent
9cf5ac1fbd
commit
9a4742c08d
+23
@@ -0,0 +1,23 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: COROUTINES
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
|
||||
fun runSuspend(c: (suspend () -> Unit)?) {
|
||||
c?.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
var test = "failed"
|
||||
|
||||
fun foo() { test = "OK" }
|
||||
|
||||
fun box(): String {
|
||||
runSuspend(::foo)
|
||||
return test
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
suspend fun suspendHere(): String = suspendCoroutineUninterceptedOrReturn { x ->
|
||||
x.resume("OK")
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
|
||||
fun builder(c: (suspend () -> Unit)?) {
|
||||
c?.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
|
||||
builder(null)
|
||||
builder {
|
||||
result = suspendHere()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
+20
@@ -1,6 +1,12 @@
|
||||
fun useSuspend(fn: SuspendFunction0<Unit>) {
|
||||
}
|
||||
|
||||
fun useSuspendNullable(fn: SuspendFunction0<Unit>?) {
|
||||
}
|
||||
|
||||
fun useSuspendNestedNullable(fn: SuspendFunction0<Unit>?) {
|
||||
}
|
||||
|
||||
fun useSuspendInt(fn: SuspendFunction1<Int, Unit>) {
|
||||
}
|
||||
|
||||
@@ -97,3 +103,17 @@ fun testWithBoundReceiver() {
|
||||
C()::bar
|
||||
})
|
||||
}
|
||||
|
||||
fun testNullableParam() {
|
||||
useSuspendNullable(fn = local suspend fun foo1() {
|
||||
foo1()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testNestedNullableParam() {
|
||||
useSuspendNestedNullable(fn = local suspend fun foo1() {
|
||||
foo1()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
+20
@@ -2,6 +2,12 @@ FILE fqName:<root> fileName:/suspendConversion.kt
|
||||
FUN name:useSuspend visibility:public modality:FINAL <> (fn:kotlin.coroutines.SuspendFunction0<kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:fn index:0 type:kotlin.coroutines.SuspendFunction0<kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
FUN name:useSuspendNullable visibility:public modality:FINAL <> (fn:kotlin.coroutines.SuspendFunction0<kotlin.Unit>?) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:fn index:0 type:kotlin.coroutines.SuspendFunction0<kotlin.Unit>?
|
||||
BLOCK_BODY
|
||||
FUN name:useSuspendNestedNullable visibility:public modality:FINAL <> (fn:kotlin.coroutines.SuspendFunction0<kotlin.Unit>?) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:fn index:0 type:kotlin.coroutines.SuspendFunction0<kotlin.Unit>?
|
||||
BLOCK_BODY
|
||||
FUN name:useSuspendInt visibility:public modality:FINAL <> (fn:kotlin.coroutines.SuspendFunction1<kotlin.Int, kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:fn index:0 type:kotlin.coroutines.SuspendFunction1<kotlin.Int, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
@@ -115,3 +121,17 @@ FILE fqName:<root> fileName:/suspendConversion.kt
|
||||
$this: GET_VAR 'receiver: <root>.C declared in <root>.testWithBoundReceiver.bar' type=<root>.C origin=ADAPTED_FUNCTION_REFERENCE
|
||||
FUNCTION_REFERENCE 'local final fun bar (): kotlin.Unit [suspend] declared in <root>.testWithBoundReceiver' type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null
|
||||
$receiver: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.C' type=<root>.C origin=null
|
||||
FUN name:testNullableParam visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun useSuspendNullable (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:testNestedNullableParam visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun useSuspendNestedNullable (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
|
||||
|
||||
+7
-1
@@ -1,6 +1,8 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
|
||||
fun useSuspend(fn: suspend () -> Unit) {}
|
||||
fun useSuspendNullable(fn: (suspend () -> Unit)?) {}
|
||||
fun useSuspendNestedNullable(fn: ((suspend () -> Unit)?)?) {}
|
||||
fun useSuspendInt(fn: suspend (Int) -> Unit) {}
|
||||
|
||||
suspend fun foo0() {}
|
||||
@@ -30,4 +32,8 @@ fun testWithCoercionToUnit() { useSuspend(::foo3) }
|
||||
|
||||
fun testWithDefaults() { useSuspend(::foo4) }
|
||||
|
||||
fun testWithBoundReceiver() { useSuspend(C()::bar) }
|
||||
fun testWithBoundReceiver() { useSuspend(C()::bar) }
|
||||
|
||||
fun testNullableParam() { useSuspendNullable(::foo1) }
|
||||
|
||||
fun testNestedNullableParam() { useSuspendNestedNullable(::foo1) }
|
||||
+25
@@ -1,6 +1,12 @@
|
||||
fun useSuspend(fn: SuspendFunction0<Unit>) {
|
||||
}
|
||||
|
||||
fun useSuspendNullable(fn: SuspendFunction0<Unit>?) {
|
||||
}
|
||||
|
||||
fun useSuspendNestedNullable(fn: SuspendFunction0<Unit>?) {
|
||||
}
|
||||
|
||||
fun useSuspendInt(fn: SuspendFunction1<Int, Unit>) {
|
||||
}
|
||||
|
||||
@@ -116,3 +122,22 @@ fun testWithBoundReceiver() {
|
||||
})
|
||||
}
|
||||
|
||||
fun testNullableParam() {
|
||||
useSuspendNullable(fn = { // BLOCK
|
||||
local suspend fun foo1() {
|
||||
foo1()
|
||||
}
|
||||
|
||||
::foo1
|
||||
})
|
||||
}
|
||||
|
||||
fun testNestedNullableParam() {
|
||||
useSuspendNestedNullable(fn = { // BLOCK
|
||||
local suspend fun foo1() {
|
||||
foo1()
|
||||
}
|
||||
|
||||
::foo1
|
||||
})
|
||||
}
|
||||
|
||||
+22
@@ -2,6 +2,12 @@ FILE fqName:<root> fileName:/suspendConversion.kt
|
||||
FUN name:useSuspend visibility:public modality:FINAL <> (fn:kotlin.coroutines.SuspendFunction0<kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:fn index:0 type:kotlin.coroutines.SuspendFunction0<kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
FUN name:useSuspendNullable visibility:public modality:FINAL <> (fn:kotlin.coroutines.SuspendFunction0<kotlin.Unit>?) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:fn index:0 type:kotlin.coroutines.SuspendFunction0<kotlin.Unit>?
|
||||
BLOCK_BODY
|
||||
FUN name:useSuspendNestedNullable visibility:public modality:FINAL <> (fn:kotlin.coroutines.SuspendFunction0<kotlin.Unit>?) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:fn index:0 type:kotlin.coroutines.SuspendFunction0<kotlin.Unit>?
|
||||
BLOCK_BODY
|
||||
FUN name:useSuspendInt visibility:public modality:FINAL <> (fn:kotlin.coroutines.SuspendFunction1<kotlin.Int, kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:fn index:0 type:kotlin.coroutines.SuspendFunction1<kotlin.Int, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
@@ -122,3 +128,19 @@ FILE fqName:<root> fileName:/suspendConversion.kt
|
||||
$this: GET_VAR 'receiver: <root>.C declared in <root>.testWithBoundReceiver.bar' type=<root>.C origin=ADAPTED_FUNCTION_REFERENCE
|
||||
FUNCTION_REFERENCE 'local final fun bar (): kotlin.Unit [suspend] declared in <root>.testWithBoundReceiver' type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun bar (): kotlin.Unit declared in <root>.C
|
||||
$receiver: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.C' type=<root>.C origin=null
|
||||
FUN name:testNullableParam visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun useSuspendNullable (fn: kotlin.coroutines.SuspendFunction0<kotlin.Unit>?): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
fn: BLOCK 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
|
||||
FUNCTION_REFERENCE 'local final fun foo1 (): kotlin.Unit [suspend] declared in <root>.testNullableParam' type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo1 (): kotlin.Unit declared in <root>
|
||||
FUN name:testNestedNullableParam visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun useSuspendNestedNullable (fn: kotlin.coroutines.SuspendFunction0<kotlin.Unit>?): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
fn: BLOCK 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
|
||||
FUNCTION_REFERENCE 'local final fun foo1 (): kotlin.Unit [suspend] declared in <root>.testNestedNullableParam' type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo1 (): kotlin.Unit declared in <root>
|
||||
|
||||
Reference in New Issue
Block a user