[FIR] Remove redundant nullability from findFunctionalTypesInConstraints return type
This commit is contained in:
committed by
TeamCityServer
parent
7d8a8d543f
commit
fbab32c4dd
+5
-5
@@ -41,7 +41,7 @@ class PostponedArgumentInputTypesResolver(
|
|||||||
private fun Context.findFunctionalTypesInConstraints(
|
private fun Context.findFunctionalTypesInConstraints(
|
||||||
variable: VariableWithConstraints,
|
variable: VariableWithConstraints,
|
||||||
variableDependencyProvider: TypeVariableDependencyInformationProvider
|
variableDependencyProvider: TypeVariableDependencyInformationProvider
|
||||||
): List<TypeWithKind>? {
|
): List<TypeWithKind> {
|
||||||
fun List<Constraint>.extractFunctionalTypes() = mapNotNull { constraint ->
|
fun List<Constraint>.extractFunctionalTypes() = mapNotNull { constraint ->
|
||||||
TypeWithKind(constraint.type.getFunctionalTypeFromSupertypes(), constraint.kind)
|
TypeWithKind(constraint.type.getFunctionalTypeFromSupertypes(), constraint.kind)
|
||||||
}
|
}
|
||||||
@@ -67,22 +67,22 @@ class PostponedArgumentInputTypesResolver(
|
|||||||
val functionalTypesFromConstraints = findFunctionalTypesInConstraints(variableWithConstraints, variableDependencyProvider)
|
val functionalTypesFromConstraints = findFunctionalTypesInConstraints(variableWithConstraints, variableDependencyProvider)
|
||||||
|
|
||||||
// Don't create functional expected type for further error reporting about a different number of arguments
|
// Don't create functional expected type for further error reporting about a different number of arguments
|
||||||
if (functionalTypesFromConstraints != null && functionalTypesFromConstraints.distinctBy { it.type.argumentsCount() }.size > 1)
|
if (functionalTypesFromConstraints.distinctBy { it.type.argumentsCount() }.size > 1)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
val parameterTypesFromDeclaration =
|
val parameterTypesFromDeclaration =
|
||||||
if (argument is LambdaWithTypeVariableAsExpectedTypeMarker) argument.parameterTypesFromDeclaration else null
|
if (argument is LambdaWithTypeVariableAsExpectedTypeMarker) argument.parameterTypesFromDeclaration else null
|
||||||
|
|
||||||
val parameterTypesFromConstraints = functionalTypesFromConstraints?.mapTo(SmartSet.create()) { typeWithKind ->
|
val parameterTypesFromConstraints = functionalTypesFromConstraints.mapTo(SmartSet.create()) { typeWithKind ->
|
||||||
typeWithKind.type.extractArgumentsForFunctionalTypeOrSubtype().map {
|
typeWithKind.type.extractArgumentsForFunctionalTypeOrSubtype().map {
|
||||||
// We should use opposite kind as lambda's parameters are contravariant
|
// We should use opposite kind as lambda's parameters are contravariant
|
||||||
TypeWithKind(it, typeWithKind.direction.opposite())
|
TypeWithKind(it, typeWithKind.direction.opposite())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val annotations = functionalTypesFromConstraints?.map { it.type.getAttributes() }?.flatten()?.distinct()
|
val annotations = functionalTypesFromConstraints.map { it.type.getAttributes() }.flatten().distinct()
|
||||||
|
|
||||||
val extensionFunctionTypePresentInConstraints = functionalTypesFromConstraints?.any { it.type.isExtensionFunctionType() } == true
|
val extensionFunctionTypePresentInConstraints = functionalTypesFromConstraints.any { it.type.isExtensionFunctionType() }
|
||||||
|
|
||||||
// An extension function flag can only come from a declaration of anonymous function: `select({ this + it }, fun Int.(x: Int) = 10)`
|
// An extension function flag can only come from a declaration of anonymous function: `select({ this + it }, fun Int.(x: Int) = 10)`
|
||||||
val (parameterTypesFromDeclarationOfRelatedLambdas, isThereExtensionFunctionAmongRelatedLambdas, maxParameterCount) =
|
val (parameterTypesFromDeclarationOfRelatedLambdas, isThereExtensionFunctionAmongRelatedLambdas, maxParameterCount) =
|
||||||
|
|||||||
Reference in New Issue
Block a user