Don't try to infer postponed variables on lambdas without BuilderInference annotation

^KT-39618 Fixed
This commit is contained in:
Victor Petukhov
2020-07-14 17:18:13 +03:00
parent 9e737156dd
commit b0c96a61ec
10 changed files with 85 additions and 1 deletions
@@ -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)
@@ -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
@@ -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