Fail calls constraints of which contain uninferred type parameter

^KT-44055 Fixed

It's possible only if there is a callable reference among subcalls which go though the old type inference (and the error for uninferred type parameter wasn't reported)
This commit is contained in:
Victor Petukhov
2020-12-24 13:52:05 +03:00
parent 9afc13f002
commit 0dde5ddd7e
8 changed files with 30 additions and 54 deletions
@@ -141,8 +141,12 @@ class VariableFixationFinder(
return false
}
private fun Context.variableHasProperArgumentConstraints(variable: TypeConstructorMarker): Boolean =
notFixedTypeVariables[variable]?.constraints?.any { isProperArgumentConstraint(it) } ?: false
private fun Context.variableHasProperArgumentConstraints(variable: TypeConstructorMarker): Boolean {
val constraints = notFixedTypeVariables[variable]?.constraints ?: return false
// temporary hack to fail calls which contain callable references resolved though OI with uninferred type parameters
val areThereConstraintsWithUninferredTypeParameter = constraints.any { c -> c.type.contains { it.isUninferredParameter() } }
return constraints.any { isProperArgumentConstraint(it) } && !areThereConstraintsWithUninferredTypeParameter
}
private fun Context.isProperArgumentConstraint(c: Constraint) =
isProperType(c.type)
@@ -167,7 +171,7 @@ inline fun TypeSystemInferenceExtensionContext.isProperTypeForFixation(
type: KotlinTypeMarker,
isProper: (KotlinTypeMarker) -> Boolean
): Boolean {
if (!isProper(type) || type.contains { it.isUninferredParameter() }) return false
if (!isProper(type)) return false
if (type.isCapturedType()) {
val projection = (type as? SimpleTypeMarker)?.asCapturedType()?.typeConstructorProjection() ?: return true
if (projection.isStarProjection()) return true