[NI] Fix inference of lambda with receiver when wrapped...
in when/if or another lambda. #KT-37419 fixed
This commit is contained in:
+6
-3
@@ -263,9 +263,12 @@ class KotlinConstraintSystemCompleter(
|
||||
c.notFixedTypeVariables.getValue(variable),
|
||||
TypeVariableDirectionCalculator.ResolveDirection.TO_SUPERTYPE
|
||||
) as KotlinType
|
||||
val isExtensionWithoutParameters =
|
||||
functionalType.isExtensionFunctionType && functionalType.arguments.size == 2 && parameterTypes?.isEmpty() == true
|
||||
if (parameterTypes?.all { type -> type != null } == true && !isExtensionWithoutParameters) return this
|
||||
|
||||
val isExtensionFunction = functionalType.isExtensionFunctionType
|
||||
val isExtensionFunctionWithReceiverAsDeclaredParameter =
|
||||
isExtensionFunction && functionalType.arguments.size - 1 == parameterTypes?.count { it != null }
|
||||
if (parameterTypes?.all { it != null } == true && (!isExtensionFunction || isExtensionFunctionWithReceiverAsDeclaredParameter)) return this
|
||||
|
||||
if (!functionalType.isSuitable()) return this
|
||||
val returnVariable = typeVariableCreator()
|
||||
csBuilder.registerVariable(returnVariable)
|
||||
|
||||
Reference in New Issue
Block a user