FIR: perform more proper type approximation in completion

Note: test data change is questionable here
This commit is contained in:
Mikhail Glukhikh
2020-09-17 18:27:06 +03:00
parent 14cfc62745
commit 0310272738
2 changed files with 6 additions and 7 deletions
@@ -260,11 +260,10 @@ class FirCallCompletionResultsWriterTransformer(
candidate: Candidate, candidate: Candidate,
): FirResolvedTypeRef { ): FirResolvedTypeRef {
val initialType = candidate.substitutor.substituteOrSelf(type) val initialType = candidate.substitutor.substituteOrSelf(type)
val finalType = finalSubstitutor.substituteOrNull(initialType)?.let { substitutedType -> val substitutedType = finalSubstitutor.substituteOrNull(initialType)
typeApproximator.approximateToSuperType( val finalType = typeApproximator.approximateToSuperType(
substitutedType, TypeApproximatorConfiguration.FinalApproximationAfterResolutionAndInference, type = substitutedType ?: initialType, TypeApproximatorConfiguration.FinalApproximationAfterResolutionAndInference,
) as ConeKotlinType? ?: substitutedType ) as ConeKotlinType? ?: substitutedType
}
return withReplacedConeType(finalType) return withReplacedConeType(finalType)
} }
@@ -19,6 +19,6 @@ class In<in F> {
} }
fun test() { fun test() {
A.foo().x() checkType { _<Any?>() } A.foo().<!UNRESOLVED_REFERENCE!>x<!>() <!INAPPLICABLE_CANDIDATE!>checkType<!> { _<Any?>() }
A.bar().<!INAPPLICABLE_CANDIDATE!>y<!>(null) A.bar().<!UNRESOLVED_REFERENCE!>y<!>(null)
} }