Allow builder inference calls with labeled lambda

^KT-24993 Fixed
This commit is contained in:
Victor Petukhov
2021-04-30 13:24:37 +03:00
parent 90066d7e50
commit c5faf532f5
7 changed files with 78 additions and 5 deletions
@@ -14,10 +14,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.psi.KtLambdaExpression
import org.jetbrains.kotlin.psi.ValueArgument
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.renderer.DescriptorRendererOptions
import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver
@@ -335,8 +332,11 @@ fun isCoroutineCallWithAdditionalInference(
else
parameterDescriptor.hasSuspendFunctionType
val pureExpression = argument.getArgumentExpression()
val baseExpression = if (pureExpression is KtLabeledExpression) pureExpression.baseExpression else pureExpression
return parameterHasOptIn &&
argument.getArgumentExpression() is KtLambdaExpression &&
baseExpression is KtLambdaExpression &&
parameterDescriptor.type.let { it.isBuiltinFunctionalType && it.getReceiverTypeFromFunctionType() != null }
}