[NI] Fix detecting expected type variable for postponed atoms

#KT-36819 Fixed
This commit is contained in:
Dmitriy Novozhilov
2020-02-19 16:41:08 +03:00
parent 7e832e50ac
commit 102d5c7d5a
7 changed files with 88 additions and 2 deletions
@@ -167,9 +167,11 @@ class KotlinConstraintSystemCompleter(
val builtIns = (variable as TypeVariableTypeConstructor).builtIns
val csBuilder = (c as NewConstraintSystemImpl).getBuilder()
val expectedTypeVariable = postponedAtom.expectedType?.constructor?.takeIf { it in c.allTypeVariables } ?: variable
val atomToAnalyze = when (postponedAtom) {
is PostponedCallableReferenceAtom -> postponedAtom.preparePostponedAtomWithTypeVariableAsExpectedType(
c, csBuilder, variable,
c, csBuilder, expectedTypeVariable,
condition = { true },
isSuitable = KotlinType::isBuiltinFunctionalTypeOrSubtype,
typeVariableCreator = { TypeVariableForCallableReferenceReturnType(builtIns, "_Q") },
@@ -180,7 +182,7 @@ class KotlinConstraintSystemCompleter(
}
)
is LambdaWithTypeVariableAsExpectedTypeAtom -> postponedAtom.preparePostponedAtomWithTypeVariableAsExpectedType(
c, csBuilder, variable,
c, csBuilder, expectedTypeVariable,
condition = { it.atom.parametersTypes?.all { type -> type != null } != true },
isSuitable = KotlinType::isBuiltinFunctionalType,
typeVariableCreator = { TypeVariableForLambdaReturnType(postponedAtom.atom, builtIns, "_R") },