diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/PostponedArgumentInputTypesResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/PostponedArgumentInputTypesResolver.kt index 7d48a50d562..695b97f21a2 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/PostponedArgumentInputTypesResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/PostponedArgumentInputTypesResolver.kt @@ -72,11 +72,7 @@ class PostponedArgumentInputTypesResolver( ): ParameterTypesInfo? { val expectedType = argument.expectedType ?: return null val variableWithConstraints = notFixedTypeVariables[expectedType.constructor] ?: return null - - // We shouldn't collect functional types from constraints for anonymous functions as they have fully explicit declaration form - val functionalTypesFromConstraints = if (!isAnonymousFunction(argument)) { - findFunctionalTypesInConstraints(variableWithConstraints, variableDependencyProvider) - } else null + val functionalTypesFromConstraints = findFunctionalTypesInConstraints(variableWithConstraints, variableDependencyProvider) // 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) diff --git a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.kt b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.kt index 653dfdc3756..f9af745674a 100644 --- a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.kt +++ b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.kt @@ -142,8 +142,8 @@ fun main() { val x18: (C) -> Unit = select(id { it }, { it }, id<(B) -> Unit> { x -> x }) // Resolution of extension/non-extension functions combination - val x19: String.() -> Unit = select( kotlin.Unit")!>id {}, kotlin.Unit")!>id(fun(x: String) {})) - val x20: String.() -> Unit = select( kotlin.Unit")!>{}, kotlin.Unit")!>(fun(x: String) {})) + val x19: String.() -> Unit = select( kotlin.Unit")!>id { this }, kotlin.Unit")!>id(fun(x: String) {})) + val x20: String.() -> Unit = select( kotlin.Unit")!>{ this }, kotlin.Unit")!>(fun(x: String) {})) val x21: String.() -> Unit = select( kotlin.Unit")!>id(fun(x: String) {}), kotlin.Unit")!>id(fun(x: String) {})) select(id Unit>(fun(x: String) {}), kotlin.Unit")!>id(fun(x: String) {})) select( kotlin.Unit")!>id(fun String.(x: String) {}), kotlin.Unit")!>id(fun(x: String, y: String) {})) @@ -155,7 +155,7 @@ fun main() { select(id(id(fun(x: String, y: String) { }), fun String.(x: String) {}), { x, y -> x }) val x26: Int.(String) -> Int = fun (x: String) = 10 // it must be error, see KT-38439 // Receiver must be specified in anonymous function declaration - val x27: Int.(String) -> Int = id(fun (x: String) = 10) + val x27: Int.(String) -> Int = id(fun (x: String) = 10) select(id Unit> {}, { x: Int, y: String -> x }) // Inferring lambda parameter types by partially specified parameter types of other lambdas