From 6b0a803d142e4bcbc1daa58a1217171944b02b53 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Tue, 2 Jun 2020 16:01:10 +0300 Subject: [PATCH] Allow suspend-conversion for callable references as part of adaptation --- .../checkers/SuspendConversionCallChecker.kt | 20 ------------------- ...ndConversionCompatibilityInDisabledMode.kt | 2 +- .../suspendConversionDisabled.kt | 2 +- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/SuspendConversionCallChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/SuspendConversionCallChecker.kt index e53145b618c..3ba1bf9c731 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/SuspendConversionCallChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/SuspendConversionCallChecker.kt @@ -35,25 +35,5 @@ object SuspendConversionCallChecker : CallChecker { ) ) } - - for ((parameter, argument) in resolvedCall.argumentMappingByOriginal) { - if (!parameter.type.isSuspendFunctionType) continue - if (argument !is ResolvedCallArgument.SimpleArgument) continue - - val callArgument = argument.callArgument - if (callArgument !is CallableReferenceKotlinCallArgument) continue - - val callableReferenceExpression = callArgument.psiExpression as? KtCallableReferenceExpression ?: continue - val argumentCall = callableReferenceExpression.callableReference.getResolvedCall(context.trace.bindingContext) ?: continue - val target = argumentCall.resultingDescriptor as? FunctionDescriptor ?: continue - if (!target.isSuspend) { - context.trace.report( - Errors.UNSUPPORTED_FEATURE.on( - callableReferenceExpression, - LanguageFeature.SuspendConversion to context.languageVersionSettings - ) - ) - } - } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suspendConversion/suspendConversionCompatibilityInDisabledMode.kt b/compiler/testData/diagnostics/tests/suspendConversion/suspendConversionCompatibilityInDisabledMode.kt index db3f1841414..ab3e106bbf3 100644 --- a/compiler/testData/diagnostics/tests/suspendConversion/suspendConversionCompatibilityInDisabledMode.kt +++ b/compiler/testData/diagnostics/tests/suspendConversion/suspendConversionCompatibilityInDisabledMode.kt @@ -10,7 +10,7 @@ object Test1 { fun bar(x: Int = 42): String = "" fun test() { - val result = foo(::bar) + val result = foo(::bar) result } } diff --git a/compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt b/compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt index 64a19857e9e..98ed49a4995 100644 --- a/compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt +++ b/compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt @@ -20,7 +20,7 @@ fun test( foo2(f2) foo3(f3) - foo1(::bar) + foo1(::bar) foo1(f2) foo1(f3)