From 0bd7de158c52fb2cf5b328c85dbd0b2496f621df Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Fri, 11 Sep 2020 23:05:17 -0700 Subject: [PATCH] FIR: update suspend lambda type during declaration resolution --- .../body/resolve/FirDeclarationsResolveTransformer.kt | 7 ++++++- .../codegen/box/coroutines/debug/firstSuspensionPoint.kt | 4 ++-- .../coroutines/featureIntersection/suspendFunctionIsAs.kt | 1 - .../box/coroutines/localFunctions/named/insideLambda.kt | 1 - .../box/coroutines/suspendFunctionTypeCall/localVal.kt | 1 - 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 3cb8befe0ac..af6ed4f9a79 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.fir.resolve.calls.InaccessibleImplicitReceiverValue import org.jetbrains.kotlin.fir.resolve.dfa.FirControlFlowGraphReferenceImpl import org.jetbrains.kotlin.fir.resolve.inference.FirDelegatedPropertyInferenceSession import org.jetbrains.kotlin.fir.resolve.inference.extractLambdaInfoFromFunctionalType +import org.jetbrains.kotlin.fir.resolve.inference.isSuspendFunctionType import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.transformers.* import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope @@ -768,7 +769,11 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor inferenceComponents.ctx.commonSuperTypeOrNull(returnTypes) ?: session.builtinTypes.unitType.type ) ) - af.replaceTypeRef(af.constructFunctionalTypeRef()) + af.replaceTypeRef( + af.constructFunctionalTypeRef( + isSuspend = expectedTypeRef.coneTypeSafe()?.isSuspendFunctionType(session) == true + ) + ) af.addReturn().compose() } is ResolutionMode.WithStatus -> { diff --git a/compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt b/compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt index 9688e7a2dd6..fdeb921527e 100644 --- a/compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt +++ b/compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt @@ -1,10 +1,10 @@ -// IGNORE_BACKEND_FIR: JVM_IR +// NB This test depends on line numbers // TARGET_BACKEND: JVM // WITH_RUNTIME // FULL_JDK // WITH_COROUTINES // IGNORE_BACKEND: -package test // NB This test depends on line numbers +package test import helpers.* import kotlin.coroutines.* diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/suspendFunctionIsAs.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/suspendFunctionIsAs.kt index 0b679cd2aa2..b4cd56ffe3c 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/suspendFunctionIsAs.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/suspendFunctionIsAs.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: NATIVE // IGNORE_BACKEND: JS // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/coroutines/localFunctions/named/insideLambda.kt b/compiler/testData/codegen/box/coroutines/localFunctions/named/insideLambda.kt index 92b04042112..d03f2546a69 100644 --- a/compiler/testData/codegen/box/coroutines/localFunctions/named/insideLambda.kt +++ b/compiler/testData/codegen/box/coroutines/localFunctions/named/insideLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/localVal.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/localVal.kt index ce01028d789..02113d0964d 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/localVal.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/localVal.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST