Add check already fixed variables in PostponedArgumentInputTypesResolver during adding constraints on them and using inside a functional type

^KT-42374 Fixed
This commit is contained in:
Victor Petukhov
2020-10-01 19:20:57 +03:00
parent 96ccf03794
commit 6c1dc43d25
8 changed files with 39 additions and 1 deletions
@@ -220,9 +220,12 @@ class PostponedArgumentInputTypesResolver(
return allGroupedParameterTypes.mapIndexed { index, types ->
val parameterTypeVariable = createTypeVariableForParameterType(argument, index)
val typeVariableConstructor = parameterTypeVariable.freshTypeConstructor
for (typeWithKind in types) {
if (typeVariableConstructor in fixedTypeVariables) break
if (typeWithKind == null) continue
when (typeWithKind.direction) {
ConstraintKind.EQUALITY -> csBuilder.addEqualityConstraint(
parameterTypeVariable.defaultType, typeWithKind.type, ArgumentConstraintPositionImpl(atom)
@@ -236,7 +239,13 @@ class PostponedArgumentInputTypesResolver(
}
}
parameterTypeVariable.defaultType.asTypeProjection()
val resultType = if (typeVariableConstructor in fixedTypeVariables) {
fixedTypeVariables[typeVariableConstructor] as KotlinType
} else {
parameterTypeVariable.defaultType
}
resultType.asTypeProjection()
}
}