diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/KotlinCallResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/KotlinCallResolver.kt index 6f6cff00228..164e7984ae8 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/KotlinCallResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/KotlinCallResolver.kt @@ -141,14 +141,14 @@ class KotlinCallResolver( if ( maximallySpecificCandidates.size > 1 && - callComponents.languageVersionSettings.supportsFeature(LanguageFeature.FactoryPatternResolution) && + callComponents.languageVersionSettings.supportsFeature(LanguageFeature.OverloadResolutionByLambdaReturnType) && candidates.all { resolutionCallbacks.inferenceSession.shouldRunCompletion(it) } ) { val candidatesWithAnnotation = candidates.filter { it.resolvedCall.candidateDescriptor.annotations.hasAnnotation(OVERLOAD_RESOLUTION_BY_LAMBDA_ANNOTATION) } val candidatesWithoutAnnotation = candidates - candidatesWithAnnotation if (candidatesWithAnnotation.isNotEmpty()) { - val newCandidates = kotlinCallCompleter.chooseCandidateRegardingFactoryPatternResolution(maximallySpecificCandidates, resolutionCallbacks) + val newCandidates = kotlinCallCompleter.chooseCandidateRegardingOverloadResolutionByLambdaReturnType(maximallySpecificCandidates, resolutionCallbacks) maximallySpecificCandidates = overloadingConflictResolver.chooseMaximallySpecificCandidates( newCandidates, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt index 1f121a7d446..bab59ced937 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt @@ -76,7 +76,7 @@ class KotlinCallCompleter( } } - fun chooseCandidateRegardingFactoryPatternResolution( + fun chooseCandidateRegardingOverloadResolutionByLambdaReturnType( candidates: Set, resolutionCallbacks: KotlinResolutionCallbacks ): Set { diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/independentResolutionInLambda.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/independentResolutionInLambda.fir.kt index 1ed50155566..de14e25943c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/independentResolutionInLambda.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/independentResolutionInLambda.fir.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +FactoryPatternResolution +// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/independentResolutionInLambda.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/independentResolutionInLambda.kt index b06f91dcffe..f7fc1603694 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/independentResolutionInLambda.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/independentResolutionInLambda.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +FactoryPatternResolution +// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_1.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_1.fir.kt index 31b30656b87..9d743017c38 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_1.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_1.fir.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +FactoryPatternResolution +// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_1.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_1.kt index 1203446c796..989ad9a96e5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_1.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_1.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +FactoryPatternResolution +// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_2.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_2.fir.kt index d5534900d64..97436c8de29 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_2.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_2.fir.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +FactoryPatternResolution +// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_2.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_2.kt index b0fcde84074..c4c0ba0d0d2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_2.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_2.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +FactoryPatternResolution +// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_3.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_3.fir.kt index e9c069e337e..c5a6b7f8778 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_3.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_3.fir.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +FactoryPatternResolution +// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_3.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_3.kt index 4f11533e582..71f5bdf68e8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_3.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/multipleOverloads_3.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +FactoryPatternResolution +// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_disabled.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_disabled.fir.kt index af77b9a790e..edea75cb513 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_disabled.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_disabled.fir.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference -FactoryPatternResolution +// !LANGUAGE: +NewInference -OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_disabled.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_disabled.kt index 94dd36c271d..2e15db0c30b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_disabled.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_disabled.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference -FactoryPatternResolution +// !LANGUAGE: +NewInference -OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled.fir.kt index 869cf15f35d..2d2fbb7ce42 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled.fir.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +FactoryPatternResolution +// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled.kt index a0200cd8f07..571c23e8131 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +FactoryPatternResolution +// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled_no_annotation.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled_no_annotation.fir.kt index 2b38b1b6e5f..49f717234b2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled_no_annotation.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled_no_annotation.fir.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +FactoryPatternResolution +// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION // ISSUE: KT-11265 diff --git a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled_no_annotation.kt b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled_no_annotation.kt index 7f924f1496a..bf4b674420f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled_no_annotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/factoryPattern/overloadByLambdaReturnType_enabled_no_annotation.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +FactoryPatternResolution +// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION // ISSUE: KT-11265 diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 9170a99e9be..35a3d393527 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -153,7 +153,7 @@ enum class LanguageFeature( FunctionReferenceWithDefaultValueAsOtherType(sinceVersion = KOTLIN_1_4), NonStrictOnlyInputTypesChecks(sinceVersion = KOTLIN_1_4), SuspendConversion(sinceVersion = KOTLIN_1_4, defaultState = State.DISABLED), - FactoryPatternResolution(sinceVersion = KOTLIN_1_4), + OverloadResolutionByLambdaReturnType(sinceVersion = KOTLIN_1_4), BooleanElvisBoundSmartCasts(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED), // see KT-26357 for details NewDataFlowForTryExpressions(sinceVersion = KOTLIN_1_4, defaultState = State.DISABLED),