Minor optimization

This commit is contained in:
Valentin Kipyatkov
2015-08-19 23:04:42 +03:00
parent 5fc6525db6
commit 9b04afc278
@@ -436,12 +436,20 @@ public class LookupElementFactory(
originalFunction.extensionReceiverParameter?.type?.let { addPotentiallyInferred(it) }
originalFunction.valueParameters.forEach { addPotentiallyInferred(it.type) }
fun allTypeParametersPotentiallyInferred() = originalFunction.typeParameters.all { it in potentiallyInferred }
if (allTypeParametersPotentiallyInferred()) return false
val returnType = originalFunction.returnType
// check that there is an expected type and return value from the function can potentially match it
if (returnType != null && expectedInfos.any { it.fuzzyType?.checkIsSuperTypeOf(originalFunction.fuzzyReturnType()!!) != null }) {
if (returnType != null) {
addPotentiallyInferred(returnType)
if (allTypeParametersPotentiallyInferred() && expectedInfos.any { it.fuzzyType?.checkIsSuperTypeOf(originalFunction.fuzzyReturnType()!!) != null }) {
return false
}
}
return originalFunction.typeParameters.any { it !in potentiallyInferred }
return true
}
}