[NI] Analyse lambda in factory pattern resolution in independent context

This commit is contained in:
Dmitriy Novozhilov
2020-04-24 13:14:12 +03:00
parent a0c7bece93
commit e7869bd9d4
10 changed files with 144 additions and 6 deletions
@@ -72,7 +72,8 @@ interface KotlinResolutionCallbacks {
parameters: List<UnwrappedType>,
expectedReturnType: UnwrappedType?, // null means, that return type is not proper i.e. it depends on some type variables
annotations: Annotations,
stubsForPostponedVariables: Map<NewTypeVariable, StubType>
stubsForPostponedVariables: Map<NewTypeVariable, StubType>,
shouldRunInIndependentContext: Boolean = false
): ReturnArgumentsAnalysisResult
fun bindStubResolvedCallForCandidate(candidate: ResolvedCallAtom)
@@ -115,7 +115,8 @@ class KotlinCallCompleter(
firstCandidate.getSystem().asPostponedArgumentsAnalyzerContext(),
resolutionCallbacks,
firstAtom,
diagnosticHolderForLambda
diagnosticHolderForLambda,
shouldRunInIndependentContext = true
)
lambdas.getValue(firstCandidate).setAnalyzedResults(results.returnArgumentsInfo, listOf(firstAtom))
@@ -70,7 +70,8 @@ class PostponedArgumentsAnalyzer(
c: Context,
resolutionCallbacks: KotlinResolutionCallbacks,
lambda: ResolvedLambdaAtom,
diagnosticHolder: KotlinDiagnosticsHolder
diagnosticHolder: KotlinDiagnosticsHolder,
shouldRunInIndependentContext: Boolean = false
): ReturnArgumentsAnalysisResult {
val stubsForPostponedVariables = c.bindingStubsForPostponedVariables()
val currentSubstitutor = c.buildCurrentSubstitutor(stubsForPostponedVariables.mapKeys { it.key.freshTypeConstructor(c) })
@@ -128,7 +129,8 @@ class PostponedArgumentsAnalyzer(
parameters,
expectedTypeForReturnArguments,
convertedAnnotations ?: Annotations.EMPTY,
stubsForPostponedVariables.cast()
stubsForPostponedVariables.cast(),
shouldRunInIndependentContext
)
val (returnArgumentsInfo, inferenceSession, inferedReturnType, hasInapplicableCallForBuilderInference) =
returnArgumentsAnalysisResult