Don't try to infer postponed variables on lambdas without BuilderInference annotation
^KT-39618 Fixed
This commit is contained in:
+1
-1
@@ -187,7 +187,7 @@ class PostponedArgumentsAnalyzer(
|
||||
|
||||
lambda.setAnalyzedResults(returnArgumentsInfo, subResolvedKtPrimitives)
|
||||
|
||||
if (inferenceSession != null) {
|
||||
if (inferenceSession != null && lambda.atom.hasBuilderInferenceAnnotation) {
|
||||
val storageSnapshot = c.getBuilder().currentStorage()
|
||||
|
||||
val postponedVariables = inferenceSession.inferPostponedVariables(lambda, storageSnapshot, diagnosticHolder)
|
||||
|
||||
+4
@@ -238,6 +238,10 @@ internal object PostponedVariablesInitializerResolutionPart : ResolutionPart() {
|
||||
if (!callComponents.statelessCallbacks.isCoroutineCall(argument, parameter)) continue
|
||||
val receiverType = parameter.type.getReceiverTypeFromFunctionType() ?: continue
|
||||
|
||||
if (argument is LambdaKotlinCallArgument && !argument.hasBuilderInferenceAnnotation) {
|
||||
argument.hasBuilderInferenceAnnotation = true
|
||||
}
|
||||
|
||||
for (freshVariable in resolvedCall.freshVariablesSubstitutor.freshVariables) {
|
||||
if (resolvedCall.typeArgumentMappingByOriginal.getTypeArgument(freshVariable.originalTypeParameter) is SimpleTypeArgument)
|
||||
continue
|
||||
|
||||
+8
@@ -52,6 +52,14 @@ interface LambdaKotlinCallArgument : PostponableKotlinCallArgument {
|
||||
override val isSpread: Boolean
|
||||
get() = false
|
||||
|
||||
/*
|
||||
* Builder inference is supported only for lambdas (so it's implemented only in `LambdaKotlinCallArgumentImpl`),
|
||||
* anonymous functions aren't supported
|
||||
*/
|
||||
var hasBuilderInferenceAnnotation: Boolean
|
||||
get() = false
|
||||
set(value) {}
|
||||
|
||||
/**
|
||||
* parametersTypes == null means, that there is no declared arguments
|
||||
* null inside array means that this type is not declared explicitly
|
||||
|
||||
Reference in New Issue
Block a user