[NI] Update lambda result types.
When completing calls, update return types for functional descriptors for lambdas using type inference results. Add toString to some Call subclasses (for debugging purposes).
This commit is contained in:
committed by
Stanislav Erokhin
parent
2bf252afe6
commit
1d6ed4ef8e
@@ -102,7 +102,7 @@ class KotlinCallResolver(
|
||||
}
|
||||
|
||||
return maximallySpecificCandidates.map {
|
||||
kotlinCallCompleter.transformWhenAmbiguity(it)
|
||||
kotlinCallCompleter.transformWhenAmbiguity(it, callContext.lambdaAnalyzer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -17,10 +17,8 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.components
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCallArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinResolutionCandidate
|
||||
import org.jetbrains.kotlin.resolve.calls.model.LambdaKotlinCallArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
|
||||
interface IsDescriptorFromSourcePredicate: (CallableDescriptor) -> Boolean
|
||||
@@ -39,4 +37,6 @@ interface LambdaAnalyzer {
|
||||
// todo this is hack for some client which try to read ResolvedCall from trace before all calls completed
|
||||
fun bindStubResolvedCallForCandidate(candidate: KotlinResolutionCandidate)
|
||||
|
||||
fun completeLambdaReturnType(lambdaArgument: ResolvedLambdaArgument, returnType: KotlinType)
|
||||
|
||||
}
|
||||
+8
-4
@@ -63,8 +63,8 @@ class KotlinCallCompleter(
|
||||
fun getBuilder(): ConstraintSystemBuilder
|
||||
}
|
||||
|
||||
fun transformWhenAmbiguity(candidate: KotlinResolutionCandidate): ResolvedKotlinCall =
|
||||
toCompletedBaseResolvedCall(candidate.lastCall.constraintSystem.asCallCompleterContext(), candidate)
|
||||
fun transformWhenAmbiguity(candidate: KotlinResolutionCandidate, lambdaAnalyzer: LambdaAnalyzer): ResolvedKotlinCall =
|
||||
toCompletedBaseResolvedCall(candidate.lastCall.constraintSystem.asCallCompleterContext(), candidate, lambdaAnalyzer)
|
||||
|
||||
fun completeCallIfNecessary(
|
||||
candidate: KotlinResolutionCandidate,
|
||||
@@ -82,7 +82,7 @@ class KotlinCallCompleter(
|
||||
val c = candidate.lastCall.constraintSystem.asCallCompleterContext()
|
||||
|
||||
topLevelCall.competeCall(c, lambdaAnalyzer)
|
||||
return toCompletedBaseResolvedCall(c, candidate)
|
||||
return toCompletedBaseResolvedCall(c, candidate, lambdaAnalyzer)
|
||||
}
|
||||
|
||||
return ResolvedKotlinCall.OnlyResolvedKotlinCall(candidate)
|
||||
@@ -90,13 +90,17 @@ class KotlinCallCompleter(
|
||||
|
||||
private fun toCompletedBaseResolvedCall(
|
||||
c: Context,
|
||||
candidate: KotlinResolutionCandidate
|
||||
candidate: KotlinResolutionCandidate,
|
||||
lambdaAnalyzer: LambdaAnalyzer
|
||||
): ResolvedKotlinCall.CompletedResolvedKotlinCall {
|
||||
val currentSubstitutor = c.buildResultingSubstitutor()
|
||||
val completedCall = candidate.toCompletedCall(currentSubstitutor)
|
||||
val competedCalls = c.innerCalls.map {
|
||||
it.candidate.toCompletedCall(currentSubstitutor)
|
||||
}
|
||||
c.lambdaArguments.forEach {
|
||||
lambdaAnalyzer.completeLambdaReturnType(it, currentSubstitutor.safeSubstitute(it.returnType))
|
||||
}
|
||||
return ResolvedKotlinCall.CompletedResolvedKotlinCall(completedCall, competedCalls)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user